Jamoma API  0.6.0.a19
TTString Class Reference

The TTString class is used to represent a string. More...

#include <TTString.h>

Inherits std::vector< T >.

Public Member Functions

 TTString (const char *aCString="")
 Constructor.
 
 ~TTString ()
 Destructor.
 
const char * c_str () const
 Return a pointer to the internal C-string.
 
 operator const char * () const
 Cast to a C-string. More...
 
TTStringoperator= (const char *aCString)
 Assign from a C-string. More...
 
TTStringoperator= (std::string &aStdString)
 Assign from a std::string. More...
 
TTStringoperator= (const char aChar)
 Assign from a simple char. More...
 
void assign (const char *aCString, size_t length=0)
 Overload to assign from a C-string. More...
 
void assign (const std::string &aStdString)
 Assign from a std::string. More...
 
size_t size () const
 Find out the length of a string. More...
 
size_t length () const
 Find out the length of a string. More...
 
void resize (size_t newSize)
 Allocate memory for the string. More...
 
void append (const char *str, size_t length=0)
 Append / Concatenate.
 
size_t find_first_of (const char aChar, size_t from=0)
 Return the index of the first instance of a specified char in the string. More...
 
size_t find_last_of (const char aChar)
 Return the index of the last instance of a specified char in the string. More...
 
TTString substr (size_t pos=0, size_t n=1) const
 Returns a string object with its contents initialized to a substring of the current object. More...
 
void TTFOUNDATION_EXPORT random ()
 Replace contents with a pseudo-random string. More...
 

Detailed Description

The TTString class is used to represent a string.

We cannot safely pass std::string across lib boundaries, particularly on Windows. We also don't want to simply pass naked C-Strings for a whole host of reasons.

In many cases we try to mimic the interface of std::string for ease of compatibility.

FROM http://cboard.cprogramming.com/cplusplus-programming/86598-std-vector-char-vs-std-string.html

  1. std::string has a huge number of string-related functions which make it easy to manipulate strings.
  2. std::vector, on the other hand, is guaranteed to be contiguous in memory – that is, &data[x + 1] = &data[x] + sizeof(data[x]). std::string has NO guarantee that it is contiguous in memory. So, for example, say you're using an API call that fills a character buffer. You'd need to use the vector, not the string.

TTSymbol

Definition at line 34 of file TTString.h.

Member Function Documentation

void TTString::assign ( const char *  aCString,
size_t  length = 0 
)
inline

Overload to assign from a C-string.

Definition at line 123 of file TTString.h.

References length(), and resize().

Referenced by assign(), operator=(), and TTString().

+ Here is the call graph for this function:

void TTString::assign ( const std::string &  aStdString)
inline

Assign from a std::string.

Definition at line 137 of file TTString.h.

References assign().

+ Here is the call graph for this function:

size_t TTString::find_first_of ( const char  aChar,
size_t  from = 0 
)
inline

Return the index of the first instance of a specified char in the string.

Parameters
aCharThe char for which to search
fromA position in the string from which to begin the search. By default it starts at the beginning (0)

Definition at line 296 of file TTString.h.

References size().

Referenced by TTAddressBase::splitAt().

+ Here is the call graph for this function:

size_t TTString::find_last_of ( const char  aChar)
inline

Return the index of the last instance of a specified char in the string.

Parameters
aCharThe char for which to search

Definition at line 316 of file TTString.h.

References size().

Referenced by TTSoundfileLoader::test(), and TTSoundfile::test().

+ Here is the call graph for this function:

size_t TTString::length ( ) const
inline

Find out the length of a string.

Definition at line 151 of file TTString.h.

References size().

Referenced by append(), and assign().

+ Here is the call graph for this function:

TTString::operator const char * ( ) const
inline

Cast to a C-string.

Definition at line 90 of file TTString.h.

TTString& TTString::operator= ( const char *  aCString)
inline

Assign from a C-string.

Definition at line 98 of file TTString.h.

References assign().

+ Here is the call graph for this function:

TTString& TTString::operator= ( std::string &  aStdString)
inline

Assign from a std::string.

Definition at line 106 of file TTString.h.

References assign().

+ Here is the call graph for this function:

TTString& TTString::operator= ( const char  aChar)
inline

Assign from a simple char.

Definition at line 114 of file TTString.h.

References resize().

+ Here is the call graph for this function:

void TTString::random ( )

Replace contents with a pseudo-random string.

Definition at line 13 of file TTString.cpp.

Referenced by TTSymbol::random().

void TTString::resize ( size_t  newSize)
inline

Allocate memory for the string.

Definition at line 164 of file TTString.h.

Referenced by append(), assign(), operator=(), and substr().

TTString TTString::substr ( size_t  pos = 0,
size_t  n = 1 
) const
inline

Returns a string object with its contents initialized to a substring of the current object.

Parameters
posPosition of a character in the current string object to be used as starting character for the substring.
nLength of the substring.

Definition at line 342 of file TTString.h.

References resize(), and size().

Referenced by TTValue::fromString(), TTAddressBase::splitAt(), TTSoundfileLoader::test(), and TTSoundfile::test().

+ Here is the call graph for this function:


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