| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #ifndef ANKI_UTIL_STRING_LIST_H
- #define ANKI_UTIL_STRING_LIST_H
- #include "anki/util/Vector.h"
- #include "anki/util/StdTypes.h"
- #include <string>
- namespace anki {
- /// @addtogroup util
- /// @{
- /// @addtogroup containers
- /// @{
- /// A simple convenience class for string lists
- class StringList: public Vector<std::string>
- {
- public:
- typedef StringList Self; ///< Self type
- typedef Vector<std::string> Base; ///< Its the vector of strings
- typedef Base::value_type String; ///< Its string
- typedef String::value_type Char; ///< Char type
- enum StringListSort
- {
- SLS_ASCENDING = 0,
- SLS_DESCENDING
- };
- /// Join all the elements into a single big string using a the
- /// seperator @a sep
- String join(const Char* sep) const;
- /// Returns the index position of the last occurrence of @a value in
- /// the list
- /// @return -1 of not found
- I getIndexOf(const Char* value) const;
- /// Sort the string list
- void sortAll(const StringListSort method = SLS_ASCENDING);
- /// Split a string using a list of separators (@a sep) and return these
- /// strings in a string list
- static Self splitString(const Char* s, const Char sep = ' ',
- Bool keepEmpties = false);
- /// Mainly for the unit tests
- friend std::ostream& operator<<(std::ostream& s, const Self& a);
- };
- /// @}
- /// @}
- } // end namespace anki
- #endif
|