diff options
Diffstat (limited to 'dep/include/g3dlite/G3D/stringutils.h')
-rw-r--r-- | dep/include/g3dlite/G3D/stringutils.h | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/dep/include/g3dlite/G3D/stringutils.h b/dep/include/g3dlite/G3D/stringutils.h index 59449313bf5..e15a757a7a6 100644 --- a/dep/include/g3dlite/G3D/stringutils.h +++ b/dep/include/g3dlite/G3D/stringutils.h @@ -1,10 +1,10 @@ /** @file stringutils.h - - @maintainer Morgan McGuire, matrix@graphics3d.com - + + @maintainer Morgan McGuire, http://graphics.cs.williams.edu + @author 2000-09-09 - @edited 2002-11-30 + @edited 2008-08-05 */ #ifndef G3D_STRINGUTILS_H @@ -12,12 +12,22 @@ #include "G3D/platform.h" #include "G3D/Array.h" -#include <string> +#include <cstring> namespace G3D { extern const char* NEWLINE; +/** Separates a comma-separated line, properly escaping commas within + double quotes (") and super quotes ("""). This matches Microsoft Excel's + CSV output. + + \param stripQuotes If true, strips leading and trailing " and """ + + \sa G3D::stringSplit, G3D::TextInput, G3D::readWholeFile +*/ +void parseCommaSeparated(const std::string s, Array<std::string>& array, bool stripQuotes = true); + /** Returns true if the test string begins with the pattern string. */ @@ -91,36 +101,36 @@ std::string trimWhitespace( /** These standard C functions are renamed for clarity/naming conventions and to return bool, not int. */ -inline bool isWhiteSpace(const char c) { +inline bool isWhiteSpace(const unsigned char c) { return isspace(c) != 0; } /** These standard C functions are renamed for clarity/naming conventions and to return bool, not int. */ -inline bool isNewline(const char c) { +inline bool isNewline(const unsigned char c) { return (c == '\n') || (c == '\r'); } /** These standard C functions are renamed for clarity/naming conventions and to return bool, not int. */ -inline bool isDigit(const char c) { +inline bool isDigit(const unsigned char c) { return isdigit(c) != 0; } /** These standard C functions are renamed for clarity/naming conventions and to return bool, not int. */ -inline bool isLetter(const char c) { +inline bool isLetter(const unsigned char c) { return isalpha(c) != 0; } -inline bool isSlash(const char c) { +inline bool isSlash(const unsigned char c) { return (c == '\\') || (c == '/'); } -inline bool isQuote(const char c) { +inline bool isQuote(const unsigned char c) { return (c == '\'') || (c == '\"'); } @@ -128,4 +138,3 @@ inline bool isQuote(const char c) { #endif - |