X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsupport%2Flstrings.h;h=87e7f242fd7691785e12966ba4f5ad98f444537b;hb=e4c3ce462791c85922d919f8859e3408f57d10fa;hp=0f10743b03f9753bb001569f3ab496bfc8778003;hpb=6c300f72a217722652dc27db9108e1050028979c;p=lyx.git diff --git a/src/support/lstrings.h b/src/support/lstrings.h index 0f10743b03..87e7f242fd 100644 --- a/src/support/lstrings.h +++ b/src/support/lstrings.h @@ -68,6 +68,13 @@ bool isStrUnsignedInt(std::string const & str); /// bool isStrDbl(std::string const & str); +bool isHex(lyx::docstring const & str); + +int hexToInt(lyx::docstring const & str); + +/// is \p str pure ascii? +bool isAscii(docstring const & str); + /// char lowercase(char c); @@ -82,9 +89,11 @@ char_type uppercase(char_type c); /// same as lowercase(), but ignores locale std::string const ascii_lowercase(std::string const &); +docstring const ascii_lowercase(docstring const &); /// std::string const lowercase(std::string const &); +docstring const lowercase(docstring const &); /// std::string const uppercase(std::string const &); @@ -100,14 +109,22 @@ bool suffixIs(std::string const &, char); bool suffixIs(std::string const &, std::string const &); /// -template -bool contains(std::string const & a, B b) +inline bool contains(std::string const & a, std::string const & b) +{ + return a.find(b) != std::string::npos; +} + +inline bool contains(docstring const & a, docstring const & b) +{ + return a.find(b) != docstring::npos; +} + +inline bool contains(std::string const & a, char b) { return a.find(b) != std::string::npos; } -template -bool contains(docstring const & a, B b) +inline bool contains(docstring const & a, char_type b) { return a.find(b) != docstring::npos; } @@ -173,13 +190,15 @@ std::string const trim(std::string const & a, char const * p = " "); \endcode */ std::string const rtrim(std::string const & a, char const * p = " "); +docstring const rtrim(docstring const & a, char const * p = " "); /** Trims characters off the beginning of a string. \code - ltrim("ababcdef", "ab") = "cdef" + ("ababcdef", "ab") = "cdef" \endcode */ std::string const ltrim(std::string const & a, char const * p = " "); +docstring const ltrim(docstring const & a, char const * p = " "); /** Splits the string by the first delim. Splits the string by the first appearance of delim. @@ -199,12 +218,15 @@ std::string const split(std::string const & a, char delim); /// Same as split but uses the last delim. std::string const rsplit(std::string const & a, std::string & piece, char delim); -/// Escapes non ASCII chars +/// Escapes non ASCII chars and other problematic characters that cause +/// problems in latex labels. docstring const escape(docstring const & lab); /// gives a vector of stringparts which have the delimiter delim std::vector const getVectorFromString(std::string const & str, std::string const & delim = std::string(",")); +std::vector const getVectorFromString(docstring const & str, + docstring const & delim = from_ascii(",")); // the same vice versa std::string const getStringFromVector(std::vector const & vec,