Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

SbString Class Reference

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

#include <Inventor/SbString.h>

List of all members.

Public Methods

 SbString (void)
 SbString (const char *str)
 SbString (const char *str, int start, int end)
 SbString (const SbString &str)
 SbString (const int digits)
 ~SbString ()
uint32_t hash (void)
int getLength (void) const
void makeEmpty (SbBool freeold=TRUE)
const char * getString (void) const
SbString getSubString (int startidx, int endidx=-1) const
void deleteSubString (int startidx, int endidx=-1)
void addIntString (const int value)
char operator[] (int index) const
SbString & operator= (const char *str)
SbString & operator= (const SbString &str)
SbString & operator+= (const char *str)
SbString & operator+= (const SbString &str)
int operator! (void) const
SbString & operator+= (const char c)
SbString & sprintf (const char *formatstr,...)
SbString & vsprintf (const char *formatstr, va_list args)
void print (FILE *file=stdout) const

Static Public Methods

uint32_t hash (const char *s)

Friends

COIN_DLL_API int operator== (const SbString &str, const char *s)
COIN_DLL_API int operator== (const char *s, const SbString &str)
COIN_DLL_API int operator== (const SbString &str1, const SbString &str2)
COIN_DLL_API int operator!= (const SbString &str, const char *s)
COIN_DLL_API int operator!= (const char *s, const SbString &str)
COIN_DLL_API int operator!= (const SbString &str1, const SbString &str2)


Detailed Description

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

Internally for the Coin library, 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::SbString void
 

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

SbString::SbString const char * str
 

This constructor assigns from the given string.

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

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::SbString const SbString & str
 

This is the copy constructor.

SbString::SbString const int digits
 

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

SbString::~SbString
 

The destructor.


Member Function Documentation

uint32_t SbString::hash void
 

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

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

int SbString::getLength void const
 

This method returns the length of the string.

void SbString::makeEmpty SbBool freeold = TRUE
 

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.

const char * SbString::getString void const
 

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

SbString SbString::getSubString int startidx,
int endidx = -1
const
 

This method returns a new string which contains a substring defined by the given indices startidx and endChar (inclusive). If endChar is -1, the substring from startidx to the end of the string is used.

This will return a string which is (endChar - 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/".

void SbString::deleteSubString int startidx,
int endidx = -1
 

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.

void SbString::addIntString const int value
 

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

char SbString::operator[] int index const
 

Returns character at position index in the string.

See also:
getSubString()

SbString & SbString::operator= const char * str
 

This is the assignment operator.

SbString & SbString::operator= const SbString & str
 

Assign from the given string.

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

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

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

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

int SbString::operator! void const
 

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

uint32_t SbString::hash const char * s [static]
 

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

SbString & SbString::operator+= const char c
 

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

Note:
This member function is not compatible with OpenInventor.

SbString & SbString::sprintf const char * formatstr,
...
 

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.

SbString & SbString::vsprintf const char * formatstr,
va_list args
 

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.

void SbString::print FILE * file = stdout const
 

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


Friends And Related Function Documentation

COIN_DLL_API int operator== const SbString & str,
const char * s
[friend]
 

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

COIN_DLL_API int operator== const char * s,
const SbString & str
[friend]
 

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

COIN_DLL_API int operator== const SbString & str1,
const SbString & str2
[friend]
 

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

COIN_DLL_API int operator!= const SbString & str,
const char * s
[friend]
 

Inequality operator.

COIN_DLL_API int operator!= const char * s,
const SbString & str
[friend]
 

Inequality operator.

COIN_DLL_API int operator!= const SbString & str1,
const SbString & str2
[friend]
 

Inequality operator.


The documentation for this class was generated from the following files:
Generated at Tue Mar 5 03:31:31 2002 for Coin by doxygen1.2.9 written by Dimitri van Heesch, © 1997-2001