StringList.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef ANKI_UTIL_STRING_LIST_H
  2. #define ANKI_UTIL_STRING_LIST_H
  3. #include "anki/util/Vector.h"
  4. #include "anki/util/StdTypes.h"
  5. #include <string>
  6. namespace anki {
  7. /// @addtogroup util
  8. /// @{
  9. /// A simple convenience class for string lists
  10. class StringList: public Vector<std::string>
  11. {
  12. public:
  13. typedef StringList Self; ///< Self type
  14. typedef Vector<std::string> Base; ///< Its the vector of strings
  15. typedef Base::value_type String; ///< Its string
  16. typedef String::value_type Char; ///< Char type
  17. /// Join all the elements into a single big string using a the
  18. /// seperator @a sep
  19. String join(const Char* sep) const;
  20. /// Returns the index position of the last occurrence of @a value in
  21. /// the list
  22. /// @return -1 of not found
  23. I getIndexOf(const Char* value) const;
  24. /// Split a string using a list of separators (@a sep) and return these
  25. /// strings in a string list
  26. static Self splitString(const Char* s, const Char sep = ' ',
  27. Bool keepEmpties = false);
  28. /// Mainly for the unit tests
  29. friend std::ostream& operator<<(std::ostream& s, const Self& a);
  30. };
  31. /// @}
  32. } // end namespace anki
  33. #endif