Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SbString Class Reference

Class for smart character strings. More...

#include <Inventor/SbString.h>

Public Member Functions

 SbString ()
 Default constructor.
 
 SbString (const std::string &std_string)
 Constructor that takes an STL string.
 
 SbString (const std::wstring &std_wstring)
 Constructor that takes an STL wstring.
 
 SbString (const char *str)
 Constructor that takes a character string.
 
 SbString (const char *str, int start, int end)
 Constructor that takes the subset of a character string from start to end (inclusive).
 
 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 SbString &str)
 Constructor that takes an SbString.
 
 SbString (const wchar_t *str)
 Constructor that takes a wide character string.
 
 ~SbString ()
 Destructor.
 
SbBool isEmpty () const
 Returns TRUE if the string is empty.
 
SbBool isNull () const
 Returns TRUE if the string is a null string.
 
int getLength () const
 Returns length of string (zero if null or empty).
 
void makeEmpty (const SbBool freeOld=TRUE)
 Sets string to be the empty string ("").
 
void makeNull ()
 Makes the current string null (same as uninitialized).
 
SbString getSubString (int startChar, int endChar=-1) const
 Returns a new string containing the sub-string from startChar (position) to endChar, inclusive.
 
void deleteSubString (int startChar, int endChar=-1)
 Deletes the characters from startChar to endChar, inclusive, from the string.
 
SbBool contains (const SbString &str) const
 Returns TRUE if the string contains the specified substring.
 
bool endsWith (const SbString &str) const
 Returns true if the string ends with the specified string.
 
int find (const SbString &str) const
 Returns the position of the first occurence of the specified substring.
 
int rfind (const SbString &str) const
 Returns the position of the last occurence of the specified substring.
 
int findLast (const SbString &str) const
 Returns the position of the last occurence of any character contained in the specified sub string.
 
SbBool containsAny (const SbString &str) const
 Returns TRUE if any of the characters listed in the str parameter exist in the string.
 
int findAny (const SbString &str) const
 Returns the position of the first occurence of any character contained in the specified sub string.
 
void replace (const SbString &patternStr, const SbString &substStr)
 This function replaces all the occurence of patternStr by the new string substStr.
 
SbString lower () const
 Returns a lowercase copy of the string.
 
SbString upper () const
 Returns an uppercase copy of the string.
 
SbStringsetNum (short value, int base=10)
 Sets the string to a formatted numeric value.
 
SbStringsetNum (unsigned short value, int base=10)
 Sets the string to a formatted numeric value.
 
SbStringsetNum (int value, int base=10)
 Sets the string to a formatted numeric value.
 
SbStringsetNum (unsigned int value, int base=10)
 Sets the string to a formatted numeric value.
 
SbStringsetNum (long value, int base=10)
 Sets the string to a formatted numeric value.
 
SbStringsetNum (unsigned long value, int base=10)
 Sets the string to a formatted numeric value.
 
SbStringsetNum (double value)
 Sets the string to a formatted numeric value.
 
SbStringsetNum (float value)
 Sets the string to a formatted numeric value.
 
unsigned short toUShort (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.
 
unsigned int toUInt (SbBool *ok=NULL) const
 Returns the numeric value represented by the string.
 
int toInt (SbBool *ok=NULL) const
 Returns the numeric value represented by the string.
 
unsigned long toULong (SbBool *ok=NULL) const
 Returns the numeric value represented by the string.
 
long toLong (SbBool *ok=NULL) const
 Returns the numeric value represented by the string.
 
float toFloat (SbBool *ok=NULL) const
 Returns the numeric value represented by the string.
 
double toDouble (SbBool *ok=NULL) const
 Returns the numeric value represented by the string.
 
SbBool isUnicode () const
 Returns TRUE if the string contains Unicode characters.
 
SbStringfromLatin1 (const char *str)
 Set the string from a Latin-1/ASCII C string.
 
SbStringfromUtf16 (const unsigned short *str)
 Set the string from a UTF-16 string.
 
SbStringfromWideChar (const wchar_t *str)
 Set the string from a wide char string.
 
const char * toLatin1 () const
 Returns the string as a Latin-1/ASCII C string.
 
unsigned short * toUtf16 () const
 Returns the string as a UTF-16 string.
 
const wchar_t * toWideChar () const
 Returns the string as a wide char string.
 
std::wstring toStdWString () const
 Returns the string as an STL wstring.
 
std::string toStdString () const
 Returns the string as an STL string.
 
SbStringoperator+= (const SbString &str)
 Concatenation operator "+=" for SbString, SbString.
 
SbStringoperator+= (const char *str)
 Concatenation operator "+=" for string, SbString.
 
SbStringoperator= (const SbString &str)
 Assignment operator for SbString.
 
SbStringoperator= (const char *str)
 Assignment operator for character string.
 
uint32_t hash () const
 Returns a reasonable hash key for string.
 
SoNONUNICODE SbString (const int digitString)
 Constructor that takes an integer to be turned into a string.
 
SoNONUNICODE const char * getString () const
 Returns pointer to the character string.
 
SoNONUNICODE const std::string & getSString () const
 Returns pointer to the std::string.
 
SoNONUNICODE SbStringsprintf (const char *cformat,...)
 Builds a formatted string from the format string cformat and an arbitrary list of arguments.
 
SoNONUNICODE SbStringvprintf (const char *cformat, va_list arg)
 Write into string using vprintf() syntax.
 
SoNONUNICODE char operator[] (int i) const
 Returns the character at index i, or 0 if i is beyond the length of the string.
 
SoNONUNICODE int operator! () const
 Unary "not" operator; returns TRUE if string is empty ("").
 
SoNONUNICODE const SO_WCHAR_T * wgetString () const
 Returns pointer to the character string.
 
SoNONUNICODE const std::wstring & wgetSString () const
 Returns pointer to the stl::wstring.
 
SoNONUNICODE SbStringoperator= (const SO_WCHAR_T *str)
 Assignment operator for character string, SbString.
 
SoNONUNICODE SbStringoperator+= (const SO_WCHAR_T *str)
 Concatenation operator "+=" for SbString.
 

Static Public Attributes

static const int npos
 This constant is used to indicate when a find string action failed.
 

Friends

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.
 
int operator== (const SbString &str1, const SbString &str2)
 Equality operator for SbString / SbString comparison.
 
int operator== (const SbString &str, const char *s)
 Equality operator for SbString / char* comparison.
 
int operator== (const char *s, const SbString &str)
 Equality operator for char* / SbString comparison.
 
int operator!= (const SbString &str1, const SbString &str2)
 Inequality operator for SbString / SbString comparison.
 
bool operator< (const SbString &str1, const SbString &str2)
 "less than" relational operator for SbString
Returns TRUE if the first operand is less than the second, FALSE otherwise.
 
bool operator> (const SbString &str1, const SbString &str2)
 "greater than" relational operator for SbString
Returns TRUE if the first operand is greater than the second, FALSE otherwise.
 
bool operator<= (const SbString &str1, const SbString &str2)
 "less than or equal" relational operator for SbString
Returns TRUE if the first operand is less than or equal to the second, FALSE otherwise.
 
bool operator>= (const SbString &str1, const SbString &str2)
 "greater than or equal" relational operator for SbString
Returns TRUE if the first operand is greater than or equal to the second, FALSE otherwise.
 
std::ostream & operator<< (std::ostream &os, const SbString &str)
 Writes the string to the specified output stream.
 
SoNONUNICODE friend const SbString operator+ (const SbString &s1, const char *s2)
 This is an overloaded member function, provided for convenience.
 
SoNONUNICODE friend const SbString operator+ (const char *s1, const SbString &s2)
 This is an overloaded member function, provided for convenience.
 
SoNONUNICODE friend int operator== (const SbString &str, const std::string &s)
 Equality operator for SbString / std::string comparison.
 
SoNONUNICODE friend int operator== (const std::string &s, const SbString &str)
 Equality operator for std::string / SbString comparison.
 
SoNONUNICODE friend int operator!= (const SbString &str, const char *s)
 Inequality operator for SbString / char* comparison.
 
SoNONUNICODE friend int operator!= (const char *s, const SbString &str)
 Inequality operator for char* / SbString comparison.
 
SoNONUNICODE friend bool operator< (const SbString &str, const char *s)
 "less than" relational operator for SbString / char* that returns TRUE if the first operand is less than the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator< (const char *s, const SbString &str)
 "less than" relational operator for char* / SbString that returns TRUE if the first operand is less than the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator< (const SbString &str, const std::string &s)
 "less than" relational operator for SbString / std::string that returns TRUE if the first operand is less than the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator< (const std::string &s, const SbString &str)
 "less than" relational operator for std::string / SbString that returns TRUE if the first operand is less than the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator> (const SbString &str, const char *s)
 "greater than" relational operator for SbString / char* that returns TRUE if the first operand is greater than the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator> (const char *s, const SbString &str)
 "greater than" relational operator for char* / SbString that returns TRUE if the first operand is greater than the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator> (const SbString &str, const std::string &s)
 "greater than" relational operator for SbString / std::string that returns TRUE if the first operand is greater than the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator> (const std::string &s, const SbString &str)
 "greater than" relational operator for std::string / SbString that returns TRUE if the first operand is greater than the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator<= (const SbString &str, const char *s)
 "less than or equal" relational operator for SbString / char* that returns TRUE if the first operand is less than or equal to the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator<= (const char *s, const SbString &str)
 "less than or equal" relational operator for char* / SbString that returns TRUE if the first operand is less than or equal to the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator<= (const SbString &str, const std::string &s)
 "less than or equal" relational operator for SbString / std::string that returns TRUE if the first operand is less than or equal to the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator<= (const std::string &s, const SbString &str)
 "less than or equal" relational operator for std::string / SbString that returns TRUE if the first operand is less than or equal to the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator>= (const SbString &str, const char *s)
 "greater than or equal" relational operator for SbString / char* that returns TRUE if the first operand is greater than or equal to the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator>= (const char *s, const SbString &str)
 "greater than or equal" relational operator for char* / SbString that returns TRUE if the first operand is greater than or equal to the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator>= (const SbString &str, const std::string &s)
 "greater than or equal" relational operator for SbString / std::string that returns TRUE if the first operand is greater than or equal to the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator>= (const std::string &s, const SbString &str)
 "greater than or equal" relational operator for std::string / SbString that returns TRUE if the first operand is greater than or equal to the second, FALSE otherwise.
 
SoNONUNICODE friend int operator== (const SbString &str, const SO_WCHAR_T *s)
 Equality operator for SbString / wchar_t* comparison.
 
SoNONUNICODE friend int operator== (const SO_WCHAR_T *s, const SbString &str)
 Equality operator for wchar_t* / SbString comparison.
 
SoNONUNICODE friend int operator== (const SbString &str, const std::wstring &s)
 Equality operator for SbString / std::wstring comparison.
 
SoNONUNICODE friend int operator== (const std::wstring &s, const SbString &str)
 Equality operator for std::wstring / SbString comparison.
 
SoNONUNICODE friend int operator!= (const SbString &str, const SO_WCHAR_T *s)
 Inequality operator for SbString / wchar_t* comparison.
 
SoNONUNICODE friend int operator!= (const SO_WCHAR_T *s, const SbString &str)
 Inequality operator for wchar_t* / SbString comparison.
 
SoNONUNICODE friend bool operator< (const SbString &str, const SO_WCHAR_T *s)
 "less than" relational operator for SbString / wchar_t* that returns TRUE if the first operand is less than the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator< (const SO_WCHAR_T *s, const SbString &str)
 "less than" relational operator for wchar_t* / SbString that returns TRUE if the first operand is less than the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator< (const SbString &str, const std::wstring &s)
 "less than" relational operator for SbString / std::wstring that returns TRUE if the first operand is less than the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator< (const std::wstring &s, const SbString &str)
 "less than" relational operator for std::wstring / SbString that returns TRUE if the first operand is less than the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator> (const SbString &str, const SO_WCHAR_T *s)
 "greater than" relational operator for SbString/wchar_t* that returns TRUE if the first operand is greater than the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator> (const SO_WCHAR_T *s, const SbString &str)
 "greater than" relational operator for wchar_t* / SbString that returns TRUE if the first operand is greater than the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator> (const SbString &str, const std::wstring &s)
 "greater than" relational operator for SbString / std::wstring that returns TRUE if the first operand is greater than the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator> (const std::wstring &s, const SbString &str)
 "greater than" relational operator for std::wstring / SbString that returns TRUE if the first operand is greater than the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator<= (const SbString &str, const SO_WCHAR_T *s)
 "less than or equal" relational operator for SbString / wchar_t* that returns TRUE if the first operand is less than or equal to the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator<= (const SO_WCHAR_T *s, const SbString &str)
 "less than or equal" relational operator for wchar_t* / SbString that returns TRUE if the first operand is less than or equal to the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator<= (const SbString &str, const std::wstring &s)
 "less than or equal" relational operator for SbString / std::wstring that returns TRUE if the first operand is less than or equal to the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator<= (const std::wstring &s, const SbString &str)
 "less than or equal" relational operator for std::wstring / SbString that returns TRUE if the first operand is less than or equal to the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator>= (const SbString &str, const SO_WCHAR_T *s)
 "greater than or equal" relational operator for SbString / wchar_t* that returns TRUE if the first operand is greater than or equal to the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator>= (const SO_WCHAR_T *s, const SbString &str)
 "greater than or equal" relational operator for wchar_t* / SbString that returns TRUE if the first operand is greater than or equal to the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator>= (const SbString &str, const std::wstring &s)
 "greater than or equal" relational operator for SbString / std::wstring that returns TRUE if the first operand is greater than or equal to the second, FALSE otherwise.
 
SoNONUNICODE friend bool operator>= (const std::wstring &s, const SbString &str)
 "greater than or equal" relational operator for std::wstring / SbString that returns TRUE if the first operand is greater than or equal to the second, FALSE otherwise.
 

Detailed Description

Class for smart character strings.

The class SbString provides functions to manage strings of Latin-1 (ASCII) or Unicode characters.

About Unicode:

For more information about the Unicode standard, see http://unicode.org

  • On Microsoft Windows platforms the Unicode string is stored in utf16, while on Unix/Linux based systems (including MacOSX) it uses utf32. In order to get the best performance the user should use Latin1 functions or WideChar functions.
  • On Microsoft Windows platforms there is no difference between WideChars and Utf16 because these platforms use Utf16.
  • On Unix platforms converting between utf16 and WideChars is not free and the user should try to use wide chars as much as possible.
  • Nokia's Qt toolkit uses Utf16 as internal storage, so to convert a string from or to a QString use the toUtf16 and fromUtf16 functions.
  • All access to files on the system should be done using the class SbFileHelper which supports Unicode file names.

About SO_WCHAR_T:

This macro was introduced in order to have generic code across Windows and Linux platforms. Because on Linux platforms wchar_t doesn't have the same type as on the Windows platform, it was decided to add this macro to keep a common size on both systems.

Since OpenInventor 8.0 there are separate functions and it is possible to use functions, on both systems, which use the same data size. Most of the time it's better to use utf16 functions when the size of the characters must be constant whatever is the platform.

SO_WCHAR_T is now deprecated and should not be used except for specific issues.

About locales:

In order to read values in IV files the initClass function overwrites some locales using the setlocales function provided by the standard lib C. Setting the locale after the init of OpenInventor can break reading IV files.

String manipulation:

Since OpenInventor 8.0 SbString has many new functions for string manipulation including:

  • New functions to convert strings to numbers.
  • New functions to convert numbers to strings.
  • Find functions to find sub-strings within a string.
  • SbString now supports "null" strings (note this is not the same as an empty string).
  • SbStringList::split() splits a string based on a specified separator character.

EXAMPLE

    1) Construction of a string from a regular Latin-1/Ascii C string.

    SbString s = "This is my string.";
    or
    SbString s = SbString().fromLatin1( "This is my string." );
    or
    SbString s( "This is my string." );
    Class for smart character strings.
    Definition SbString.h:202
    SbString()
    Default constructor.
    SbString & fromLatin1(const char *str)
    Set the string from a Latin-1/ASCII C string.

    2) Construction of a string from a WideChar string (wchar_t string).

    SbString s = L"This is my WideChar string";
    or
    SbString s = SbString().fromWideChar( L"This is my string." );
    or
    SbString s = SbString( myStdWString );
    SbString & fromWideChar(const wchar_t *str)
    Set the string from a wide char string.

    3) Conversion SbString <-> QString

    4) Find/Contains examples:

    SbString( "This is my string" ).contains( "Hello" ) // returns false.
    SbString( "This is my string" ).contains( "my" ) // returns true.
    SbString( "This is my string" ).containsAny( "aze" ) // returns false.
    SbString( "This is my string" ).containsAny( "Tzw" ) // returns true.
    SbString( "This is my string" ).find( "Zoo" ) // returns SbString::npos.
    SbString( "This is my string" ).find( "is" ) // returns 2.
    SbString( "This is my string" ).rfind( "Zoo" ) // returns SbString::npos.
    SbString( "This is my string" ).rfind( "is" ) // returns 5.
    SbString( "This is my string" ).findLast( "i" ) // returns 14.
    SbString( "This is my string" ).findAny( "s" ) // returns 3.

    5) Number to string

    SbString().setNum( 4, 16 ) // produces the string "0x4".
    SbString().setNum( 0.5 ) // produces the string "0.5".

    6) String to Number

    SbString( "5" ).toInt( &result ) // will return 5 and set the result boolean to true.
    SbString( "aa" ).toInt( &result ) // will return an undefined value and set the result boolean to false.

SEE ALSO

SbName, SbFileHelper, SbStringList

Definition at line 202 of file SbString.h.

Constructor & Destructor Documentation

◆ SbString() [1/9]

SbString::SbString ( )

Default constructor.

The string is initially empty.

◆ SbString() [2/9]

SbString::SbString ( const std::string &  std_string)

Constructor that takes an STL string.

◆ SbString() [3/9]

SbString::SbString ( const std::wstring &  std_wstring)

Constructor that takes an STL wstring.

◆ SbString() [4/9]

SbString::SbString ( const char *  str)

Constructor that takes a character string.

◆ SbString() [5/9]

SbString::SbString ( const char *  str,
int  start,
int  end 
)

Constructor that takes the subset of a character string from start to end (inclusive).


For example, SbString("Testing",1,3) creates the string "est".

◆ SbString() [6/9]

SbString::SbString ( const wchar_t *  str,
int  start,
int  end 
)

Constructor that takes the subset of a wide char string from start to end (inclusive).


For example, SbString("Testing",1,3) creates the string "est".

◆ SbString() [7/9]

SbString::SbString ( const SbString str)

Constructor that takes an SbString.

◆ SbString() [8/9]

SbString::SbString ( const wchar_t *  str)

Constructor that takes a wide character string.

◆ ~SbString()

SbString::~SbString ( )

Destructor.

◆ SbString() [9/9]

SoNONUNICODE SbString::SbString ( const int  digitString)

Constructor that takes an integer to be turned into a string.

For example, SbString(1234) creates the string "1234".

Non Unicode: This function should not be used in a Unicode application. Use the setNum() methods instead.

Member Function Documentation

◆ contains()

SbBool SbString::contains ( const SbString str) const

Returns TRUE if the string contains the specified substring.

◆ containsAny()

SbBool SbString::containsAny ( const SbString str) const

Returns TRUE if any of the characters listed in the str parameter exist in the string.

◆ deleteSubString()

void SbString::deleteSubString ( int  startChar,
int  endChar = -1 
)

Deletes the characters from startChar to endChar, inclusive, from the string.


If endChar is -1 (the default), all characters from startChar until the end are deleted.

◆ endsWith()

bool SbString::endsWith ( const SbString str) const

Returns true if the string ends with the specified string.

◆ find()

int SbString::find ( const SbString str) const

Returns the position of the first occurence of the specified substring.


If not found, returns npos .

◆ findAny()

int SbString::findAny ( const SbString str) const

Returns the position of the first occurence of any character contained in the specified sub string.


If not found, returns npos .

◆ findLast()

int SbString::findLast ( const SbString str) const

Returns the position of the last occurence of any character contained in the specified sub string.


If not found, returns npos .

◆ fromLatin1()

SbString & SbString::fromLatin1 ( const char *  str)

Set the string from a Latin-1/ASCII C string.

◆ fromUtf16()

SbString & SbString::fromUtf16 ( const unsigned short *  str)

Set the string from a UTF-16 string.

◆ fromWideChar()

SbString & SbString::fromWideChar ( const wchar_t *  str)

Set the string from a wide char string.

◆ getLength()

int SbString::getLength ( ) const

Returns length of string (zero if null or empty).

◆ getSString()

SoNONUNICODE const std::string & SbString::getSString ( ) const

Returns pointer to the std::string.

Non Unicode: This function should not be used in a Unicode application. Use the toSTDString() method instead.

◆ getString()

SoNONUNICODE const char * SbString::getString ( ) const

Returns pointer to the character string.

Non Unicode: This function should not be used in a Unicode application. Use the toLatin1() method instead.

◆ getSubString()

SbString SbString::getSubString ( int  startChar,
int  endChar = -1 
) const

Returns a new string containing the sub-string from startChar (position) to endChar, inclusive.


If endChar is -1 (the default), the sub-string from startChar until the end is returned.

◆ hash()

uint32_t SbString::hash ( ) const

Returns a reasonable hash key for string.

◆ isEmpty()

SbBool SbString::isEmpty ( ) const
inline

Returns TRUE if the string is empty.


i.e. if length() == 0; otherwise returns FALSE. Null strings are also empty. See makeEmpty().

Definition at line 1162 of file SbString.h.

◆ isNull()

SbBool SbString::isNull ( ) const
inline

Returns TRUE if the string is a null string.


A null string has never been initialized. See makeNull().

Definition at line 1168 of file SbString.h.

◆ isUnicode()

SbBool SbString::isUnicode ( ) const

Returns TRUE if the string contains Unicode characters.

◆ lower()

SbString SbString::lower ( ) const

Returns a lowercase copy of the string.


See also: upper()

◆ makeEmpty()

void SbString::makeEmpty ( const SbBool  freeOld = TRUE)

Sets string to be the empty string ("").


Note: freeOld is no longer used, it is kept for compatibility. Formerly if freeOld was TRUE (default), any old storage was freed up.

◆ makeNull()

void SbString::makeNull ( )

Makes the current string null (same as uninitialized).

◆ operator!()

SoNONUNICODE int SbString::operator! ( ) const

Unary "not" operator; returns TRUE if string is empty ("").

Non Unicode: This function should not be used in a Unicode application.

◆ operator+=() [1/3]

SbString & SbString::operator+= ( const char *  str)

Concatenation operator "+=" for string, SbString.

◆ operator+=() [2/3]

SbString & SbString::operator+= ( const SbString str)

Concatenation operator "+=" for SbString, SbString.

◆ operator+=() [3/3]

SoNONUNICODE SbString & SbString::operator+= ( const SO_WCHAR_T *  str)

Concatenation operator "+=" for SbString.

◆ operator=() [1/3]

SbString & SbString::operator= ( const char *  str)

Assignment operator for character string.

◆ operator=() [2/3]

SbString & SbString::operator= ( const SbString str)

Assignment operator for SbString.

◆ operator=() [3/3]

SoNONUNICODE SbString & SbString::operator= ( const SO_WCHAR_T *  str)

Assignment operator for character string, SbString.

◆ operator[]()

SoNONUNICODE char SbString::operator[] ( int  i) const

Returns the character at index i, or 0 if i is beyond the length of the string.

Non Unicode: This function should not be used in a Unicode application.

◆ replace()

void SbString::replace ( const SbString patternStr,
const SbString substStr 
)

This function replaces all the occurence of patternStr by the new string substStr.

◆ rfind()

int SbString::rfind ( const SbString str) const

Returns the position of the last occurence of the specified substring.


If not found, returns npos .

◆ setNum() [1/8]

SbString & SbString::setNum ( double  value)

Sets the string to a formatted numeric value.

◆ setNum() [2/8]

SbString & SbString::setNum ( float  value)

Sets the string to a formatted numeric value.

◆ setNum() [3/8]

SbString & SbString::setNum ( int  value,
int  base = 10 
)

Sets the string to a formatted numeric value.

base must be one of the following values or the result is an empty string:

  • 2 : Formatted using "%b" (Windows only)
  • 8 : Formatted using "%o"
  • 10 : Formatted using "%d"
  • 16 : Formatted using "0x%x"

◆ setNum() [4/8]

SbString & SbString::setNum ( long  value,
int  base = 10 
)

Sets the string to a formatted numeric value.

base must be one of the following values or the result is an empty string:

  • 2 : Formatted using "%b" (Windows only)
  • 8 : Formatted using "%o"
  • 10 : Formatted using "%d"
  • 16 : Formatted using "0x%x"

◆ setNum() [5/8]

SbString & SbString::setNum ( short  value,
int  base = 10 
)

Sets the string to a formatted numeric value.

base must be one of the following values or the result is an empty string:

  • 2 : Formatted using "%b" (Windows only)
  • 8 : Formatted using "%o"
  • 10 : Formatted using "%d"
  • 16 : Formatted using "0x%x"

◆ setNum() [6/8]

SbString & SbString::setNum ( unsigned int  value,
int  base = 10 
)

Sets the string to a formatted numeric value.

base must be one of the following values or the result is an empty string:

  • 2 : Formatted using "%b" (Windows only)
  • 8 : Formatted using "%o"
  • 10 : Formatted using "%d"
  • 16 : Formatted using "0x%x"

◆ setNum() [7/8]

SbString & SbString::setNum ( unsigned long  value,
int  base = 10 
)

Sets the string to a formatted numeric value.

base must be one of the following values or the result is an empty string:

  • 2 : Formatted using "%b" (Windows only)
  • 8 : Formatted using "%o"
  • 10 : Formatted using "%d"
  • 16 : Formatted using "0x%x"

◆ setNum() [8/8]

SbString & SbString::setNum ( unsigned short  value,
int  base = 10 
)

Sets the string to a formatted numeric value.

base must be one of the following values or the result is an empty string:

  • 2 : Formatted using "%b" (Windows only)
  • 8 : Formatted using "%o"
  • 10 : Formatted using "%d"
  • 16 : Formatted using "0x%x"

◆ sprintf()

SoNONUNICODE SbString & SbString::sprintf ( const char *  cformat,
  ... 
)

Builds a formatted string from the format string cformat and an arbitrary list of arguments.

The format string supports all the escape sequences of printf() in the standard C library.

Non Unicode: This function should not be used in a Unicode application.

◆ toDouble()

double SbString::toDouble ( SbBool ok = NULL) const

Returns the numeric value represented by the string.


Returns 0 if the conversion fails. Optional parameter ok is set to TRUE if the conversion was successful, else to FALSE.

◆ toFloat()

float SbString::toFloat ( SbBool ok = NULL) const

Returns the numeric value represented by the string.


Returns 0 if the conversion fails. Optional parameter ok is set to TRUE if the conversion was successful, else to FALSE.

◆ toInt()

int SbString::toInt ( SbBool ok = NULL) const

Returns the numeric value represented by the string.


Returns 0 if the conversion fails. Optional parameter ok is set to TRUE if the conversion was successful, else to FALSE.

◆ toLatin1()

const char * SbString::toLatin1 ( ) const

Returns the string as a Latin-1/ASCII C string.

◆ toLong()

long SbString::toLong ( SbBool ok = NULL) const

Returns the numeric value represented by the string.


Returns 0 if the conversion fails. Optional parameter ok is set to TRUE if the conversion was successful, else to FALSE.

◆ toShort()

short SbString::toShort ( SbBool ok = NULL) const

Returns the numeric value represented by the string.


Returns 0 if the conversion fails. Optional parameter ok is set to TRUE if the conversion was successful, else to FALSE.

◆ toStdString()

std::string SbString::toStdString ( ) const

Returns the string as an STL string.

◆ toStdWString()

std::wstring SbString::toStdWString ( ) const

Returns the string as an STL wstring.

◆ toUInt()

unsigned int SbString::toUInt ( SbBool ok = NULL) const

Returns the numeric value represented by the string.


Returns 0 if the conversion fails. Optional parameter ok is set to TRUE if the conversion was successful, else to FALSE.

◆ toULong()

unsigned long SbString::toULong ( SbBool ok = NULL) const

Returns the numeric value represented by the string.


Returns 0 if the conversion fails. Optional parameter ok is set to TRUE if the conversion was successful, else to FALSE.

◆ toUShort()

unsigned short SbString::toUShort ( SbBool ok = NULL) const

Returns the numeric value represented by the string.


Returns 0 if the conversion fails. Optional parameter ok is set to TRUE if the conversion was successful, else to FALSE.

◆ toUtf16()

unsigned short * SbString::toUtf16 ( ) const

Returns the string as a UTF-16 string.

◆ toWideChar()

const wchar_t * SbString::toWideChar ( ) const

Returns the string as a wide char string.

◆ upper()

SbString SbString::upper ( ) const

Returns an uppercase copy of the string.


See also: lower()

◆ vprintf()

SoNONUNICODE SbString & SbString::vprintf ( const char *  cformat,
va_list  arg 
)

Write into string using vprintf() syntax.

Non Unicode: This function should not be used in a Unicode application.

◆ wgetSString()

SoNONUNICODE const std::wstring & SbString::wgetSString ( ) const

Returns pointer to the stl::wstring.

◆ wgetString()

SoNONUNICODE const SO_WCHAR_T * SbString::wgetString ( ) const

Returns pointer to the character string.

Friends And Related Symbol Documentation

◆ operator!= [1/5]

SoNONUNICODE friend int operator!= ( const char *  s,
const SbString str 
)
friend

Inequality operator for char* / SbString comparison.


The inequality operator (!=) returns FALSE if its operands are equal, TRUE otherwise.

Non Unicode: This function should not be used in a Unicode application.

◆ operator!= [2/5]

SoNONUNICODE friend int operator!= ( const SbString str,
const char *  s 
)
friend

Inequality operator for SbString / char* comparison.


The inequality operator (!=) returns FALSE if its operands are equal, TRUE otherwise.

Non Unicode: This function should not be used in a Unicode application.

◆ operator!= [3/5]

SoNONUNICODE friend int operator!= ( const SbString str,
const SO_WCHAR_T *  s 
)
friend

Inequality operator for SbString / wchar_t* comparison.

The inequality operator (!=) returns FALSE if its operands are equal, TRUE otherwise.

◆ operator!= [4/5]

int operator!= ( const SbString str1,
const SbString str2 
)
friend

Inequality operator for SbString / SbString comparison.


The inequality operator (!=) returns FALSE if its operands are equal, TRUE otherwise.

◆ operator!= [5/5]

SoNONUNICODE friend int operator!= ( const SO_WCHAR_T *  s,
const SbString str 
)
friend

Inequality operator for wchar_t* / SbString comparison.

The inequality operator (!=) returns FALSE if its operands are equal, TRUE otherwise.

◆ operator+ [1/3]

SoNONUNICODE friend const SbString operator+ ( const char *  s1,
const SbString s2 
)
friend

This is an overloaded member function, provided for convenience.

It behaves essentially like the above function.

Non Unicode: This function should not be used in a Unicode application.

◆ operator+ [2/3]

SoNONUNICODE friend const SbString operator+ ( const SbString s1,
const char *  s2 
)
friend

This is an overloaded member function, provided for convenience.

It behaves essentially like the above function.

Non Unicode: This function should not be used in a Unicode application.

◆ operator+ [3/3]

const SbString operator+ ( const SbString s1,
const SbString s2 
)
friend

Returns a string which is the result of concatenating the string s1 and the string s2.

◆ operator< [1/9]

SoNONUNICODE friend bool operator< ( const char *  s,
const SbString str 
)
friend

"less than" relational operator for char* / SbString that returns TRUE if the first operand is less than the second, FALSE otherwise.

Non Unicode: This function should not be used in a Unicode application.

◆ operator< [2/9]

SoNONUNICODE friend bool operator< ( const SbString str,
const char *  s 
)
friend

"less than" relational operator for SbString / char* that returns TRUE if the first operand is less than the second, FALSE otherwise.

Non Unicode: This function should not be used in a Unicode application.

◆ operator< [3/9]

SoNONUNICODE friend bool operator< ( const SbString str,
const SO_WCHAR_T *  s 
)
friend

"less than" relational operator for SbString / wchar_t* that returns TRUE if the first operand is less than the second, FALSE otherwise.

◆ operator< [4/9]

SoNONUNICODE friend bool operator< ( const SbString str,
const std::string &  s 
)
friend

"less than" relational operator for SbString / std::string that returns TRUE if the first operand is less than the second, FALSE otherwise.

Non Unicode: This function should not be used in a Unicode application.

◆ operator< [5/9]

SoNONUNICODE friend bool operator< ( const SbString str,
const std::wstring &  s 
)
friend

"less than" relational operator for SbString / std::wstring that returns TRUE if the first operand is less than the second, FALSE otherwise.

◆ operator< [6/9]

bool operator< ( const SbString str1,
const SbString str2 
)
friend

"less than" relational operator for SbString
Returns TRUE if the first operand is less than the second, FALSE otherwise.

◆ operator< [7/9]

SoNONUNICODE friend bool operator< ( const SO_WCHAR_T *  s,
const SbString str 
)
friend

"less than" relational operator for wchar_t* / SbString that returns TRUE if the first operand is less than the second, FALSE otherwise.

◆ operator< [8/9]

SoNONUNICODE friend bool operator< ( const std::string &  s,
const SbString str 
)
friend

"less than" relational operator for std::string / SbString that returns TRUE if the first operand is less than the second, FALSE otherwise.

Non Unicode: This function should not be used in a Unicode application.

◆ operator< [9/9]

SoNONUNICODE friend bool operator< ( const std::wstring &  s,
const SbString str 
)
friend

"less than" relational operator for std::wstring / SbString that returns TRUE if the first operand is less than the second, FALSE otherwise.

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const SbString str 
)
friend

Writes the string to the specified output stream.

Definition at line 594 of file SbString.h.

◆ operator<= [1/9]

SoNONUNICODE friend bool operator<= ( const char *  s,
const SbString str 
)
friend

"less than or equal" relational operator for char* / SbString that returns TRUE if the first operand is less than or equal to the second, FALSE otherwise.

Non Unicode: This function should not be used in a Unicode application.

◆ operator<= [2/9]

SoNONUNICODE friend bool operator<= ( const SbString str,
const char *  s 
)
friend

"less than or equal" relational operator for SbString / char* that returns TRUE if the first operand is less than or equal to the second, FALSE otherwise.

Non Unicode: This function should not be used in a Unicode application.

◆ operator<= [3/9]

SoNONUNICODE friend bool operator<= ( const SbString str,
const SO_WCHAR_T *  s 
)
friend

"less than or equal" relational operator for SbString / wchar_t* that returns TRUE if the first operand is less than or equal to the second, FALSE otherwise.

◆ operator<= [4/9]

SoNONUNICODE friend bool operator<= ( const SbString str,
const std::string &  s 
)
friend

"less than or equal" relational operator for SbString / std::string that returns TRUE if the first operand is less than or equal to the second, FALSE otherwise.

Non Unicode: This function should not be used in a Unicode application.

◆ operator<= [5/9]

SoNONUNICODE friend bool operator<= ( const SbString str,
const std::wstring &  s 
)
friend

"less than or equal" relational operator for SbString / std::wstring that returns TRUE if the first operand is less than or equal to the second, FALSE otherwise.

◆ operator<= [6/9]

bool operator<= ( const SbString str1,
const SbString str2 
)
friend

"less than or equal" relational operator for SbString
Returns TRUE if the first operand is less than or equal to the second, FALSE otherwise.

◆ operator<= [7/9]

SoNONUNICODE friend bool operator<= ( const SO_WCHAR_T *  s,
const SbString str 
)
friend

"less than or equal" relational operator for wchar_t* / SbString that returns TRUE if the first operand is less than or equal to the second, FALSE otherwise.

◆ operator<= [8/9]

SoNONUNICODE friend bool operator<= ( const std::string &  s,
const SbString str 
)
friend

"less than or equal" relational operator for std::string / SbString that returns TRUE if the first operand is less than or equal to the second, FALSE otherwise.

Non Unicode: This function should not be used in a Unicode application.

◆ operator<= [9/9]

SoNONUNICODE friend bool operator<= ( const std::wstring &  s,
const SbString str 
)
friend

"less than or equal" relational operator for std::wstring / SbString that returns TRUE if the first operand is less than or equal to the second, FALSE otherwise.

◆ operator== [1/9]

int operator== ( const char *  s,
const SbString str 
)
friend

Equality operator for char* / SbString comparison.


The equality operator (==) returns TRUE if the values of its operands are equal, FALSE otherwise.

◆ operator== [2/9]

int operator== ( const SbString str,
const char *  s 
)
friend

Equality operator for SbString / char* comparison.


The equality operator (==) returns TRUE if the values of its operands are equal, FALSE otherwise.

◆ operator== [3/9]

SoNONUNICODE friend int operator== ( const SbString str,
const SO_WCHAR_T *  s 
)
friend

Equality operator for SbString / wchar_t* comparison.

The equality operator (==) returns TRUE if the values of its operands are equal, FALSE otherwise.

◆ operator== [4/9]

SoNONUNICODE friend int operator== ( const SbString str,
const std::string &  s 
)
friend

Equality operator for SbString / std::string comparison.


The equality operator (==) returns TRUE if the values of its operands are equal, FALSE otherwise.

Non Unicode: This function should not be used in a Unicode application.

◆ operator== [5/9]

SoNONUNICODE friend int operator== ( const SbString str,
const std::wstring &  s 
)
friend

Equality operator for SbString / std::wstring comparison.

The equality operator (==) returns TRUE if the values of its operands are equal, FALSE otherwise.

◆ operator== [6/9]

int operator== ( const SbString str1,
const SbString str2 
)
friend

Equality operator for SbString / SbString comparison.


The equality operator (==) returns TRUE if the values of its operands are equal, FALSE otherwise.

◆ operator== [7/9]

SoNONUNICODE friend int operator== ( const SO_WCHAR_T *  s,
const SbString str 
)
friend

Equality operator for wchar_t* / SbString comparison.

The equality operator (==) returns TRUE if the values of its operands are equal, FALSE otherwise.

◆ operator== [8/9]

SoNONUNICODE friend int operator== ( const std::string &  s,
const SbString str 
)
friend

Equality operator for std::string / SbString comparison.


The equality operator (==) returns TRUE if the values of its operands are equal, FALSE otherwise.

Non Unicode: This function should not be used in a Unicode application.

◆ operator== [9/9]

SoNONUNICODE friend int operator== ( const std::wstring &  s,
const SbString str 
)
friend

Equality operator for std::wstring / SbString comparison.

The equality operator (==) returns TRUE if the values of its operands are equal, FALSE otherwise.

◆ operator> [1/9]

SoNONUNICODE friend bool operator> ( const char *  s,
const SbString str 
)
friend

"greater than" relational operator for char* / SbString that returns TRUE if the first operand is greater than the second, FALSE otherwise.

Non Unicode: This function should not be used in a Unicode application.

◆ operator> [2/9]

SoNONUNICODE friend bool operator> ( const SbString str,
const char *  s 
)
friend

"greater than" relational operator for SbString / char* that returns TRUE if the first operand is greater than the second, FALSE otherwise.

Non Unicode: This function should not be used in a Unicode application.

◆ operator> [3/9]

SoNONUNICODE friend bool operator> ( const SbString str,
const SO_WCHAR_T *  s 
)
friend

"greater than" relational operator for SbString/wchar_t* that returns TRUE if the first operand is greater than the second, FALSE otherwise.

◆ operator> [4/9]

SoNONUNICODE friend bool operator> ( const SbString str,
const std::string &  s 
)
friend

"greater than" relational operator for SbString / std::string that returns TRUE if the first operand is greater than the second, FALSE otherwise.

Non Unicode: This function should not be used in a Unicode application.

◆ operator> [5/9]

SoNONUNICODE friend bool operator> ( const SbString str,
const std::wstring &  s 
)
friend

"greater than" relational operator for SbString / std::wstring that returns TRUE if the first operand is greater than the second, FALSE otherwise.

◆ operator> [6/9]

bool operator> ( const SbString str1,
const SbString str2 
)
friend

"greater than" relational operator for SbString
Returns TRUE if the first operand is greater than the second, FALSE otherwise.

◆ operator> [7/9]

SoNONUNICODE friend bool operator> ( const SO_WCHAR_T *  s,
const SbString str 
)
friend

"greater than" relational operator for wchar_t* / SbString that returns TRUE if the first operand is greater than the second, FALSE otherwise.

◆ operator> [8/9]

SoNONUNICODE friend bool operator> ( const std::string &  s,
const SbString str 
)
friend

"greater than" relational operator for std::string / SbString that returns TRUE if the first operand is greater than the second, FALSE otherwise.

Non Unicode: This function should not be used in a Unicode application.

◆ operator> [9/9]

SoNONUNICODE friend bool operator> ( const std::wstring &  s,
const SbString str 
)
friend

"greater than" relational operator for std::wstring / SbString that returns TRUE if the first operand is greater than the second, FALSE otherwise.

◆ operator>= [1/9]

SoNONUNICODE friend bool operator>= ( const char *  s,
const SbString str 
)
friend

"greater than or equal" relational operator for char* / SbString that returns TRUE if the first operand is greater than or equal to the second, FALSE otherwise.

Non Unicode: This function should not be used in a Unicode application.

◆ operator>= [2/9]

SoNONUNICODE friend bool operator>= ( const SbString str,
const char *  s 
)
friend

"greater than or equal" relational operator for SbString / char* that returns TRUE if the first operand is greater than or equal to the second, FALSE otherwise.

Non Unicode: This function should not be used in a Unicode application.

◆ operator>= [3/9]

SoNONUNICODE friend bool operator>= ( const SbString str,
const SO_WCHAR_T *  s 
)
friend

"greater than or equal" relational operator for SbString / wchar_t* that returns TRUE if the first operand is greater than or equal to the second, FALSE otherwise.

◆ operator>= [4/9]

SoNONUNICODE friend bool operator>= ( const SbString str,
const std::string &  s 
)
friend

"greater than or equal" relational operator for SbString / std::string that returns TRUE if the first operand is greater than or equal to the second, FALSE otherwise.

Non Unicode: This function should not be used in a Unicode application.

◆ operator>= [5/9]

SoNONUNICODE friend bool operator>= ( const SbString str,
const std::wstring &  s 
)
friend

"greater than or equal" relational operator for SbString / std::wstring that returns TRUE if the first operand is greater than or equal to the second, FALSE otherwise.

◆ operator>= [6/9]

bool operator>= ( const SbString str1,
const SbString str2 
)
friend

"greater than or equal" relational operator for SbString
Returns TRUE if the first operand is greater than or equal to the second, FALSE otherwise.

◆ operator>= [7/9]

SoNONUNICODE friend bool operator>= ( const SO_WCHAR_T *  s,
const SbString str 
)
friend

"greater than or equal" relational operator for wchar_t* / SbString that returns TRUE if the first operand is greater than or equal to the second, FALSE otherwise.

◆ operator>= [8/9]

SoNONUNICODE friend bool operator>= ( const std::string &  s,
const SbString str 
)
friend

"greater than or equal" relational operator for std::string / SbString that returns TRUE if the first operand is greater than or equal to the second, FALSE otherwise.

Non Unicode: This function should not be used in a Unicode application.

◆ operator>= [9/9]

SoNONUNICODE friend bool operator>= ( const std::wstring &  s,
const SbString str 
)
friend

"greater than or equal" relational operator for std::wstring / SbString that returns TRUE if the first operand is greater than or equal to the second, FALSE otherwise.

Member Data Documentation

◆ npos

const int SbString::npos
static

This constant is used to indicate when a find string action failed.

It defines a non-existing position.

Definition at line 259 of file SbString.h.


The documentation for this class was generated from the following file: