char_predicates.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Internal header. Functional objects (predicates) on char
  2. //
  3. // Platform: ISO C++ 98
  4. // $Id$
  5. //
  6. // (c) __vic 2021
  7. #ifndef __VIC_CHAR_PREDICATES_H
  8. #define __VIC_CHAR_PREDICATES_H
  9. #include<__vic/ascii.h>
  10. #include<__vic/set_of_chars.h>
  11. namespace __vic {
  12. //////////////////////////////////////////////////////////////////////////////
  13. struct is_ascii_ws
  14. {
  15. bool operator()(char ch) const { return ascii::isspace(ch); }
  16. };
  17. //////////////////////////////////////////////////////////////////////////////
  18. class is_eq_char
  19. {
  20. char c;
  21. public:
  22. explicit is_eq_char(char ch) : c(ch) {}
  23. bool operator()(char ch) const { return ch == c; }
  24. };
  25. //////////////////////////////////////////////////////////////////////////////
  26. class is_one_of_chars
  27. {
  28. set_of_chars set;
  29. public:
  30. explicit is_one_of_chars(const char *chars) : set(chars) {}
  31. bool operator()(char ch) const { return set.contains(ch); }
  32. };
  33. //////////////////////////////////////////////////////////////////////////////
  34. } // namespace
  35. #endif // header guard