Coin  4.0.3
Coin3D core library
Loading...
Searching...
No Matches
SbString Class Reference

The SbString class is a string class with convenience functions for string operations. More...

#include <Inventor/SbString.h>

Public Member Functions

 SbString (const char *s)
 
 SbString (const char *s, int start, int end)
 
 SbString (const int digits)
 
 SbString (const SbString &s)
 
 SbString (const wchar_t *s)
 
 SbString (void)
 
 ~SbString ()
 
void addIntString (const int value)
 
void apply (char(*func)(char input))
 
int compareSubString (const char *text, int offset=0) const
 
void deleteSubString (int startidx, int endidx=-1)
 
int find (const SbString &s) const
 
SbBool findAll (const SbString &s, SbIntList &found) const
 
int getLength (void) const
 
const char * getString (void) const
 
SbString getSubString (int startidx, int endidx=-1) const
 
uint32_t hash (void) const
 
SbString lower () const
 
void makeEmpty (SbBool freeold=TRUE)
 
int operator! (void) const
 
SbStringoperator+= (const char *s)
 
SbStringoperator+= (const char c)
 
SbStringoperator+= (const SbString &s)
 
SbStringoperator= (const char *s)
 
SbStringoperator= (const SbString &s)
 
char operator[] (int index) const
 
void print (std::FILE *fp) const
 
SbStringsprintf (const char *formatstr,...)
 
SbString upper () const
 
SbStringvsprintf (const char *formatstr, va_list args)
 

Static Public Member Functions

static uint32_t hash (const char *s)
 

Related Symbols

(Note that these are not member symbols.)

int operator!= (const char *s, const SbString &str)
 
int operator!= (const SbString &str, const char *s)
 
int operator!= (const SbString &str1, const SbString &str2)
 
const SbString operator+ (const char *s, const SbString &sbstr)
 
const SbString operator+ (const SbString &sbstr, const char *s)
 
const SbString operator+ (const SbString &str1, const SbString &str2)
 
int operator< (const char *s, const SbString &str)
 
int operator< (const SbString &str, const char *s)
 
int operator< (const SbString &str1, const SbString &str2)
 
int operator== (const char *s, const SbString &str)
 
int operator== (const SbString &str, const char *s)
 
int operator== (const SbString &str1, const SbString &str2)
 
int operator> (const char *s, const SbString &str)
 
int operator> (const SbString &str, const char *s)
 
int operator> (const SbString &str1, const SbString &str2)
 

Detailed Description

The SbString class is a string class with convenience functions for string operations.

This is the class used for storing and working with character strings. It automatically takes care of supporting all the "bookkeeping" tasks usually associated with working with character strings, like memory allocation and deallocation etc.

This class should also be well suited for use by the application programmer throughout the application using the Coin library.

See also
SbName

Constructor & Destructor Documentation

◆ SbString() [1/6]

SbString::SbString ( void )
inline

This is the default constructor. It initializes the string to be empty.

◆ SbString() [2/6]

SbString::SbString ( const char * str)
inline

This constructor assigns from the given string.

◆ SbString() [3/6]

SbString::SbString ( const wchar_t * str)
inline

This constructor converts the given string to UTF-8 and assigns it.

◆ SbString() [4/6]

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

This constructor constructs a string from the given substring from start to end indices inclusive. If end is -1, the substring from start until the end of the string is used.

◆ SbString() [5/6]

SbString::SbString ( const SbString & str)
inline

This is the copy constructor.

◆ SbString() [6/6]

SbString::SbString ( const int digits)
inline

Construct an SbString instance containing the digits of the integer argument.

◆ ~SbString()

SbString::~SbString ( )
inline

The destructor. Deallocates any internal resources used during the lifetime of the SbString instance.

Member Function Documentation

◆ addIntString()

void SbString::addIntString ( const int value)
inline

Constructs a string from the given integer (e.g. intToString(42) creates the string "42"), and adds this to the contents of the string.

◆ apply()

void SbString::apply ( char(*)(char input) func)
inline

Apply the conversion function func to every character of the current string. func is a pointer to a function that takes a character as input and returns a (probably converted) character.

Note that this function is not part of the original Open Inventor API.

◆ compareSubString()

int SbString::compareSubString ( const char * text,
int offset = 0 ) const
inline

Uses text as a substring to be compared to the string, starting at offset offset. Return value is 0 upon success, and the failing character comparison difference upon failure.

◆ deleteSubString()

void SbString::deleteSubString ( int startidx,
int endidx = -1 )
inline

This method deletes the substring defined by startidx and endidx (inclusive). If endidx is -1, the substring from startidx to the end of the string is deleted.

◆ find()

int SbString::find ( const SbString & strarg) const

If s is found, the method returns the first index where s starts. Otherwise it returns -1.

Note: SbString::find() is a Coin specific extension to the original Open Inventor API.

See also
SbString::findAll()
Since
Coin 2.0

◆ findAll()

SbBool SbString::findAll ( const SbString & strarg,
SbIntList & found ) const

All occurrences of str is represented in found as indices to the characters where str starts. If 1 or more is found, TRUE is returned, else FALSE is returned.

Note: SbString::findAll() is an extension to the original Open Inventor API.

See also
SbString::find()
Since
Coin 2.0

◆ getLength()

int SbString::getLength ( void ) const
inline

This method returns the length of the string.

◆ getString()

const char * SbString::getString ( void ) const
inline

This method returns the pointer to the string (character array).

◆ getSubString()

SbString SbString::getSubString ( int startidx,
int endidx = -1 ) const
inline

This method returns a new string which contains a substring defined by the given indices startidx and endidx (inclusive).

If endidx is -1, the substring from startidx to the end of the string is used.

This will return a string which is (endidx - startidx + 1) characters long, i.e. if this string is "foo/bar" and we call by SbString::getSubString(0, 3), the returned string will be "foo/".

◆ hash() [1/2]

uint32_t SbString::hash ( const char * s)
inlinestatic

This static method returns a hash value for the given string.

◆ hash() [2/2]

uint32_t SbString::hash ( void ) const
inline

This method returns a reasonable hash value for the current string.

See also
uint32_t SbString::hash(const char * s)

◆ lower()

SbString SbString::lower ( ) const

Converts all of the characters to lowercase using tolower().

Since
Coin 3.1

◆ makeEmpty()

void SbString::makeEmpty ( SbBool freeold = TRUE)
inline

This method clears the string, making it an empty string (""). If freeold is TRUE (which is the default), the memory used by the old string is freed. Otherwise, memory will be kept and reused when the string is manipulated later.

◆ operator!()

int SbString::operator! ( void ) const
inline

This unary operator results in TRUE if the current string is empty ("") or FALSE otherwise.

◆ operator+=() [1/3]

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

Concatenate the given string to the end of the current one.

◆ operator+=() [2/3]

SbString & SbString::operator+= ( const char c)
inline

Concatenate the given character to the end of the current string.

Note
This member function is not compatible with OpenInventor.

◆ operator+=() [3/3]

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

Concatenate the given string to the end of the current one.

◆ operator=() [1/2]

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

This is the assignment operator.

◆ operator=() [2/2]

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

Assign from the given string.

◆ operator[]()

char SbString::operator[] ( int index) const
inline

Returns character at position index in the string.

See also
getSubString()

◆ print()

void SbString::print ( std::FILE * fp) const

Dump the state of this object to the fp file stream. Only works in debug version of library, method does nothing in an optimized build.

◆ sprintf()

SbString & SbString::sprintf ( const char * formatstr,
... )
inline

Set SbString instance to the formatted string formatstr, replacing the current contents. The control characters within formatstr and the remaining arguments should follow the conventions of the printf() call.

Note that this function is not part of the original Open Inventor API.

◆ upper()

SbString SbString::upper ( ) const

Converts all of the characters to uppercase using toupper().

Since
Coin 3.1

◆ vsprintf()

SbString & SbString::vsprintf ( const char * formatstr,
va_list args )
inline

Set SbString instance to the formatted string formatstr, replacing the current contents. The control characters within formatstr and the arguments of the args argument list should follow the conventions of the printf() call.

Note that this function is not part of the original Open Inventor API.

Friends And Related Symbol Documentation

◆ operator!=() [1/3]

int operator!= ( const char * s,
const SbString & str )
related

Inequality operator.

◆ operator!=() [2/3]

int operator!= ( const SbString & str,
const char * s )
related

Inequality operator.

◆ operator!=() [3/3]

int operator!= ( const SbString & str1,
const SbString & str2 )
related

Inequality operator.

◆ operator+() [1/3]

const SbString operator+ ( const char * s,
const SbString & sbstr )
related

Addition operator.

◆ operator+() [2/3]

const SbString operator+ ( const SbString & sbstr,
const char * s )
related

Addition operator.

◆ operator+() [3/3]

const SbString operator+ ( const SbString & str1,
const SbString & str2 )
related

Addition operator.

◆ operator<() [1/3]

int operator< ( const char * s,
const SbString & str )
related

Less than operator. Results in TRUE if the first character that does not match has a lower value in s than in str.

◆ operator<() [2/3]

int operator< ( const SbString & str,
const char * s )
related

Less than operator. Results in TRUE if the first character that does not match has a lower value in str than in s.

◆ operator<() [3/3]

int operator< ( const SbString & str1,
const SbString & str2 )
related

Less than operator. Results in TRUE if the first character that does not match has a lower value in str1 than in str2.

◆ operator==() [1/3]

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

Equality operator. Check if the strings have the same contents.

◆ operator==() [2/3]

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

Equality operator. Check if the strings have the same contents.

◆ operator==() [3/3]

int operator== ( const SbString & str1,
const SbString & str2 )
related

Equality operator. Check if the strings have the same contents.

◆ operator>() [1/3]

int operator> ( const char * s,
const SbString & str )
related

Greater than operator. Results in TRUE if the first character that does not match has a higher value in s than in str.

◆ operator>() [2/3]

int operator> ( const SbString & str,
const char * s )
related

Greater than operator. Results in TRUE if the first character that does not match has a higher value in str than in s.

◆ operator>() [3/3]

int operator> ( const SbString & str1,
const SbString & str2 )
related

Greater than operator. Results in TRUE if the first character that does not match has a higher value in str1 than in str2.


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