#include "support/lstrings.h"
#include "support/convert.h"
-#include "support/gettext.h"
#include "support/qstring_helpers.h"
-#include "support/textutils.h"
-#include <boost/tokenizer.hpp>
#include "support/lassert.h"
#include <QString>
-#include <QVector>
#include <cstdio>
#include <algorithm>
}
+bool isASCII(char_type c)
+{
+ return c < 0x80;
+}
+
+
namespace support {
int compare_no_case(docstring const & s, docstring const & s2)
char lowercase(char c)
{
- LASSERT(static_cast<unsigned char>(c) < 0x80, /**/);
+ LASSERT(isASCII(c), /**/);
return char(tolower(c));
}
char uppercase(char c)
{
- LASSERT(static_cast<unsigned char>(c) < 0x80, /**/);
+ LASSERT(isASCII(c), /**/);
return char(toupper(c));
}
}
+int count_char(string const & str, char chr)
+{
+ int count = 0;
+ string::const_iterator lit = str.begin();
+ string::const_iterator end = str.end();
+ for (; lit != end; ++lit)
+ if ((*lit) == chr)
+ count++;
+ return count;
+}
+
+
/// Count all occurences of char \a chr inside \a str
int count_char(docstring const & str, docstring::value_type chr)
{
}
+docstring const rsplit(docstring const & a, docstring & piece, char_type delim)
+{
+ docstring tmp;
+ size_t i = a.rfind(delim);
+ if (i != string::npos) { // delimiter was found
+ piece = a.substr(0, i);
+ tmp = a.substr(i + 1);
+ } else { // delimiter was not found
+ piece.erase();
+ }
+ return tmp;
+}
+
+
docstring const rsplit(docstring const & a, char_type delim)
{
docstring tmp;