commore  1.0.6-SNAPSHOT
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
commore::String Class Reference

#include <String.h>

Classes

class  Allocator
 

Public Types

enum  { STRING_INCREMENT_SIZE = 16 }
 
typedef AllocatorPAllocator
 
typedef Char value_type
 
typedef size_t size_type
 
typedef Charreference
 
typedef const Charconst_reference
 
typedef Charpointer
 
typedef const Charconst_pointer
 

Public Member Functions

 String ()
 
 String (const String &str)
 
 String (const String &str, size_t pos, size_t n=(size_t) npos)
 
 String (const Char *str, size_t n)
 
 String (const Char *str)
 
 String (const AChar *str, size_t n)
 
 String (const AChar *str)
 
 String (size_t n, Char c)
 
Stringoperator= (const String &str)
 
Stringoperator= (const AChar *str)
 
Stringoperator= (const Char *str)
 
Stringoperator= (Char c)
 
 ~String ()
 
bool operator== (const AChar *str) const
 
bool operator== (const String &str) const
 
bool operator== (const Char *str) const
 
bool operator!= (const AChar *str) const
 
bool operator!= (const String &str) const
 
bool operator!= (const Char *str) const
 
Stringoperator+= (const String &str)
 
String operator+ (const String &str) const
 
Stringoperator+= (const Char *str)
 
Stringoperator+= (const AChar *str)
 
Stringoperator+= (Char c)
 
Stringoperator+= (AChar c)
 
bool operator< (const String &s) const
 
bool operator> (const String &s) const
 
Stringappend (const String &str)
 
Stringappend (const String &str, size_t pos, size_t n)
 
Stringappend (const Char *str, size_t n)
 
Stringappend (const AChar *str, size_t n)
 
Stringappend (const Char *str)
 
Stringappend (const AChar *str)
 
Stringappend (size_t n, Char c)
 
bool validate_range (size_t pos, size_t *len) const
 
Stringassign (const String &other)
 
Stringassign (const String &str, size_t pos, size_t n)
 
Stringassign (const Char *str, size_t n)
 
Stringassign (const Char *str)
 
Stringassign (size_t n, Char c)
 
Stringassign (const AChar *str, size_t n)
 
Stringassign (const AChar *str)
 
Stringassign (size_t n, AChar c)
 
void swap (String &str)
 
void splice (String &str)
 
Stringinsert (size_t pos1, const String &str)
 
Stringinsert (size_t pos1, const String &str, size_t pos2, size_t n)
 
Stringinsert (size_t pos, const Char *str, size_t n)
 
Stringinsert (size_t pos, const Char *str)
 
Stringinsert (size_t pos, size_t n, Char c)
 
Stringclear ()
 
Stringerase (size_t pos=0, size_t n=(size_t) npos)
 
Stringreplace (size_t pos1, size_t n1, const String &str)
 
Stringreplace (size_t pos1, size_t n1, const String &str, size_t pos2, size_t n2)
 
Stringreplace (size_t pos, size_t n1, const Char *str, size_t n2)
 
Stringreplace (size_t pos, size_t n1, const Char *str)
 
Stringreplace (size_t pos, size_t n1, size_t n2, Char c)
 
Char operator[] (size_t pos) const
 
Charoperator[] (size_t pos)
 
Char at (size_t pos) const
 
Charat (size_t pos)
 
const Charc_str () const
 
 operator const Char * () const
 
const Chardata () const
 
const PAllocatorget_allocator () const
 
size_t length () const
 
size_t size () const
 
size_t max_size () const
 
bool empty () const
 
void resize (size_t n, Char c)
 
void resize (size_t n)
 
size_t capacity () const
 
void reserve (size_t size)
 
size_t copy (Char *str, size_t n, size_t pos=0) const
 Copy sequence of characters from string Copies a substring of the current value of the string object into the array pointed by s. This substring contains the len characters that start at position pos. The function does not append a null character at the end of the copied content. More...
 
size_t find (const String &str, size_t pos=0) const
 Find content in string Searches the string for the first occurrence of the sequence specified by its arguments. When pos is specified, the search only includes characters at or after position pos, ignoring any possible occurrences that include characters before pos. Notice that unlike member find_first_of, whenever more than one character is being searched for, it is not enough that just one of these characters match, but the entire sequence must match. More...
 
size_t find (const Char *s, size_t pos, size_t n) const
 
size_t find (const Char *str, size_t pos=0) const
 
size_t find (Char c, size_t pos=0) const
 
size_t find_first_of (const String &str, size_t pos=0) const
 
size_t find_first_of (const Char *s, size_t pos, size_t n) const
 
size_t find_first_of (const Char *str, size_t pos=0) const
 
size_t find_first_of (Char c, size_t pos=0) const
 
size_t find_first_not_of (const String &str, size_t pos=0) const
 
size_t find_first_not_of (const Char *s, size_t pos, size_t n) const
 
size_t find_first_not_of (Char c, size_t pos=0) const
 
size_t find_first_not_of (const Char *str, size_t pos=0) const
 
size_t rfind (const Char *str, size_t pos, size_t n) const
 
size_t find_last_of (const Char *s, size_t pos, size_t n) const
 
size_t find_last_not_of (const Char *s, size_t pos, size_t n) const
 
size_t rfind (const String &str, size_t pos=(size_t) npos) const
 
size_t rfind (const Char *str, size_t pos=(size_t) npos) const
 
size_t rfind (Char c, size_t pos=(size_t) npos) const
 
size_t find_last_of (const String &str, size_t pos=(size_t) npos) const
 
size_t find_last_of (Char c, size_t pos=(size_t) npos) const
 
size_t find_last_of (const Char *str, size_t pos=(size_t) npos) const
 
size_t find_last_not_of (const String &str, size_t pos=(size_t) npos) const
 
size_t find_last_not_of (const Char &c, size_t pos=(size_t) npos) const
 
size_t find_last_not_of (const Char *str, size_t pos=(size_t) npos) const
 
String substr (size_t pos=0, size_t n=(size_t) npos) const
 
int compare (const String &str) const
 
int compare (size_t pos, size_t n, const String &str) const
 
int compare (size_t pos1, size_t n1, const String &str, size_t pos2, size_t n2) const
 
int compare (const Char *s) const
 
int compare (const AChar *s) const
 
int compare (size_t pos, size_t n1, const Char *str, size_t n2=(size_t) npos) const
 
int icompare (const String &str) const
 
int icompare (size_t pos, size_t n, const String &str) const
 
int icompare (size_t pos1, size_t n1, const String &str, size_t pos2, size_t n2) const
 
int icompare (const Char *s) const
 
int icompare (const AChar *s) const
 
int icompare (size_t pos, size_t n1, const Char *str, size_t n2=(size_t) npos) const
 
Int to_int () const
 
Stringmake_upper ()
 
Stringmake_lower ()
 
bool match (const String &pattern, String &a0) const
 
bool match (const String &pattern, String &a0, String &a1) const
 
bool match (const String &pattern, String &a0, String &a1, String &a2) const
 
bool match (const String &pattern, String &a0, String &a1, String &a2, String &a3) const
 
bool match (const String &pattern, String &a0, String &a1, String &a2, String &a3, String &a4) const
 
bool match (const String &pattern, String &a0, String &a1, String &a2, String &a3, String &a4, String &a5) const
 
bool match (const String &pattern, String &a0, String &a1, String &a2, String &a3, String &a4, String &a5, String &a6) const
 
bool match (const String &pattern, String &a0, String &a1, String &a2, String &a3, String &a4, String &a5, String &a6, String &a7) const
 
long write_xml (OBStream &o) const
 
long write (CommBuffer &buffer) const
 
long read_xml (IBStream &i)
 
long read (const CommBuffer &buffer)
 
Stringfrom_acsii (const AChar *s)
 

Static Public Member Functions

static Char eos ()
 
static int compare (const Char *s1, const Char *s2, size_t n)
 
static int compare (const Char *s1, const AChar *s2, size_t n)
 
static int icompare (const Char *s1, const Char *s2, size_t n)
 
static const Charfind (const Char *s, int n, const Char &a)
 
static size_t length (const Char *s)
 
static size_t length (const AChar *s)
 
static Charcopy (Char *dest, const Char *src, size_t n)
 
static Charcopy (Char *dest, const AChar *src, size_t n)
 
static Charmove (Char *dest, const Char *src, size_t n)
 
static Charassign (Char *dest, size_t n, const Char &c)
 
static void assign (Char &c1, const Char &c2)
 
static bool eq (const Char &c1, const Char &c2)
 
static bool ne (const Char &c1, const Char &c2)
 
static bool lt (const Char &c1, const Char &c2)
 
static bool ieq (const Char &c1, const Char &c2)
 
static bool ine (const Char &c1, const Char &c2)
 
static bool ilt (const Char &c1, const Char &c2)
 

Friends

class Iterator
 

Detailed Description

Unicode string class. Is inspired by stl::string

Remarks
does not manage the character encoding
Todo:
keep only usefull method

Member Typedef Documentation

Member Enumeration Documentation

anonymous enum
Enumerator
STRING_INCREMENT_SIZE 

Constructor & Destructor Documentation

String::String ( )
String::String ( const String str)
String::String ( const String str,
size_t  pos,
size_t  n = (size_t)npos 
)

Constuctor with a substring

Parameters
strsource string
posstart position
nsize of substrins
String::String ( const Char str,
size_t  n 
)

Constuctor with a substring

Parameters
strsource null terminated string
nsize of substrins
String::String ( const Char str)

Constuctor with a null terminated unicode string

Parameters
strsource null terminated unicode string
String::String ( const AChar str,
size_t  n 
)

Constuctor with a unicode substring

Parameters
strsource null terminated string
nsize of substrins
String::String ( const AChar str)

Constuctor with a null terminated string

Parameters
strsource null terminated string
String::String ( size_t  n,
Char  c 
)

Fill Constructor Fills the string with n consecutive copies of unicode character c.

Parameters
n
c
String::~String ( )

Member Function Documentation

String& commore::String::append ( const String str)
inline

Append unicode string

String& commore::String::append ( const String str,
size_t  pos,
size_t  n 
)
inline

Append unicode substring

Parameters
strsource string
posbegin of substring
nsize of substring
String& commore::String::append ( const Char str,
size_t  n 
)
inline

Append unicode substring

Parameters
strsource string
nsize of substring
String& commore::String::append ( const AChar str,
size_t  n 
)
inline

Append null terminated substring

Parameters
strsource string
nsize of substring
String& commore::String::append ( const Char str)
inline

Append null terminated unicode substring

Parameters
strsource string
String& commore::String::append ( const AChar str)
inline

Append null terminated substring

Parameters
strsource string
String& commore::String::append ( size_t  n,
Char  c 
)
inline

Append n consecutive copies of character c.

Parameters
n
c
String & String::assign ( const String other)

Assign string content

String& commore::String::assign ( const String str,
size_t  pos,
size_t  n 
)
inline

Assign string content with a substring

String& commore::String::assign ( const Char str,
size_t  n 
)
inline

Assign string content with a null terminated substring

String& commore::String::assign ( const Char str)
inline

Assign string content with null terminated string

String& commore::String::assign ( size_t  n,
Char  c 
)
inline

Assign string content with n consecutive copies of character c.

String& commore::String::assign ( const AChar str,
size_t  n 
)
inline

Assign string content with null terminated string

String& commore::String::assign ( const AChar str)
inline

Assign string content with null terminated string

String& commore::String::assign ( size_t  n,
AChar  c 
)
inline

Assign string content with n consecutive copies of character c.

Char * String::assign ( Char dest,
size_t  n,
const Char c 
)
static
static void commore::String::assign ( Char c1,
const Char c2 
)
inlinestatic
Char commore::String::at ( size_t  pos) const
inline
See also
const get_at
Char& commore::String::at ( size_t  pos)
inline
See also
get_at
const Char* commore::String::c_str ( ) const
inline

Get C unicode string equivalent

Returns
a pointer to an array that contains a null-terminated sequence of characters (i.e., a C-string) representing the current value of the string object.
size_t commore::String::capacity ( ) const
inline
Returns
string capacity (real allocated size)
String& commore::String::clear ( )
inline

Clear string content

int commore::String::compare ( const String str) const
inline
int commore::String::compare ( size_t  pos,
size_t  n,
const String str 
) const
inline
int commore::String::compare ( size_t  pos1,
size_t  n1,
const String str,
size_t  pos2,
size_t  n2 
) const
inline
int commore::String::compare ( const Char s) const
inline
int commore::String::compare ( const AChar s) const
inline
int String::compare ( size_t  pos,
size_t  n1,
const Char str,
size_t  n2 = (size_t)npos 
) const
int String::compare ( const Char s1,
const Char s2,
size_t  n 
)
static
int String::compare ( const Char s1,
const AChar s2,
size_t  n 
)
static
size_t commore::String::copy ( Char str,
size_t  n,
size_t  pos = 0 
) const
inline

Copy sequence of characters from string Copies a substring of the current value of the string object into the array pointed by s. This substring contains the len characters that start at position pos. The function does not append a null character at the end of the copied content.

Parameters
strPointer to an array of characters. The array shall contain enough storage for the copied characters.
nNumber of characters to copy (if the string is shorter, as many characters as possible are copied).
posPosition of the first character to be copied.
Char * String::copy ( Char dest,
const Char src,
size_t  n 
)
static
Char * String::copy ( Char dest,
const AChar src,
size_t  n 
)
static
const Char* commore::String::data ( ) const
inline

Convesion operator to null terminated string

bool commore::String::empty ( ) const
inline
Returns
true if string is empty
static Char commore::String::eos ( )
inlinestatic
static bool commore::String::eq ( const Char c1,
const Char c2 
)
inlinestatic
String& commore::String::erase ( size_t  pos = 0,
size_t  n = (size_t)npos 
)
inline

Delete substring

Parameters
posstart position
nsubstring size
size_t commore::String::find ( const String str,
size_t  pos = 0 
) const
inline

Find content in string Searches the string for the first occurrence of the sequence specified by its arguments. When pos is specified, the search only includes characters at or after position pos, ignoring any possible occurrences that include characters before pos. Notice that unlike member find_first_of, whenever more than one character is being searched for, it is not enough that just one of these characters match, but the entire sequence must match.

Parameters
strAnother string with the subject to search for.
posPosition of the first character in the string to be considered in the search. If this is greater than the string length, the function never finds matches. Note: The first character is denoted by a value of 0 (not 1): A value of 0 means that the entire string is searched.
sPointer to an array of characters. If argument n is specified (3), the sequence to match are the first n characters in the array. Otherwise (2), a null-terminated sequence is expected: the length of the sequence to match is determined by the first occurrence of a null character.
nLength of sequence of characters to match.
cIndividual character to be searched for.
size_t String::find ( const Char s,
size_t  pos,
size_t  n 
) const
size_t commore::String::find ( const Char str,
size_t  pos = 0 
) const
inline
size_t commore::String::find ( Char  c,
size_t  pos = 0 
) const
inline
static const Char* commore::String::find ( const Char s,
int  n,
const Char a 
)
static
size_t commore::String::find_first_not_of ( const String str,
size_t  pos = 0 
) const
inline
size_t String::find_first_not_of ( const Char s,
size_t  pos,
size_t  n 
) const
size_t commore::String::find_first_not_of ( Char  c,
size_t  pos = 0 
) const
inline
size_t commore::String::find_first_not_of ( const Char str,
size_t  pos = 0 
) const
inline
size_t commore::String::find_first_of ( const String str,
size_t  pos = 0 
) const
inline
size_t String::find_first_of ( const Char s,
size_t  pos,
size_t  n 
) const
size_t commore::String::find_first_of ( const Char str,
size_t  pos = 0 
) const
inline
size_t commore::String::find_first_of ( Char  c,
size_t  pos = 0 
) const
inline
size_t String::find_last_not_of ( const Char s,
size_t  pos,
size_t  n 
) const
size_t commore::String::find_last_not_of ( const String str,
size_t  pos = (size_t)npos 
) const
inline
size_t commore::String::find_last_not_of ( const Char c,
size_t  pos = (size_t)npos 
) const
inline
size_t commore::String::find_last_not_of ( const Char str,
size_t  pos = (size_t)npos 
) const
inline
size_t String::find_last_of ( const Char s,
size_t  pos,
size_t  n 
) const
size_t commore::String::find_last_of ( const String str,
size_t  pos = (size_t)npos 
) const
inline
size_t commore::String::find_last_of ( Char  c,
size_t  pos = (size_t)npos 
) const
inline
size_t commore::String::find_last_of ( const Char str,
size_t  pos = (size_t)npos 
) const
inline
String & String::from_acsii ( const AChar s)
const PAllocator& commore::String::get_allocator ( ) const
inline

Reference to allocator

int commore::String::icompare ( const String str) const
inline
int commore::String::icompare ( size_t  pos,
size_t  n,
const String str 
) const
inline
int commore::String::icompare ( size_t  pos1,
size_t  n1,
const String str,
size_t  pos2,
size_t  n2 
) const
inline
int commore::String::icompare ( const Char s) const
inline
int commore::String::icompare ( const AChar s) const
inline
int String::icompare ( size_t  pos,
size_t  n1,
const Char str,
size_t  n2 = (size_t)npos 
) const
int String::icompare ( const Char s1,
const Char s2,
size_t  n 
)
static
bool String::ieq ( const Char c1,
const Char c2 
)
static
bool String::ilt ( const Char c1,
const Char c2 
)
static
static bool commore::String::ine ( const Char c1,
const Char c2 
)
inlinestatic
String& commore::String::insert ( size_t  pos1,
const String str 
)
inline

Insert string

Parameters
pos1insert position
strstring to insert
String& commore::String::insert ( size_t  pos1,
const String str,
size_t  pos2,
size_t  n 
)
inline

Insert substring

Parameters
pos1insert position
strstring to insert
pos2start substring position
nsubstring size
String& commore::String::insert ( size_t  pos,
const Char str,
size_t  n 
)
inline

Insert null terminated substring

Parameters
posinsert position
strnull terminated string to insert
nsubstring size
String& commore::String::insert ( size_t  pos,
const Char str 
)
inline

Insert null terminated substring

Parameters
posinsert position
strnull terminated string to insert
String& commore::String::insert ( size_t  pos,
size_t  n,
Char  c 
)
inline

Insert n consecutive copies of character c.

Parameters
posinsert position
n
c
size_t commore::String::length ( ) const
inline
Returns
string length
size_t String::length ( const Char s)
static
size_t String::length ( const AChar s)
static
static bool commore::String::lt ( const Char c1,
const Char c2 
)
inlinestatic
String & String::make_lower ( )
String & String::make_upper ( )
bool String::match ( const String pattern,
String a0 
) const
bool String::match ( const String pattern,
String a0,
String a1 
) const
bool String::match ( const String pattern,
String a0,
String a1,
String a2 
) const
bool String::match ( const String pattern,
String a0,
String a1,
String a2,
String a3 
) const
bool String::match ( const String pattern,
String a0,
String a1,
String a2,
String a3,
String a4 
) const
bool String::match ( const String pattern,
String a0,
String a1,
String a2,
String a3,
String a4,
String a5 
) const
bool String::match ( const String pattern,
String a0,
String a1,
String a2,
String a3,
String a4,
String a5,
String a6 
) const
bool String::match ( const String pattern,
String a0,
String a1,
String a2,
String a3,
String a4,
String a5,
String a6,
String a7 
) const
size_t commore::String::max_size ( ) const
inline
Returns
max string length
Char * String::move ( Char dest,
const Char src,
size_t  n 
)
static
static bool commore::String::ne ( const Char c1,
const Char c2 
)
inlinestatic
commore::String::operator const Char * ( ) const
inline

Implicit convesion operator to null terminated string

bool commore::String::operator!= ( const AChar str) const
inline

Tests the difference with a null terminated string

bool commore::String::operator!= ( const String str) const
inline

Tests difference with an unicode string

bool commore::String::operator!= ( const Char str) const
inline

Tests the difference with a null terminated string

String commore::String::operator+ ( const String str) const
inline

String concatenation operator

String& commore::String::operator+= ( const String str)
inline

Append string operator

String& commore::String::operator+= ( const Char str)
inline

Append string operator

String& commore::String::operator+= ( const AChar str)
inline

Append string operator

String& commore::String::operator+= ( Char  c)
inline

Append string operator

String& commore::String::operator+= ( AChar  c)
inline

Append string operator

bool commore::String::operator< ( const String s) const
inline

Compare string operator with lexical order

String& commore::String::operator= ( const String str)
inline
String& commore::String::operator= ( const AChar str)
inline

Assigment operator with null terminated unicode string

Parameters
strsource null terminated string
String& commore::String::operator= ( const Char str)
inline

Assigment operator with null terminated string

Parameters
strsource nult terminated string
String& commore::String::operator= ( Char  c)
inline

Assigment operator with an unicode caracter

Parameters
csource caracter
bool commore::String::operator== ( const AChar str) const
inline

Tests the equality with a null terminated string

bool commore::String::operator== ( const String str) const
inline

Tests equality with an unicode string

bool commore::String::operator== ( const Char str) const
inline

Tests the equality with a null terminated unicode string

bool commore::String::operator> ( const String s) const
inline

Compare string operator with lexical order

Char commore::String::operator[] ( size_t  pos) const
inline

Get character of string

Returns
the character at position pos in the string.
Char& commore::String::operator[] ( size_t  pos)
inline

Get character of string

Returns
a reference to the character at position pos in the string.
long String::read ( const CommBuffer buffer)
long commore::String::read_xml ( IBStream i)
String& commore::String::replace ( size_t  pos1,
size_t  n1,
const String str 
)
inline

Replace a substring

Parameters
posstart position
nsubstring size
strreplacement string
String& commore::String::replace ( size_t  pos1,
size_t  n1,
const String str,
size_t  pos2,
size_t  n2 
)
inline

Replace a substring

Parameters
pos1start position
n1substring size
strreplacement string
pos2substring start position
n2substring size
String& commore::String::replace ( size_t  pos,
size_t  n1,
const Char str,
size_t  n2 
)
inline

Replace a substring

Parameters
pos1start position
n1substring size
strreplacement null terminated string
n2substring size
String& commore::String::replace ( size_t  pos,
size_t  n1,
const Char str 
)
inline

Replace a substring

Parameters
pos1start position
n1substring size
strreplacement null terminated string
String& commore::String::replace ( size_t  pos,
size_t  n1,
size_t  n2,
Char  c 
)
inline

Replace a substring by n2 consecutive copies of character c.

Parameters
pos1start position
n1substring size
n2
c
void commore::String::reserve ( size_t  size)
inline

Allocate a new string capacity

void commore::String::resize ( size_t  n,
Char  c 
)
inline

Resize string,fill with character c

void commore::String::resize ( size_t  n)
inline

Resize string

size_t String::rfind ( const Char str,
size_t  pos,
size_t  n 
) const
size_t commore::String::rfind ( const String str,
size_t  pos = (size_t)npos 
) const
inline
size_t commore::String::rfind ( const Char str,
size_t  pos = (size_t)npos 
) const
inline
size_t commore::String::rfind ( Char  c,
size_t  pos = (size_t)npos 
) const
inline
size_t commore::String::size ( ) const
inline
Returns
string length
void String::splice ( String str)

Swap string content

String String::substr ( size_t  pos = 0,
size_t  n = (size_t)npos 
) const
void String::swap ( String str)

Swap string content

Int commore::String::to_int ( ) const
bool commore::String::validate_range ( size_t  pos,
size_t *  len 
) const
inline

Check that interval is a substring

Parameters
posinterval start position
leninterval length
Returns
true if interval is in string
Remarks
this methode should be private
long String::write ( CommBuffer buffer) const
long String::write_xml ( OBStream o) const

Friends And Related Function Documentation

friend class Iterator
friend

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