libosmscout  0.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules
utf8helper::UTF8String Class Reference

#include <utf8helper.h>

Public Member Functions

UTF8StringAppend (codepoint u, utf8helper::Transform func=utf8helper::TransformNop)
 Add character to the string. More...
 
UTF8StringAppend (const storage_type &data, utf8helper::Transform func=utf8helper::TransformNop)
 Add characters to the string. More...
 
void Clear ()
 Clears the contents of the string and makes it null. More...
 
const storage_type & Data () const
 Returns the characters contained in this string. More...
 
bool Empty () const
 
bool Insert (size_t pos, codepoint u, utf8helper::Transform func=utf8helper::TransformNop)
 Insert the character u at the position pos. More...
 
size_t Insert (size_t pos, const storage_type &data, utf8helper::Transform func=utf8helper::TransformNop)
 Insert characters at the position pos. More...
 
UTF8Stringoperator<< (char cc)
 A convenience method for writeByte(char) More...
 
codepoint operator[] (size_t pos) const
 Returns the character at the position pos. More...
 
size_t RawSize () const
 Returns the number of bytes of this string. More...
 
bool Remove (size_t pos, size_t n=1)
 Remove n character from the position pos. More...
 
void Reserve (size_t sz)
 Attempts to allocate memory for at least sz characters. More...
 
size_t Size () const
 Return the number of character of this string. More...
 
std::string Substr (size_t pos, size_t n=(-1)) const
 Returns a std::string object with the substring of n characters of this string, starting at the position pos. More...
 
std::string ToStdString () const
 Returns a std::string object with the data contained in this string. More...
 
UTF8StringTransform (const std::string &text, utf8helper::Transform)
 Transform and assign the text to the string. More...
 
UTF8StringTransform (utf8helper::Transform)
 Apply transformation to the string. More...
 
 UTF8String ()
 Contructs empty UTF8String object with transformation nop. More...
 
 UTF8String (const std::string &text)
 Contructs UTF8String object containing the text. More...
 
 UTF8String (const std::string &text, utf8helper::Transform)
 Contructs UTF8String object containing the text with specified transformation. More...
 
 UTF8String (const UTF8String &)=default
 
 UTF8String (utf8helper::Transform)
 Contructs empty UTF8String object with the specified transformation. More...
 
void WriteByte (char cc)
 Push one more byte into this string. More...
 

Constructor & Destructor Documentation

◆ UTF8String() [1/5]

utf8helper::UTF8String::UTF8String ( )

Contructs empty UTF8String object with transformation nop.

◆ UTF8String() [2/5]

utf8helper::UTF8String::UTF8String ( const std::string &  text)
explicit

Contructs UTF8String object containing the text.

References utf8helper::Parser::func, and Transform().

◆ UTF8String() [3/5]

utf8helper::UTF8String::UTF8String ( utf8helper::Transform  func)
explicit

Contructs empty UTF8String object with the specified transformation.

◆ UTF8String() [4/5]

utf8helper::UTF8String::UTF8String ( const std::string &  text,
utf8helper::Transform  func 
)

Contructs UTF8String object containing the text with specified transformation.

References Transform().

◆ UTF8String() [5/5]

utf8helper::UTF8String::UTF8String ( const UTF8String )
default

Member Function Documentation

◆ Append() [1/2]

UTF8String & utf8helper::UTF8String::Append ( codepoint  u,
utf8helper::Transform  func = utf8helper::TransformNop 
)

Add character to the string.

Parameters
u
transformfunction = nop
Returns
this

References utf8helper::_u_string(), utf8helper::Parser::Continue, utf8helper::Parser::Done, utf8helper::Parser::Error, utf8helper::Parser::run, utf8helper::Parser::u, and utf8helper::Parser::u_size.

Referenced by Append().

◆ Append() [2/2]

UTF8String & utf8helper::UTF8String::Append ( const storage_type &  data,
utf8helper::Transform  func = utf8helper::TransformNop 
)

Add characters to the string.

Parameters
data
transformfunction = nop
Returns
this

References Append().

◆ Clear()

void utf8helper::UTF8String::Clear ( )

Clears the contents of the string and makes it null.

References utf8helper::Parser::Reset().

Referenced by Transform().

◆ Data()

const storage_type& utf8helper::UTF8String::Data ( ) const
inline

Returns the characters contained in this string.

Returns
the list of characters

◆ Empty()

bool utf8helper::UTF8String::Empty ( ) const
inline
Returns
true if the string has no characters, otherwise returns false

◆ Insert() [1/2]

bool utf8helper::UTF8String::Insert ( size_t  pos,
codepoint  u,
utf8helper::Transform  func = utf8helper::TransformNop 
)

Insert the character u at the position pos.

Parameters
pos
u
transformfunction = nop
Returns
false if pos is out of bound or the character is invalid, otherwise returns true

References utf8helper::_u_string(), utf8helper::Parser::Continue, utf8helper::Parser::Done, utf8helper::Parser::Error, utf8helper::Parser::run, Size(), utf8helper::Parser::u, and utf8helper::Parser::u_size.

Referenced by Insert().

◆ Insert() [2/2]

size_t utf8helper::UTF8String::Insert ( size_t  pos,
const storage_type &  data,
utf8helper::Transform  func = utf8helper::TransformNop 
)

Insert characters at the position pos.

Parameters
pos
data
transformfunction = nop
Returns
the number of valid character inserted

References Insert(), n, and Size().

◆ operator<<()

UTF8String& utf8helper::UTF8String::operator<< ( char  cc)
inline

A convenience method for writeByte(char)

Parameters
cc
Returns
this
See also
writeByte(char)

References WriteByte().

◆ operator[]()

codepoint utf8helper::UTF8String::operator[] ( size_t  pos) const
inline

Returns the character at the position pos.

Parameters
pos
Returns
the character

◆ RawSize()

size_t utf8helper::UTF8String::RawSize ( ) const
inline

Returns the number of bytes of this string.

Returns
count of bytes

◆ Remove()

bool utf8helper::UTF8String::Remove ( size_t  pos,
size_t  n = 1 
)

Remove n character from the position pos.

Parameters
pos
n
Returns
false if pos is out of bound, otherwise returns true

References utf8helper::_u_size(), n, and Size().

◆ Reserve()

void utf8helper::UTF8String::Reserve ( size_t  sz)
inline

Attempts to allocate memory for at least sz characters.

Parameters
sz

Referenced by Transform().

◆ Size()

size_t utf8helper::UTF8String::Size ( ) const
inline

Return the number of character of this string.

Returns
count of characters

Referenced by Insert(), and Remove().

◆ Substr()

std::string utf8helper::UTF8String::Substr ( size_t  pos,
size_t  n = (-1) 
) const

Returns a std::string object with the substring of n characters of this string, starting at the position pos.

Parameters
pos
n
Returns
the std::string object

References utf8helper::_u_string(), and n.

◆ ToStdString()

std::string utf8helper::UTF8String::ToStdString ( ) const

Returns a std::string object with the data contained in this string.

Returns
the std::string object

References utf8helper::_u_string().

Referenced by utf8helper::UTF8Capitalize(), utf8helper::UTF8Normalize(), utf8helper::UTF8ToLower(), utf8helper::UTF8ToUpper(), and utf8helper::UTF8Transliterate().

◆ Transform() [1/2]

UTF8String & utf8helper::UTF8String::Transform ( const std::string &  text,
utf8helper::Transform  func 
)

Transform and assign the text to the string.

Parameters
text
transformfunction
Returns
this

References Clear(), utf8helper::Parser::func, Reserve(), and WriteByte().

◆ Transform() [2/2]

UTF8String & utf8helper::UTF8String::Transform ( utf8helper::Transform  func)

Apply transformation to the string.

Parameters
transformfunction
Returns
this

References utf8helper::_u_string(), Clear(), utf8helper::Parser::func, and WriteByte().

Referenced by UTF8String().

◆ WriteByte()

void utf8helper::UTF8String::WriteByte ( char  cc)

Push one more byte into this string.

A character is added to this string on each valid sequence.

Parameters
cc
See also
operator <<(char)

References utf8helper::Parser::Continue, utf8helper::Parser::Done, utf8helper::Parser::Error, utf8helper::Parser::run, utf8helper::Parser::u, and utf8helper::Parser::u_size.

Referenced by operator<<(), and Transform().


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