libosmscout 1.1.1
Loading...
Searching...
No Matches
utf8helper::UTF8String Class Reference

#include <libosmscout/include/osmscout/util/utf8helper.h>

Public Member Functions

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

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.

◆ UTF8String() [3/5]

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

Contructs empty UTF8String object with the specified transformation.

◆ UTF8String() [4/5]

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

Contructs UTF8String object containing the text with specified transformation.

◆ 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

◆ 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

◆ Clear()

void utf8helper::UTF8String::Clear ( )

Clears the contents of the string and makes it null.

◆ 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

◆ 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

◆ operator<<()

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

A convenience method for writeByte(char)

Parameters
cc
Returns
this
See also
writeByte(char)

◆ 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

◆ Reserve()

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

Attempts to allocate memory for at least sz characters.

Parameters
sz

◆ Size()

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

Return the number of character of this string.

Returns
count of characters

◆ 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

◆ ToStdString()

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

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

Returns
the std::string object

◆ Transform() [1/2]

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

Transform and assign the text to the string.

Parameters
text
transformfunction
Returns
this

◆ Transform() [2/2]

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

Apply transformation to the string.

Parameters
transformfunction
Returns
this

◆ 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)

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