Public Types | Public Member Functions | Static Public Attributes | Friends | List of all members
zorba::String Class Reference

The Zorba string class. More...

#include <zorba/zorba_string.h>

Public Types

typedef std::allocator
< value_type
allocator_type
 
typedef const_pointer const_iterator
 
typedef value_type const * const_pointer
 
typedef value_type const & const_reference
 
typedef std::reverse_iterator
< const_iterator
const_reverse_iterator
 
typedef
allocator_type::difference_type 
difference_type
 
typedef pointer iterator
 
typedef value_typepointer
 
typedef value_typereference
 
typedef std::reverse_iterator
< iterator
reverse_iterator
 
typedef allocator_type::size_type size_type
 
typedef std::char_traits
< value_type
traits_type
 
typedef char value_type
 

Public Member Functions

Stringappend (String const &s)
 Appends the given string to this string. More...
 
Stringappend (String const &s, size_type s_pos, size_type s_n)
 Appends a substring of the given string to this string. More...
 
Stringappend (std::string const &s)
 Appends the given string to this string. More...
 
Stringappend (std::string const &s, size_type s_pos, size_type s_n)
 Appends a substring of the given string to this string. More...
 
Stringappend (const_pointer s)
 Appends the given C string to this string. More...
 
Stringappend (const_pointer s, size_type s_n)
 Appends the given C string to this string. More...
 
Stringappend (size_type n, value_type c)
 Appends n copies of c to this string. More...
 
Stringassign (String const &s)
 Assigns another string to this string. More...
 
Stringassign (std::string const &s)
 Assigns a std::string to this string. More...
 
Stringassign (String const &s, size_type pos, size_type n)
 Assigns a substring of a string to this string. More...
 
Stringassign (std::string const &s, size_type pos, size_type n)
 Assigns a substring of a std::string to this string. More...
 
Stringassign (const_pointer s)
 Assigns a C to this string. More...
 
Stringassign (const_pointer s, size_type n)
 Assigns a substring of a C to this string. More...
 
Stringassign (size_type n, value_type c)
 Assigned n copies of a character to this string. More...
 
Stringassign (const_iterator i, const_iterator j)
 Assigns characters from a range of characters [i,j). More...
 
reference at (size_type pos)
 References a particular character within the string. More...
 
value_type at (size_type pos) const
 References a particular character within the string. More...
 
iterator begin ()
 Returns a read/write iterator positioned at the first character of the string. More...
 
const_iterator begin () const
 Returns a read-only iterator positioned at the first character of the string. More...
 
const_pointer c_str () const
 Gets a pointer to a null-terminated array of characters representing the string's contents. More...
 
size_type capacity () const
 Gets the capacity of this string. More...
 
void clear ()
 Erases the string making it empty. More...
 
int compare (String const &s) const
 Compares this string against another. More...
 
int compare (std::string const &s) const
 Compares this string against another. More...
 
int compare (const_pointer s) const
 Compares this string against a C string. More...
 
int compare (size_type pos, size_type n, String const &s) const
 Compares a substring of this string against another. More...
 
int compare (size_type pos, size_type n, std::string const &s) const
 Compares a substring of this string against another. More...
 
int compare (size_type pos, size_type n, const_pointer s) const
 Compares a substring of this string against a C string. More...
 
int compare (size_type pos, size_type n, String const &s, size_type s_pos, size_type s_n) const
 Compares a substring of this string against a substring of another. More...
 
int compare (size_type pos, size_type n, std::string const &s, size_type s_pos, size_type s_n) const
 Compares a substring of this string against a substring of another. More...
 
int compare (size_type pos, size_type n, const_pointer s, size_type s_n) const
 Compares a substring of this string against a C string. More...
 
size_type copy (pointer buf, size_type n, size_type pos=0) const
 Copies a substring to a C string buffer. More...
 
const_pointer data () const
 Gets a pointer to the raw character data comprising the string, not necessarily null-terminated. More...
 
bool empty () const
 Checks whether the string is empty. More...
 
iterator end ()
 Returns a read/write iterator positioned at one past the last character of the string. More...
 
const_iterator end () const
 Returns a read-only iterator positioned at one past the last character of the string. More...
 
Stringerase (size_type pos=0, size_type n=npos)
 Erases the given number of characters starting at the given position. More...
 
iterator erase (iterator i)
 Erases the character at the given iterator's position. More...
 
iterator erase (iterator i, iterator j)
 Erases a range of characters [i,j). More...
 
size_type find (String const &s, size_type pos=0) const
 Searches this string for the given string starting at the given position. More...
 
size_type find (std::string const &s, size_type pos=0) const
 Searches this string for the given string starting at the given position. More...
 
size_type find (const_pointer s, size_type pos=0) const
 Searches this string for the given string starting at the given position. More...
 
size_type find (const_pointer s, size_type pos, size_type s_n) const
 Searches this string for the given string starting at the given position. More...
 
size_type find (value_type c, size_type pos=0) const
 Searches this string for the given character staring at the given position. More...
 
size_type find_first_not_of (String const &s, size_type pos=0) const
 Searches this string for any one of the characters not in s starting at the given position. More...
 
size_type find_first_not_of (std::string const &s, size_type pos=0) const
 Searches this string for any one of the characters not in s starting at the given position. More...
 
size_type find_first_not_of (const_pointer s, size_type pos=0) const
 Searches this string for any one of the characters not in s starting at the given position. More...
 
size_type find_first_not_of (const_pointer s, size_type pos, size_type s_n) const
 Searches this string for any one of the first s_n characters not in s starting at the given position. More...
 
size_type find_first_not_of (value_type c, size_type pos=0) const
 Searches this string for any character except the given character starting at the given position. More...
 
size_type find_first_of (String const &s, size_type pos=0) const
 Searches this string for any one of the characters in s starting at the given position. More...
 
size_type find_first_of (std::string const &s, size_type pos=0) const
 Searches this string for any one of the characters in s starting at the given position. More...
 
size_type find_first_of (const_pointer s, size_type pos=0) const
 Searches this string for any one of the characters in s starting at the given position. More...
 
size_type find_first_of (const_pointer s, size_type pos, size_type s_n) const
 Searches this string for any one of the first s_n characters in s starting at the given position. More...
 
size_type find_first_of (value_type c, size_type pos=0) const
 Searches this string for the given character starting at the given position. More...
 
size_type find_last_not_of (String const &s, size_type pos=npos) const
 Searches this string backwards for any one of the characters not in s starting at the given position. More...
 
size_type find_last_not_of (std::string const &s, size_type pos=npos) const
 Searches this string backwards for any one of the characters not in s starting at the given position. More...
 
size_type find_last_not_of (const_pointer s, size_type pos=npos) const
 Searches this string backwards for any one of the characters not in s starting at the given position. More...
 
size_type find_last_not_of (const_pointer s, size_type pos, size_type s_n) const
 Searches this string backwards for any one of the first s_n characters not in s starting at the given position. More...
 
size_type find_last_not_of (value_type c, size_type pos=npos) const
 Searches this string backwards for any character except the given character starting at the given position. More...
 
size_type find_last_of (String const &s, size_type pos=npos) const
 Searches this string backwards for any one of the characters in s starting at the given position. More...
 
size_type find_last_of (std::string const &s, size_type pos=npos) const
 Searches this string backwards for any one of the characters in s starting at the given position. More...
 
size_type find_last_of (const_pointer s, size_type pos=npos) const
 Searches this string backwards for any one of the characters in s starting at the given position. More...
 
size_type find_last_of (const_pointer s, size_type pos, size_type s_n) const
 Searches this string backwards for any one of the first s_n characters in s starting at the given position. More...
 
size_type find_last_of (value_type c, size_type pos=npos) const
 Searches this string backwards for the given character starting at the given position. More...
 
Stringinsert (size_type pos, String const &s)
 Inserts the given string into this string at the given position. More...
 
Stringinsert (size_type pos, std::string const &s)
 Inserts the given string into this string at the given position. More...
 
Stringinsert (size_type pos, const_pointer s)
 Inserts the given string into this string at the given position. More...
 
Stringinsert (size_type pos, String const &s, size_type s_pos, size_type s_n)
 Inserts a substring of the given string into this string at the given position. More...
 
Stringinsert (size_type pos, std::string const &s, size_type s_pos, size_type s_n)
 Inserts a substring of the given string into this string at the given position. More...
 
Stringinsert (size_type pos, const_pointer s, size_type s_n)
 Inserts a substring of the given string into this string at the given position. More...
 
Stringinsert (size_type pos, size_type n, value_type c)
 Inserts n copies of c into this string at the given position. More...
 
iterator insert (iterator pos, value_type c)
 Inserts the given character into this string at the given position. More...
 
void insert (iterator pos, size_type n, value_type c)
 Inserts n copies of c into this string at the given position. More...
 
size_type length () const
 Gets the number of characters in this string. More...
 
Stringoperator+= (String const &s)
 Appends the given string to this string. More...
 
Stringoperator+= (std::string const &s)
 Appends the given std::string to this string. More...
 
Stringoperator+= (const_pointer s)
 Appends the given C string to this string. More...
 
Stringoperator+= (value_type c)
 Appends the given character to this string. More...
 
Stringoperator= (String const &s)
 Assigns another string to this string. More...
 
Stringoperator= (std::string const &s)
 Assigns a std::string to this string. More...
 
Stringoperator= (const_pointer s)
 Assigns a C string to this string. More...
 
Stringoperator= (value_type c)
 Assigns a character to this string. More...
 
const_reference operator[] (size_type pos) const
 References a particular character within the string. More...
 
void push_back (value_type c)
 Appends the given character to this string. More...
 
reverse_iterator rbegin ()
 Returns a read/write reverse iterator positioned at the first character of the reversed string. More...
 
const_reverse_iterator rbegin () const
 Returns a read-only reverse iterator positioned at the first character of the reversed string. More...
 
reverse_iterator rend ()
 Returns a read/write reverse iterator positioned at one past the last character of the reversed string. More...
 
const_reverse_iterator rend () const
 Returns a read-only reverse iterator positioned at one past the last character of the reversed string. More...
 
Stringreplace (size_type pos, size_type n, String const &s)
 Replaces n characters of this string starting at the given position with the given string. More...
 
Stringreplace (size_type pos, size_type n, std::string const &s)
 Replaces n characters of this string starting at the given position with the given string. More...
 
Stringreplace (size_type pos, size_type n, const_pointer s)
 Replaces n characters of this string starting at the given position with the given string. More...
 
Stringreplace (size_type pos, size_type n, String const &s, size_type s_pos, size_type s_n)
 Replaces n characters of this string starting at the given position with a substring of the given string. More...
 
Stringreplace (size_type pos, size_type n, std::string const &s, size_type s_pos, size_type s_n)
 Replaces n characters of this string starting at the given position with a substring of the given string. More...
 
Stringreplace (size_type pos, size_type n, const_pointer s, size_type s_n)
 Replaces n characters of this string starting at the given position with a substring of the given string. More...
 
Stringreplace (size_type pos, size_type n, size_type c_n, value_type c)
 Replaces n characters of this string starting at the given position with c_n copies of c. More...
 
Stringreplace (iterator i, iterator j, String const &s)
 Replaces the range of characters [i,j) of this string with the given string. More...
 
Stringreplace (iterator i, iterator j, std::string const &s)
 Replaces the range of characters [i,j) of this string with the given string. More...
 
Stringreplace (iterator i, iterator j, const_pointer s)
 Replaces the range of characters [i,j) of this string with the given string. More...
 
Stringreplace (iterator i, iterator j, const_pointer s, size_type s_n)
 Replaces the range of characters [i,j) of this string with a substring of the given string. More...
 
Stringreplace (iterator i, iterator j, size_type n, value_type c)
 Replaces the range of characters [i,j) of this string with c_n copies of c. More...
 
Stringreplace (iterator i, iterator j, iterator si, iterator sj)
 Replaces the range of characters [i,j) of this string with the range of characters [si,sj). More...
 
void reserve (size_type n)
 Attemts to pre-allocated enough memory to contain the given number of bytes. More...
 
void resize (size_type n, value_type c=value_type())
 Resizes the string to the given number of characters. More...
 
size_type rfind (String const &s, size_type pos=npos) const
 Searches this backwards string for the given string starting at the given position. More...
 
size_type rfind (std::string const &s, size_type pos=npos) const
 Searches this backwards string for the given string starting at the given position. More...
 
size_type rfind (const_pointer s, size_type pos=npos) const
 Searches this backwards string for the given string starting at the given position. More...
 
size_type rfind (const_pointer s, size_type pos, size_type s_n) const
 Searches this string backwards for the given string starting at the given position. More...
 
size_type rfind (value_type c, size_type pos=npos) const
 Searches this string backwards for the given character staring at the given position. More...
 
size_type size () const
 Gets the number of characters in this string. More...
 
std::string str () const
 Gets a std::string equivalent of this string. More...
 
 String ()
 Constructs an empty string. More...
 
 String (String const &s)
 Copy constructs a new string from an existing string. More...
 
 String (std::string const &s)
 Constructs a new string from an existing std::string. More...
 
 String (const_pointer s)
 Constructs a string from the given C string. More...
 
 String (String const &s, size_type pos, size_type n=npos)
 Copy constructs a new string from a substring of an existing string. More...
 
 String (std::string const &s, size_type pos, size_type n=npos)
 Constructs a new string from a substring of an existing std::string. More...
 
 String (const_pointer s, size_type n)
 Constructs a string from the given C string. More...
 
 String (size_type n, value_type c)
 Constructs a new string as n copies of c. More...
 
 String (const_iterator i, const_iterator j)
 Constructs a string from a range of characters [i,j). More...
 
String substr (size_type pos=0, size_type n=npos) const
 Creates a new string that is a substring of this string. More...
 
void swap (String &s)
 Swaps the contents of this string with another. More...
 
 ~String ()
 Destructs this string. More...
 

Static Public Attributes

static size_type const npos = static_cast<size_type>( -1 )
 The special value used to denote either (a) the maximum possible number as input or (b) "not found" as a result. More...
 

Friends

ZORBA_DLL_PUBLIC String operator+ (String const &, String const &)
 
ZORBA_DLL_PUBLIC String operator+ (String const &, std::string const &)
 
ZORBA_DLL_PUBLIC String operator+ (String const &, const_pointer)
 
ZORBA_DLL_PUBLIC String operator+ (std::string const &, String const &)
 
ZORBA_DLL_PUBLIC String operator+ (const_pointer, String const &)
 
ZORBA_DLL_PUBLIC bool operator< (String const &, String const &)
 
ZORBA_DLL_PUBLIC bool operator< (String const &, std::string const &)
 
ZORBA_DLL_PUBLIC bool operator< (String const &, const_pointer)
 
ZORBA_DLL_PUBLIC bool operator< (std::string const &, String const &)
 
ZORBA_DLL_PUBLIC bool operator< (const_pointer, String const &)
 
ZORBA_DLL_PUBLIC std::ostream & operator<< (std::ostream &, String const &)
 
ZORBA_DLL_PUBLIC bool operator<= (String const &, String const &)
 
ZORBA_DLL_PUBLIC bool operator<= (String const &, std::string const &)
 
ZORBA_DLL_PUBLIC bool operator<= (String const &, const_pointer)
 
ZORBA_DLL_PUBLIC bool operator<= (std::string const &, String const &)
 
ZORBA_DLL_PUBLIC bool operator<= (const_pointer, String const &)
 
ZORBA_DLL_PUBLIC bool operator== (String const &, String const &)
 
ZORBA_DLL_PUBLIC bool operator== (String const &, std::string const &)
 
ZORBA_DLL_PUBLIC bool operator== (String const &, const_pointer)
 
class Unmarshaller
 

Detailed Description

The Zorba string class.

Its API is mostly compatible with that of std::string.

Examples:
context.cpp, external_functions.cpp, sax2.cpp, and simple.cpp.

Definition at line 33 of file zorba_string.h.

Member Typedef Documentation

typedef std::allocator<value_type> zorba::String::allocator_type

Definition at line 37 of file zorba_string.h.

Definition at line 47 of file zorba_string.h.

Definition at line 42 of file zorba_string.h.

Definition at line 44 of file zorba_string.h.

typedef std::reverse_iterator<const_iterator> zorba::String::const_reverse_iterator

Definition at line 49 of file zorba_string.h.

typedef allocator_type::difference_type zorba::String::difference_type

Definition at line 38 of file zorba_string.h.

Definition at line 46 of file zorba_string.h.

Definition at line 41 of file zorba_string.h.

Definition at line 43 of file zorba_string.h.

typedef std::reverse_iterator<iterator> zorba::String::reverse_iterator

Definition at line 48 of file zorba_string.h.

typedef allocator_type::size_type zorba::String::size_type

Definition at line 39 of file zorba_string.h.

typedef std::char_traits<value_type> zorba::String::traits_type

Definition at line 36 of file zorba_string.h.

Definition at line 35 of file zorba_string.h.

Constructor & Destructor Documentation

zorba::String::String ( )

Constructs an empty string.

zorba::String::String ( String const &  s)

Copy constructs a new string from an existing string.

Parameters
sThe string to copy from.
zorba::String::String ( std::string const &  s)

Constructs a new string from an existing std::string.

Parameters
sThe string to copy from.
zorba::String::String ( const_pointer  s)

Constructs a string from the given C string.

Parameters
sThe null-terminated C string.
zorba::String::String ( String const &  s,
size_type  pos,
size_type  n = npos 
)

Copy constructs a new string from a substring of an existing string.

Parameters
sThe string to copy from.
posThe position of the first character to copy.
nThe number of characters to copy.
zorba::String::String ( std::string const &  s,
size_type  pos,
size_type  n = npos 
)

Constructs a new string from a substring of an existing std::string.

Parameters
sThe string to copy from.
posThe starting position of the substring.
nThe number of characters of the substring.
zorba::String::String ( const_pointer  s,
size_type  n 
)

Constructs a string from the given C string.

Parameters
sThe C string.
nThe number of characters to copy.
zorba::String::String ( size_type  n,
value_type  c 
)

Constructs a new string as n copies of c.

Parameters
nThe number of times to repeat the character.
cThe character to repeat.
zorba::String::String ( const_iterator  i,
const_iterator  j 
)

Constructs a string from a range of characters [i,j).

Parameters
iThe iterator marking the first character of the range.
jThe iterator marking one past the last character of the range.
zorba::String::~String ( )

Destructs this string.

Member Function Documentation

String& zorba::String::append ( String const &  s)

Appends the given string to this string.

Parameters
sThe string to append.
Returns
this string.
String& zorba::String::append ( String const &  s,
size_type  s_pos,
size_type  s_n 
)

Appends a substring of the given string to this string.

Parameters
sThe string to append.
s_posThe starting position is s.
s_nThe number of characters of s to append.
Returns
this string.
String& zorba::String::append ( std::string const &  s)

Appends the given string to this string.

Parameters
sThe string to append.
Returns
this string.
String& zorba::String::append ( std::string const &  s,
size_type  s_pos,
size_type  s_n 
)

Appends a substring of the given string to this string.

Parameters
sThe string to append.
s_posThe starting position is s.
s_nThe number of characters of s to append.
Returns
this string.
String& zorba::String::append ( const_pointer  s)

Appends the given C string to this string.

Parameters
sThe null-terminated C string to append.
Returns
this string.
String& zorba::String::append ( const_pointer  s,
size_type  s_n 
)

Appends the given C string to this string.

Parameters
sThe C string to append.
s_nThe number of characters of s to append.
Returns
this string.
String& zorba::String::append ( size_type  n,
value_type  c 
)

Appends n copies of c to this string.

Parameters
nThe numer of copies of c to append.
cThe character to append.
Returns
this string.
String& zorba::String::assign ( String const &  s)

Assigns another string to this string.

Parameters
sThe string to assign from.
Returns
this string.
String& zorba::String::assign ( std::string const &  s)

Assigns a std::string to this string.

Parameters
sThe string to assign from.
Returns
this string.
String& zorba::String::assign ( String const &  s,
size_type  pos,
size_type  n 
)

Assigns a substring of a string to this string.

Parameters
sThe string to assign from.
posThe starting position withing s.
nThe number of characters to assign.
Returns
this string.
String& zorba::String::assign ( std::string const &  s,
size_type  pos,
size_type  n 
)

Assigns a substring of a std::string to this string.

Parameters
sThe string to assign from.
posThe starting position withing s.
nThe number of characters to assign.
Returns
this string.
String& zorba::String::assign ( const_pointer  s)

Assigns a C to this string.

Parameters
sThe null-terminated C string to assign from.
Returns
this string.
String& zorba::String::assign ( const_pointer  s,
size_type  n 
)

Assigns a substring of a C to this string.

Parameters
sThe C string to assign from.
nThe number of characters to assign.
Returns
this string.
String& zorba::String::assign ( size_type  n,
value_type  c 
)

Assigned n copies of a character to this string.

Parameters
nThe number of copies of the character.
cThe character.
Returns
this string.
String& zorba::String::assign ( const_iterator  i,
const_iterator  j 
)

Assigns characters from a range of characters [i,j).

Parameters
iThe iterator marking the first character of the range.
jThe iterator marking one past the last character of the range.
reference zorba::String::at ( size_type  pos)

References a particular character within the string.

Parameters
posThe index of the character. The index is bounds-checked.
Returns
said character as an l-value.
Exceptions
std::out_of_rangeif pos >= size().
value_type zorba::String::at ( size_type  pos) const

References a particular character within the string.

Parameters
posThe index of the character. The index is bounds-checked.
Returns
said character as an r-value.
iterator zorba::String::begin ( )

Returns a read/write iterator positioned at the first character of the string.

Returns
said iterator.
const_iterator zorba::String::begin ( ) const

Returns a read-only iterator positioned at the first character of the string.

Returns
said iterator.
const_pointer zorba::String::c_str ( ) const

Gets a pointer to a null-terminated array of characters representing the string's contents.

Returns
said pointer.
See Also
data()

Referenced by zorba::fn::tokenize().

size_type zorba::String::capacity ( ) const

Gets the capacity of this string.

Returns
said capacity.
void zorba::String::clear ( )

Erases the string making it empty.

int zorba::String::compare ( String const &  s) const

Compares this string against another.

Parameters
sThe string to compare to.
Returns
-1 only if this string < s, 0 only if this string == s, or +1 only if this string > s.
int zorba::String::compare ( std::string const &  s) const

Compares this string against another.

Parameters
sThe string to compare to.
Returns
-1 only if this string < s, 0 only if this string == s, or +1 only if this string > s.
int zorba::String::compare ( const_pointer  s) const

Compares this string against a C string.

Parameters
sThe null-terminated C string to compare to.
Returns
-1 only if this string < s, 0 only if this string == s, or +1 only if this string > s.
int zorba::String::compare ( size_type  pos,
size_type  n,
String const &  s 
) const

Compares a substring of this string against another.

Parameters
posThe starting position within this string.
nThe number of characters to compare.
sThe string to compare to.
Returns
-1 only if this string < s, 0 only if this string == s, or +1 only if this string > s.
int zorba::String::compare ( size_type  pos,
size_type  n,
std::string const &  s 
) const

Compares a substring of this string against another.

Parameters
posThe starting position within this string.
nThe number of characters to compare.
sThe string to compare to.
Returns
-1 only if this string < s, 0 only if this string == s, or +1 only if this string > s.
int zorba::String::compare ( size_type  pos,
size_type  n,
const_pointer  s 
) const

Compares a substring of this string against a C string.

Parameters
posThe starting position within this string.
nThe number of characters to compare.
sThe null-terminated C string to compare to.
Returns
-1 only if this string < s, 0 only if this string == s, or +1 only if this string > s.
int zorba::String::compare ( size_type  pos,
size_type  n,
String const &  s,
size_type  s_pos,
size_type  s_n 
) const

Compares a substring of this string against a substring of another.

Parameters
posThe starting position within this string.
nThe number of characters to compare.
sThe string to compare to.
s_posThe starting position within s.
s_nThe number of characters of s to compare.
Returns
-1 only if this string < s, 0 only if this string == s, or +1 only if this string > s.
int zorba::String::compare ( size_type  pos,
size_type  n,
std::string const &  s,
size_type  s_pos,
size_type  s_n 
) const

Compares a substring of this string against a substring of another.

Parameters
posThe starting position within this string.
nThe number of characters to compare.
sThe string to compare to.
s_posThe starting position within s.
s_nThe number of characters of s to compare.
Returns
-1 only if this string < s, 0 only if this string == s, or +1 only if this string > s.
int zorba::String::compare ( size_type  pos,
size_type  n,
const_pointer  s,
size_type  s_n 
) const

Compares a substring of this string against a C string.

Parameters
posThe starting position within this string.
nThe number of characters to compare.
sThe C string to compare to.
s_nThe number of characters of s to compare.
Returns
-1 only if this string < s, 0 only if this string == s, or +1 only if this string > s.
size_type zorba::String::copy ( pointer  buf,
size_type  n,
size_type  pos = 0 
) const

Copies a substring to a C string buffer.

Parameters
bufThe buffer to copy into.
nThe number of characters to copy. It's the caller's responsibility to ensure that the size of buf <= n.
posThe position of the first character to copy.
Returns
the number of characters actually copied.
Exceptions
std::out_of_rangeif pos >= size().
const_pointer zorba::String::data ( ) const

Gets a pointer to the raw character data comprising the string, not necessarily null-terminated.

Returns
said pointer.
See Also
c_str()
bool zorba::String::empty ( ) const
inline

Checks whether the string is empty.

Returns
True only if it is.

Definition at line 180 of file zorba_string.h.

iterator zorba::String::end ( )

Returns a read/write iterator positioned at one past the last character of the string.

Returns
said iterator.
const_iterator zorba::String::end ( ) const

Returns a read-only iterator positioned at one past the last character of the string.

Returns
said iterator.
String& zorba::String::erase ( size_type  pos = 0,
size_type  n = npos 
)

Erases the given number of characters starting at the given position.

Parameters
posThe position of the first character to erase.
nThe number of characters to erase.
Returns
a reference to this string.
Exceptions
std::out_of_rangeif pos is beyond the end of the string.
iterator zorba::String::erase ( iterator  i)

Erases the character at the given iterator's position.

Parameters
iThe iterator marking the position of the character to erase.
Returns
a new iterator marking the same position (i.e., what becomes the next character).
iterator zorba::String::erase ( iterator  i,
iterator  j 
)

Erases a range of characters [i,j).

Parameters
iThe iterator marking the first character of the range.
jThe iterator marking one past the last character of the range.
Returns
a new iterator marking the same position as i.
size_type zorba::String::find ( String const &  s,
size_type  pos = 0 
) const

Searches this string for the given string starting at the given position.

Parameters
sThe string to search for.
posThe starting position within this string.
Returns
the offset of s or npos if not found.
size_type zorba::String::find ( std::string const &  s,
size_type  pos = 0 
) const

Searches this string for the given string starting at the given position.

Parameters
sThe string to search for.
posThe starting position within this string.
Returns
the offset of s or npos if not found.
size_type zorba::String::find ( const_pointer  s,
size_type  pos = 0 
) const

Searches this string for the given string starting at the given position.

Parameters
sThe null-terminated C string to search for.
posThe starting position within this string.
Returns
the offset of s or npos if not found.
size_type zorba::String::find ( const_pointer  s,
size_type  pos,
size_type  s_n 
) const

Searches this string for the given string starting at the given position.

Parameters
sThe C string to search for.
posThe starting position within this string.
s_nThe number of characters to compare.
Returns
the offset of s or npos if not found.
size_type zorba::String::find ( value_type  c,
size_type  pos = 0 
) const

Searches this string for the given character staring at the given position.

Parameters
cThe character to search for.
posThe starting position within this string.
Returns
the offset of c or npos if not found.
size_type zorba::String::find_first_not_of ( String const &  s,
size_type  pos = 0 
) const

Searches this string for any one of the characters not in s starting at the given position.

Parameters
sThe set of characters not to search for.
posThe starting position within this string.
Returns
the offset of a non-matching character or npos if not found.
size_type zorba::String::find_first_not_of ( std::string const &  s,
size_type  pos = 0 
) const

Searches this string for any one of the characters not in s starting at the given position.

Parameters
sThe set of characters not to search for.
posThe starting position within this string.
Returns
the offset of a non-matching character or npos if not found.
size_type zorba::String::find_first_not_of ( const_pointer  s,
size_type  pos = 0 
) const

Searches this string for any one of the characters not in s starting at the given position.

Parameters
sThe set of characters not to search for.
posThe starting position within this string.
Returns
the offset of a non-matching character or npos if not found.
size_type zorba::String::find_first_not_of ( const_pointer  s,
size_type  pos,
size_type  s_n 
) const

Searches this string for any one of the first s_n characters not in s starting at the given position.

Parameters
sThe set of characters not to search for.
posThe starting position within this string.
s_nThe number of characters of s to consider.
Returns
the offset of a non-matching character or npos if not found.
size_type zorba::String::find_first_not_of ( value_type  c,
size_type  pos = 0 
) const

Searches this string for any character except the given character starting at the given position.

Parameters
cThe character not to search for.
posThe starting position within this string.
Returns
the offset of any character except c or npos if not found.
size_type zorba::String::find_first_of ( String const &  s,
size_type  pos = 0 
) const

Searches this string for any one of the characters in s starting at the given position.

Parameters
sThe set of characters to search for.
posThe starting position within this string.
Returns
the offset of a matching character or npos if not found.
size_type zorba::String::find_first_of ( std::string const &  s,
size_type  pos = 0 
) const

Searches this string for any one of the characters in s starting at the given position.

Parameters
sThe set of characters to search for.
posThe starting position within this string.
Returns
the offset of a matching character or npos if not found.
size_type zorba::String::find_first_of ( const_pointer  s,
size_type  pos = 0 
) const

Searches this string for any one of the characters in s starting at the given position.

Parameters
sThe set of characters to search for.
posThe starting position within this string.
Returns
the offset of a matching character or npos if not found.
size_type zorba::String::find_first_of ( const_pointer  s,
size_type  pos,
size_type  s_n 
) const

Searches this string for any one of the first s_n characters in s starting at the given position.

Parameters
sThe set of characters to search for.
posThe starting position within this string.
s_nThe number of characters of s to consider.
Returns
the offset of a matching character or npos if not found.
size_type zorba::String::find_first_of ( value_type  c,
size_type  pos = 0 
) const

Searches this string for the given character starting at the given position.

Parameters
cThe character to search for.
posThe starting position within this string.
Returns
the offset of c or npos if not found.
size_type zorba::String::find_last_not_of ( String const &  s,
size_type  pos = npos 
) const

Searches this string backwards for any one of the characters not in s starting at the given position.

Parameters
sThe set of characters to not search for.
posThe starting position within this string.
Returns
the offset of a matching character or npos if not found.
size_type zorba::String::find_last_not_of ( std::string const &  s,
size_type  pos = npos 
) const

Searches this string backwards for any one of the characters not in s starting at the given position.

Parameters
sThe set of characters to not search for.
posThe starting position within this string.
Returns
the offset of a matching character or npos if not found.
size_type zorba::String::find_last_not_of ( const_pointer  s,
size_type  pos = npos 
) const

Searches this string backwards for any one of the characters not in s starting at the given position.

Parameters
sThe set of characters to not search for.
posThe starting position within this string.
Returns
the offset of a matching character or npos if not found.
size_type zorba::String::find_last_not_of ( const_pointer  s,
size_type  pos,
size_type  s_n 
) const

Searches this string backwards for any one of the first s_n characters not in s starting at the given position.

Parameters
sThe set of characters to not search for.
posThe starting position within this string.
s_nThe number of characters of s to consider.
Returns
the offset of a matching character or npos if not found.
size_type zorba::String::find_last_not_of ( value_type  c,
size_type  pos = npos 
) const

Searches this string backwards for any character except the given character starting at the given position.

Parameters
cThe character to search for.
posThe starting position within this string.
Returns
the offset of any character except c or npos if not found.
size_type zorba::String::find_last_of ( String const &  s,
size_type  pos = npos 
) const

Searches this string backwards for any one of the characters in s starting at the given position.

Parameters
sThe set of characters to search for.
posThe starting position within this string.
Returns
the offset of a matching character or npos if not found.
size_type zorba::String::find_last_of ( std::string const &  s,
size_type  pos = npos 
) const

Searches this string backwards for any one of the characters in s starting at the given position.

Parameters
sThe set of characters to search for.
posThe starting position within this string.
Returns
the offset of a matching character or npos if not found.
size_type zorba::String::find_last_of ( const_pointer  s,
size_type  pos = npos 
) const

Searches this string backwards for any one of the characters in s starting at the given position.

Parameters
sThe set of characters to search for.
posThe starting position within this string.
Returns
the offset of a matching character or npos if not found.
size_type zorba::String::find_last_of ( const_pointer  s,
size_type  pos,
size_type  s_n 
) const

Searches this string backwards for any one of the first s_n characters in s starting at the given position.

Parameters
sThe set of characters to search for.
posThe starting position within this string.
s_nThe number of characters of s to consider.
Returns
the offset of a matching character or npos if not found.
size_type zorba::String::find_last_of ( value_type  c,
size_type  pos = npos 
) const

Searches this string backwards for the given character starting at the given position.

Parameters
cThe character to search for.
posThe starting position within this string.
Returns
the offset of c or npos if not found.
String& zorba::String::insert ( size_type  pos,
String const &  s 
)

Inserts the given string into this string at the given position.

Parameters
posThe position within this string to insert at.
sThe string to insert.
Returns
this string.
String& zorba::String::insert ( size_type  pos,
std::string const &  s 
)

Inserts the given string into this string at the given position.

Parameters
posThe position within this string to insert at.
sThe string to insert.
Returns
this string.
String& zorba::String::insert ( size_type  pos,
const_pointer  s 
)

Inserts the given string into this string at the given position.

Parameters
posThe position within this string to insert at.
sThe null-terminated string to insert.
Returns
this string.
String& zorba::String::insert ( size_type  pos,
String const &  s,
size_type  s_pos,
size_type  s_n 
)

Inserts a substring of the given string into this string at the given position.

Parameters
posThe position within this string to insert at.
sThe null-terminated C string to insert.
s_posThe starting position within s.
s_nThe numer of characters of s to insert.
Returns
this string.
String& zorba::String::insert ( size_type  pos,
std::string const &  s,
size_type  s_pos,
size_type  s_n 
)

Inserts a substring of the given string into this string at the given position.

Parameters
posThe position within this string to insert at.
sThe null-terminated C string to insert.
s_posThe starting position within s.
s_nThe numer of characters of s to insert.
Returns
this string.
String& zorba::String::insert ( size_type  pos,
const_pointer  s,
size_type  s_n 
)

Inserts a substring of the given string into this string at the given position.

Parameters
posThe position within this string to insert at.
sThe C string to insert.
s_nThe numer of characters of s to insert.
Returns
this string.
String& zorba::String::insert ( size_type  pos,
size_type  n,
value_type  c 
)

Inserts n copies of c into this string at the given position.

Parameters
posThe position within this string to insert at.
nThe number of copies of c to insert.
cThe character to insert.
Returns
this string.
iterator zorba::String::insert ( iterator  pos,
value_type  c 
)

Inserts the given character into this string at the given position.

Parameters
posThe iterator marking the position within this string to insert at.
cThe character to insert.
Returns
Returns an iterator positioned at the newly inserted character.
void zorba::String::insert ( iterator  pos,
size_type  n,
value_type  c 
)

Inserts n copies of c into this string at the given position.

Parameters
posThe iterator marking the position within this string to insert at.
nThe number of copies of c to insert.
cThe character to insert.
size_type zorba::String::length ( ) const

Gets the number of characters in this string.

Returns
The number of UTF-8 characters.
String& zorba::String::operator+= ( String const &  s)
inline

Appends the given string to this string.

Parameters
sThe string to append.
Returns
this string.

Definition at line 305 of file zorba_string.h.

String& zorba::String::operator+= ( std::string const &  s)
inline

Appends the given std::string to this string.

Parameters
sThe string to append.
Returns
this string.

Definition at line 315 of file zorba_string.h.

String& zorba::String::operator+= ( const_pointer  s)
inline

Appends the given C string to this string.

Parameters
sThe null-terminated C string to append.
Returns
this string.

Definition at line 325 of file zorba_string.h.

String& zorba::String::operator+= ( value_type  c)
inline

Appends the given character to this string.

Parameters
cThe character to append.
Returns
this string.

Definition at line 335 of file zorba_string.h.

String& zorba::String::operator= ( String const &  s)

Assigns another string to this string.

Parameters
sThe string to assign from.
Returns
this string.
String& zorba::String::operator= ( std::string const &  s)

Assigns a std::string to this string.

Parameters
sThe string to assign from.
Returns
this string.
String& zorba::String::operator= ( const_pointer  s)

Assigns a C string to this string.

Parameters
sThe null-terminated C string to assign from.
Returns
this string.
String& zorba::String::operator= ( value_type  c)

Assigns a character to this string.

Parameters
cThe character to assign.
Returns
this string.
const_reference zorba::String::operator[] ( size_type  pos) const

References a particular character within the string.

Parameters
posThe index of the character. The index is not bounds-checked.
Returns
said character as an r-value.
void zorba::String::push_back ( value_type  c)

Appends the given character to this string.

Parameters
cThe character to append.
reverse_iterator zorba::String::rbegin ( )

Returns a read/write reverse iterator positioned at the first character of the reversed string.

Returns
said iterator.
const_reverse_iterator zorba::String::rbegin ( ) const

Returns a read-only reverse iterator positioned at the first character of the reversed string.

Returns
said iterator.
reverse_iterator zorba::String::rend ( )

Returns a read/write reverse iterator positioned at one past the last character of the reversed string.

Returns
said iterator.
const_reverse_iterator zorba::String::rend ( ) const

Returns a read-only reverse iterator positioned at one past the last character of the reversed string.

Returns
said iterator.
String& zorba::String::replace ( size_type  pos,
size_type  n,
String const &  s 
)

Replaces n characters of this string starting at the given position with the given string.

Parameters
posThe position within this string to replace at.
nThe number of characters to replace.
sThe replacement string.
Returns
this string.
String& zorba::String::replace ( size_type  pos,
size_type  n,
std::string const &  s 
)

Replaces n characters of this string starting at the given position with the given string.

Parameters
posThe position within this string to replace at.
nThe number of characters to replace.
sThe replacement string.
Returns
this string.
String& zorba::String::replace ( size_type  pos,
size_type  n,
const_pointer  s 
)

Replaces n characters of this string starting at the given position with the given string.

Parameters
posThe position within this string to replace at.
nThe number of characters to replace.
sThe null-terminated replacement C string.
Returns
this string.
String& zorba::String::replace ( size_type  pos,
size_type  n,
String const &  s,
size_type  s_pos,
size_type  s_n 
)

Replaces n characters of this string starting at the given position with a substring of the given string.

Parameters
posThe position within this string to replace at.
nThe number of characters to replace.
sThe replacement string.
s_posThe starting position is s.
s_nThe number of characters of s to use.
Returns
this string.
String& zorba::String::replace ( size_type  pos,
size_type  n,
std::string const &  s,
size_type  s_pos,
size_type  s_n 
)

Replaces n characters of this string starting at the given position with a substring of the given string.

Parameters
posThe position within this string to replace at.
nThe number of characters to replace.
sThe replacement string.
s_posThe starting position is s.
s_nThe number of characters of s to use.
Returns
this string.
String& zorba::String::replace ( size_type  pos,
size_type  n,
const_pointer  s,
size_type  s_n 
)

Replaces n characters of this string starting at the given position with a substring of the given string.

Parameters
posThe position within this string to replace at.
nThe number of characters to replace.
sThe replacement C string.
s_nThe number of characters of s to use.
Returns
this string.
String& zorba::String::replace ( size_type  pos,
size_type  n,
size_type  c_n,
value_type  c 
)

Replaces n characters of this string starting at the given position with c_n copies of c.

Parameters
posThe position within this string to replace at.
nThe number of characters to replace.
c_nThe number of copies of to replace with.
cThe character to replace with.
Returns
this string.
String& zorba::String::replace ( iterator  i,
iterator  j,
String const &  s 
)

Replaces the range of characters [i,j) of this string with the given string.

Parameters
iThe iterator marking the first character of the range.
jThe iterator marking one past the last character of the range.
sThe replacement string.
Returns
this string.
String& zorba::String::replace ( iterator  i,
iterator  j,
std::string const &  s 
)

Replaces the range of characters [i,j) of this string with the given string.

Parameters
iThe iterator marking the first character of the range.
jThe iterator marking one past the last character of the range.
sThe replacement string.
Returns
this string.
String& zorba::String::replace ( iterator  i,
iterator  j,
const_pointer  s 
)

Replaces the range of characters [i,j) of this string with the given string.

Parameters
iThe iterator marking the first character of the range.
jThe iterator marking one past the last character of the range.
sThe null-terminated replacement C string.
Returns
this string.
String& zorba::String::replace ( iterator  i,
iterator  j,
const_pointer  s,
size_type  s_n 
)

Replaces the range of characters [i,j) of this string with a substring of the given string.

Parameters
iThe iterator marking the first character of the range.
jThe iterator marking one past the last character of the range.
sThe replacement C string.
s_nThe number of characters of s to use.
Returns
this string.
String& zorba::String::replace ( iterator  i,
iterator  j,
size_type  n,
value_type  c 
)

Replaces the range of characters [i,j) of this string with c_n copies of c.

Parameters
iThe iterator marking the first character of the range.
jThe iterator marking one past the last character of the range.
nThe number of copies of to replace with.
cThe character to replace with.
Returns
Returns this string.
String& zorba::String::replace ( iterator  i,
iterator  j,
iterator  si,
iterator  sj 
)

Replaces the range of characters [i,j) of this string with the range of characters [si,sj).

Parameters
iThe iterator marking the first character of the range.
jThe iterator marking one past the last character of the range.
siThe iterator marking the first character of the range.
sjThe iterator marking one past the last character of the range.
Returns
this string.
void zorba::String::reserve ( size_type  n)

Attemts to pre-allocated enough memory to contain the given number of bytes.

Parameters
nThe number of bytes.
void zorba::String::resize ( size_type  n,
value_type  c = value_type() 
)

Resizes the string to the given number of characters.

If the number < size(), the string will be truncated; if the number > size(), the string will be extended and the new elements will be set to c.

Parameters
nThe number of characters.
cCharacters to fill any new positions.
size_type zorba::String::rfind ( String const &  s,
size_type  pos = npos 
) const

Searches this backwards string for the given string starting at the given position.

Parameters
sThe string to search for.
posThe starting position within this string.
Returns
the offset of s or npos if not found.
size_type zorba::String::rfind ( std::string const &  s,
size_type  pos = npos 
) const

Searches this backwards string for the given string starting at the given position.

Parameters
sThe string to search for.
posThe starting position within this string.
Returns
the offset of s or npos if not found.
size_type zorba::String::rfind ( const_pointer  s,
size_type  pos = npos 
) const

Searches this backwards string for the given string starting at the given position.

Parameters
sThe string to search for.
posThe starting position within this string.
Returns
the offset of s or npos if not found.
size_type zorba::String::rfind ( const_pointer  s,
size_type  pos,
size_type  s_n 
) const

Searches this string backwards for the given string starting at the given position.

Parameters
sThe C string to search for.
posThe starting position within this string.
s_nThe number of characters to compare.
Returns
the offset of s or npos if not found.
size_type zorba::String::rfind ( value_type  c,
size_type  pos = npos 
) const

Searches this string backwards for the given character staring at the given position.

Parameters
cThe character to search for.
posThe starting position within this string.
Returns
the offset of c or npos if not found.
size_type zorba::String::size ( ) const
inline

Gets the number of characters in this string.

(This is a synonym for length().)

Returns
The number of UTF-8 characters.

Definition at line 197 of file zorba_string.h.

std::string zorba::String::str ( ) const

Gets a std::string equivalent of this string.

(There intentionally is no operator std::string() const since its convenient use would mask the expense of creating a new std::string.) This function is an extension to the std::string API.

Returns
said std::string.
String zorba::String::substr ( size_type  pos = 0,
size_type  n = npos 
) const

Creates a new string that is a substring of this string.

Parameters
posThe position in this string for first character of the new string.
nThe number of characters to extract.
Returns
the new string.
Exceptions
std::out_of_rangeif pos >= size().
void zorba::String::swap ( String s)

Swaps the contents of this string with another.

This is an O(1) operation.

Parameters
sThe string to swap with.

Friends And Related Function Documentation

ZORBA_DLL_PUBLIC String operator+ ( String const &  ,
String const &   
)
friend
ZORBA_DLL_PUBLIC String operator+ ( String const &  ,
std::string const &   
)
friend
ZORBA_DLL_PUBLIC String operator+ ( String const &  ,
const_pointer   
)
friend
ZORBA_DLL_PUBLIC String operator+ ( std::string const &  ,
String const &   
)
friend
ZORBA_DLL_PUBLIC String operator+ ( const_pointer  ,
String const &   
)
friend
ZORBA_DLL_PUBLIC bool operator< ( String const &  ,
String const &   
)
friend
ZORBA_DLL_PUBLIC bool operator< ( String const &  ,
std::string const &   
)
friend
ZORBA_DLL_PUBLIC bool operator< ( String const &  ,
const_pointer   
)
friend
ZORBA_DLL_PUBLIC bool operator< ( std::string const &  ,
String const &   
)
friend
ZORBA_DLL_PUBLIC bool operator< ( const_pointer  ,
String const &   
)
friend
ZORBA_DLL_PUBLIC std::ostream& operator<< ( std::ostream &  ,
String const &   
)
friend
ZORBA_DLL_PUBLIC bool operator<= ( String const &  ,
String const &   
)
friend
ZORBA_DLL_PUBLIC bool operator<= ( String const &  ,
std::string const &   
)
friend
ZORBA_DLL_PUBLIC bool operator<= ( String const &  ,
const_pointer   
)
friend
ZORBA_DLL_PUBLIC bool operator<= ( std::string const &  ,
String const &   
)
friend
ZORBA_DLL_PUBLIC bool operator<= ( const_pointer  ,
String const &   
)
friend
ZORBA_DLL_PUBLIC bool operator== ( String const &  ,
String const &   
)
friend
ZORBA_DLL_PUBLIC bool operator== ( String const &  ,
std::string const &   
)
friend
ZORBA_DLL_PUBLIC bool operator== ( String const &  ,
const_pointer   
)
friend
friend class Unmarshaller
friend

Definition at line 1321 of file zorba_string.h.

Member Data Documentation

size_type const zorba::String::npos = static_cast<size_type>( -1 )
static

The special value used to denote either (a) the maximum possible number as input or (b) "not found" as a result.

Definition at line 55 of file zorba_string.h.


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