ProfanityFilter.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2014, Oculus VR, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. *
  9. */
  10. #ifndef __PROFANITY_FILTER__H__
  11. #define __PROFANITY_FILTER__H__
  12. #include "DS_List.h"
  13. #include "RakString.h"
  14. namespace RakNet {
  15. class ProfanityFilter
  16. {
  17. public:
  18. ProfanityFilter();
  19. ~ProfanityFilter();
  20. // Returns true if the string has profanity, false if not.
  21. bool HasProfanity(const char *str);
  22. // Removes profanity. Returns number of occurrences of profanity matches (including 0)
  23. int FilterProfanity(const char *str, char *output, bool filter = true);
  24. // Number of profanity words loaded
  25. int Count();
  26. void AddWord(RakNet::RakString newWord);
  27. private:
  28. DataStructures::List<RakNet::RakString> words;
  29. char RandomBanChar();
  30. static char BANCHARS[];
  31. static char WORDCHARS[];
  32. };
  33. } // namespace RakNet
  34. #endif // __PROFANITY__H__
粤ICP备19079148号