60#include <Inventor/STL/string>
61#include <Inventor/STL/ostream>
62#include <Inventor/STL/vector>
66#pragma warning(disable:4251)
597 return os << str.toUtf8();
1044 SbString& fromUtf8(
const char* str );
1052 const char* toUtf8()
const;
1054 static uint32_t
hash(
const char *s);
1057 static inline bool isDigit(
const int c);
1058 static inline bool isSpace(
const int c);
1061 void split(std::vector<SbString>& tokens)
const;
1069 void setCapacity(
int nBytes );
1072 const std::string& nonUnicodeToStdString()
const {
return m_cdata; }
1076 static void initClass();
1078 static void exitClass();
1081# define SB_LOCALE_DATA_TYPE _locale_t
1082# define SB_LOCALE_ALLOC_FUNC _create_locale
1083# define SB_LOCALE_FREE_FUNC _free_locale
1084# define SB_LOCALE_STRTOD_FUNC _strtod_l
1085# define SB_LOCALE_STRTOL_FUNC _strtol_l
1086# define SB_LOCALE_SPRINTF_FUNC _sprintf_l
1087# define SB_LOCALE_SNPRINTF_FUNC _snprintf_l
1088# define SB_LOCALE_SCANF_FUNC _scanf_l
1089# define SB_LOCALE_SSCANF_FUNC _sscanf_l
1090# define SB_LOCALE_FSCANF_FUNC _fscanf_l
1091# define SB_LOCALE_VPRINTF _vprintf_l
1092# define SB_LOCALE_FPRINTF_FUNC _fprintf_l
1093# define SB_LOCALE , (SB_LOCALE_DATA_TYPE)SbString::getLocaleObject()
1095# define SB_LOCALE_DATA_TYPE locale_t
1096# define SB_LOCALE_ALLOC_FUNC newlocale
1097# define SB_LOCALE_FREE_FUNC freelocale
1098# define SB_LOCALE_STRTOD_FUNC strtod
1099# define SB_LOCALE_STRTOL_FUNC strtol
1100# define SB_LOCALE_SPRINTF_FUNC ::sprintf
1101# define SB_LOCALE_FPRINTF_FUNC fprintf
1102# define SB_LOCALE_SNPRINTF_FUNC snprintf
1103# define SB_LOCALE_SCANF_FUNC scanf
1104# define SB_LOCALE_SSCANF_FUNC sscanf
1105# define SB_LOCALE_FSCANF_FUNC fscanf
1106# define SB_LOCALE_VPRINTF vprintf
1110 static float toFloat_l(
const char* str,
SbBool* ok = NULL );
1112 static double toDouble_l(
const char* str,
SbBool* ok = NULL );
1114 static long toLong_l(
const char* str,
SbBool* ok = NULL );
1116 static void toString_l(
char* str,
const char* format,
float num );
1118 static void toString_l(
char* str,
const char* format,
double num );
1120 static void* getLocaleObject();
1137 static void buildLocaleCache();
1138 static bool localeCacheInitialized;
1139 static bool localeDigitCache[256];
1140 static bool localeSpaceCache[256];
1141 static char* s_tmpstr;
1142 static size_t s_tmpStrSize;
1144 std::wstring m_data;
1145 std::string m_cdata;
1147 mutable std::wstring m_tmpData;
1148 mutable std::string m_tmpCData;
1156 mutable unsigned short* m_utf16Buffer;
1173inline bool SbString::isDigit(
const int c)
1175 if ((c < 0) || (c>=256))
1178 if (!localeCacheInitialized)
1180 return localeDigitCache[c];
1183inline bool SbString::isSpace(
const int c)
1185 if (!localeCacheInitialized)
1187 return localeSpaceCache[c];
#define TRUE
Possible value of SbBool.
Class for smart character strings.
friend bool operator<=(const SbString &str1, const SbString &str2)
"less than or equal" relational operator for SbString Returns TRUE if the first operand is less tha...
uint32_t hash() const
Returns a reasonable hash key for string.
SoNONUNICODE friend const SbString operator+(const SbString &s1, const char *s2)
This is an overloaded member function, provided for convenience.
SoNONUNICODE const std::string & getSString() const
Returns pointer to the std::string.
SoNONUNICODE const SO_WCHAR_T * wgetString() const
Returns pointer to the character string.
int findAny(const SbString &str) const
Returns the position of the first occurence of any character contained in the specified sub string.
SoNONUNICODE SbString(const int digitString)
Constructor that takes an integer to be turned into a string.
SbBool isUnicode() const
Returns TRUE if the string contains Unicode characters.
int rfind(const SbString &str) const
Returns the position of the last occurence of the specified substring.
SbString(const SbString &str)
Constructor that takes an SbString.
unsigned long toULong(SbBool *ok=NULL) const
Returns the numeric value represented by the string.
SbString & fromWideChar(const wchar_t *str)
Set the string from a wide char string.
bool endsWith(const SbString &str) const
Returns true if the string ends with the specified string.
unsigned int toUInt(SbBool *ok=NULL) const
Returns the numeric value represented by the string.
short toShort(SbBool *ok=NULL) const
Returns the numeric value represented by the string.
friend bool operator<(const SbString &str1, const SbString &str2)
"less than" relational operator for SbString Returns TRUE if the first operand is less than the sec...
SbBool isNull() const
Returns TRUE if the string is a null string.
SbString & setNum(long value, int base=10)
Sets the string to a formatted numeric value.
unsigned short * toUtf16() const
Returns the string as a UTF-16 string.
float toFloat(SbBool *ok=NULL) const
Returns the numeric value represented by the string.
std::string toStdString() const
Returns the string as an STL string.
SbString(const std::string &std_string)
Constructor that takes an STL string.
SbString & setNum(float value)
Sets the string to a formatted numeric value.
SbString & setNum(unsigned long value, int base=10)
Sets the string to a formatted numeric value.
SoNONUNICODE friend const SbString operator+(const char *s1, const SbString &s2)
This is an overloaded member function, provided for convenience.
SbString & operator=(const SbString &str)
Assignment operator for SbString.
int find(const SbString &str) const
Returns the position of the first occurence of the specified substring.
friend int operator==(const SbString &str1, const SbString &str2)
Equality operator for SbString / SbString comparison.
SbString & setNum(unsigned short value, int base=10)
Sets the string to a formatted numeric value.
SoNONUNICODE const char * getString() const
Returns pointer to the character string.
long toLong(SbBool *ok=NULL) const
Returns the numeric value represented by the string.
const wchar_t * toWideChar() const
Returns the string as a wide char string.
SoNONUNICODE const std::wstring & wgetSString() const
Returns pointer to the stl::wstring.
SoNONUNICODE char operator[](int i) const
Returns the character at index i, or 0 if i is beyond the length of the string.
SbString(const std::wstring &std_wstring)
Constructor that takes an STL wstring.
SbBool containsAny(const SbString &str) const
Returns TRUE if any of the characters listed in the str parameter exist in the string.
unsigned short toUShort(SbBool *ok=NULL) const
Returns the numeric value represented by the string.
SbString()
Default constructor.
SbString & setNum(double value)
Sets the string to a formatted numeric value.
SbBool contains(const SbString &str) const
Returns TRUE if the string contains the specified substring.
void makeEmpty(const SbBool freeOld=TRUE)
Sets string to be the empty string ("").
SbString & setNum(unsigned int value, int base=10)
Sets the string to a formatted numeric value.
SbString upper() const
Returns an uppercase copy of the string.
SbString getSubString(int startChar, int endChar=-1) const
Returns a new string containing the sub-string from startChar (position) to endChar,...
SbString lower() const
Returns a lowercase copy of the string.
SoNONUNICODE SbString & sprintf(const char *cformat,...)
Builds a formatted string from the format string cformat and an arbitrary list of arguments.
int findLast(const SbString &str) const
Returns the position of the last occurence of any character contained in the specified sub string.
void makeNull()
Makes the current string null (same as uninitialized).
friend bool operator>(const SbString &str1, const SbString &str2)
"greater than" relational operator for SbString Returns TRUE if the first operand is greater than t...
friend std::ostream & operator<<(std::ostream &os, const SbString &str)
Writes the string to the specified output stream.
SbString & setNum(int value, int base=10)
Sets the string to a formatted numeric value.
friend bool operator>=(const SbString &str1, const SbString &str2)
"greater than or equal" relational operator for SbString Returns TRUE if the first operand is great...
friend int operator!=(const SbString &str1, const SbString &str2)
Inequality operator for SbString / SbString comparison.
int toInt(SbBool *ok=NULL) const
Returns the numeric value represented by the string.
void deleteSubString(int startChar, int endChar=-1)
Deletes the characters from startChar to endChar, inclusive, from the string.
SbString & fromLatin1(const char *str)
Set the string from a Latin-1/ASCII C string.
SbString(const wchar_t *str, int start, int end)
Constructor that takes the subset of a wide char string from start to end (inclusive).
SbString(const char *str)
Constructor that takes a character string.
SbString(const wchar_t *str)
Constructor that takes a wide character string.
std::wstring toStdWString() const
Returns the string as an STL wstring.
SbString & setNum(short value, int base=10)
Sets the string to a formatted numeric value.
const char * toLatin1() const
Returns the string as a Latin-1/ASCII C string.
SbBool isEmpty() const
Returns TRUE if the string is empty.
friend const SbString operator+(const SbString &s1, const SbString &s2)
Returns a string which is the result of concatenating the string s1 and the string s2.
static const int npos
This constant is used to indicate when a find string action failed.
SoNONUNICODE SbString & vprintf(const char *cformat, va_list arg)
Write into string using vprintf() syntax.
int getLength() const
Returns length of string (zero if null or empty).
void replace(const SbString &patternStr, const SbString &substStr)
This function replaces all the occurence of patternStr by the new string substStr.
SbString(const char *str, int start, int end)
Constructor that takes the subset of a character string from start to end (inclusive).
double toDouble(SbBool *ok=NULL) const
Returns the numeric value represented by the string.
SbString & operator+=(const SbString &str)
Concatenation operator "+=" for SbString, SbString.
SoNONUNICODE int operator!() const
Unary "not" operator; returns TRUE if string is empty ("").
SbString & fromUtf16(const unsigned short *str)
Set the string from a UTF-16 string.