10 #ifndef G3D_stringutils_h
11 #define G3D_stringutils_h
29 void parseCommaSeparated(
const std::string s, Array<std::string>& array,
bool stripQuotes =
true);
34 inline size_t findSlash(
const std::string& f,
size_t start = 0) {
35 size_t i = f.find(
'/', start);
36 size_t j = f.find(
'\\', start);
37 if ((i != std::string::npos) && (i < j)) {
46 if (i == std::string::npos) {
48 }
else if (j == std::string::npos) {
58 inline size_t findLastSlash(
const std::string& f,
size_t start = std::string::npos) {
59 if (start == std::string::npos) {
60 start = f.length() - 1;
63 size_t i = f.rfind(
'/', start);
64 size_t j = f.rfind(
'\\', start);
70 std::string
replace(
const std::string& s,
const std::string& pattern,
const std::string& replacement);
79 (
const std::string& test,
80 const std::string& pattern);
86 (
const std::string& test,
87 const std::string& pattern);
99 (
const std::string&
input,
106 const std::string& s1,
107 const std::string& s2);
110 const std::string* s1,
111 const std::string* s2);
117 const std::string&
x);
120 const std::string&
x);
126 const std::string&
x,
139 const std::string& joinStr);
145 const std::string& s);
151 return isspace(c) != 0;
158 return (c ==
'\n') || (c ==
'\r');
165 return isdigit(c) != 0;
172 return isalpha(c) != 0;
176 return (c ==
'\\') || (c ==
'/');
180 return (c ==
'\'') || (c ==
'\"');
186 for (
int i = 0; i < (int)s.size(); ++i) {
bool beginsWith(const std::string &test, const std::string &pattern)
Returns true if the test string begins with the pattern string.
Definition: stringutils.cpp:81
int stringCompare(const std::string &s1, const std::string &s2)
Definition: stringutils.cpp:200
size_t findLastSlash(const std::string &f, size_t start=std::string::npos)
Definition: stringutils.h:58
std::string trimWhitespace(const std::string &s)
Definition: stringutils.cpp:288
std::string wordWrap(const std::string &input, int numCols)
Produces a new string that is the input string wrapped at a certain number of columns (where the line...
Definition: stringutils.cpp:146
std::string stringJoin(const G3D::Array< std::string > &a, char joinChar)
Definition: stringutils.cpp:252
std::string replace(const std::string &s, const std::string &pattern, const std::string &replacement)
Definition: stringutils.cpp:97
bool isNewline(const unsigned char c)
Definition: stringutils.h:157
T max(const T &x, const T &y)
Definition: g3dmath.h:320
const char * NEWLINE
Definition: stringutils.cpp:33
void parseCommaSeparated(const std::string s, Array< std::string > &array, bool stripQuotes=true)
Definition: stringutils.cpp:37
bool isDigit(const unsigned char c)
Definition: stringutils.h:164
bool isSlash(const unsigned char c)
Definition: stringutils.h:175
size_t maxNotNPOS(size_t i, size_t j)
Returns the larger string index, ignoring std::string::npos.
Definition: stringutils.h:45
G3D::Array< std::string > stringSplit(const std::string &x, char splitChar)
Definition: stringutils.cpp:230
std::string toLower(const std::string &x)
Definition: stringutils.cpp:223
std::string toUpper(const std::string &x)
Definition: stringutils.cpp:216
bool isLetter(const unsigned char c)
Definition: stringutils.h:171
bool endsWith(const std::string &test, const std::string &pattern)
Returns true if the test string ends with the pattern string.
Definition: stringutils.cpp:127
int countNewlines(const std::string &s)
Definition: stringutils.h:184
int stringPtrCompare(const std::string *s1, const std::string *s2)
Definition: stringutils.cpp:208
size_t findSlash(const std::string &f, size_t start=0)
Definition: stringutils.h:34
bool isWhiteSpace(const unsigned char c)
Definition: stringutils.h:150
bool isQuote(const unsigned char c)
Definition: stringutils.h:179
G3D::int16 x
Definition: Vector2int16.h:37
bool isValidIdentifier(const std::string &s)
Definition: stringutils.cpp:115