Ceylan::UnicodeString Class Reference

Encapsulates a Unicode string to facilitate its management. More...

#include <CeylanUnicode.h>

Inheritance diagram for Ceylan::UnicodeString:

Inheritance graph
[legend]
Collaboration diagram for Ceylan::UnicodeString:

Collaboration graph
[legend]

List of all members.

Public Types

enum  TextOutputFormat { rawText, html }
 Defines what text output formats for TextDisplayable instances are available. More...

Public Member Functions

 UnicodeString ()
 Constructs an empty Unicode string.
virtual ~UnicodeString () throw ()
 Virtual destructor.
virtual StringSize size () const
 Returns the number of characters in this Unicode string.
virtual UnicodeStringcopy (bool swap=false) const
 Creates a new Unicode string which is the copy of this Unicode string.
virtual void setFromLatin1 (const std::string &latin1String)
 Sets this string from the specified Latin-1 encoded string.
virtual void setFromUTF8 (const std::string &utf8String, StringSize characterCount)
 Sets this string from the specified UTF-8 encoded string.
virtual const std::string toString (Ceylan::VerbosityLevels level=Ceylan::high) const
 Returns an user-friendly description of the state of this object.

Static Public Member Functions

static Unicode ConvertFromLatin1 (Ceylan::Latin1Char latin1Char)
 Converts specified Latin-1 encoded character to Unicode.
static const std::string ToString (std::list< TextDisplayable * > displayables, Ceylan::VerbosityLevels level=Ceylan::high)
 Returns a user-friendly description of this list of pointers to text displayable instances.
static TextOutputFormat GetOutputFormat ()
 Returns the current overall text format to be used by TextDisplayable instances.
static void SetOutputFormat (TextOutputFormat newOutputFormat)
 Sets the current overall text format to be used by TextDisplayable instances.

Protected Member Functions

virtual void setCapacity (StringSize newSize)
 Sets the internal character buffer so that it has the specified capacity.

Protected Attributes

Unicode_buffer
 The buffer storing Unicode characters.

Static Protected Attributes

static TextOutputFormat _OutputFormat = rawText
 The text format to be used currently by TextDisplayable instances.

Private Member Functions

 UnicodeString (const UnicodeString &source)
 Copy constructor made private to ensure that it will never be called.
UnicodeStringoperator= (const UnicodeString &source)
 Assignment operator made private to ensure that it will never be called.


Detailed Description

Encapsulates a Unicode string to facilitate its management.

A first UTF-8 (Unicode Transformation Format-8) encoding support is provided as well.

UTF-8 is the default encoding for XML.

See also:
http://wikipedia.org/wiki/UTF-8

http://www.utf-8.com/

Note:
Unicode services still have to be tested.

Definition at line 68 of file CeylanUnicode.h.


Member Enumeration Documentation

Defines what text output formats for TextDisplayable instances are available.

Enumerator:
rawText 
html 

Definition at line 124 of file CeylanTextDisplayable.h.


Constructor & Destructor Documentation

UnicodeString::UnicodeString (  ) 

Constructs an empty Unicode string.

Definition at line 47 of file CeylanUnicode.cc.

Referenced by copy().

UnicodeString::~UnicodeString (  )  throw () [virtual]

Virtual destructor.

Definition at line 55 of file CeylanUnicode.cc.

References _buffer.

Ceylan::UnicodeString::UnicodeString ( const UnicodeString source  )  [private]

Copy constructor made private to ensure that it will never be called.

The compiler should complain whenever this undefined constructor is called, implicitly or not.


Member Function Documentation

Unicode UnicodeString::ConvertFromLatin1 ( Ceylan::Latin1Char  latin1Char  )  [static]

Converts specified Latin-1 encoded character to Unicode.

Definition at line 224 of file CeylanUnicode.cc.

UnicodeString & UnicodeString::copy ( bool  swap = false  )  const [virtual]

Creates a new Unicode string which is the copy of this Unicode string.

Ownership of the new string is transferred to the caller, which will have to deallocate it when not useful anymore.

Definition at line 90 of file CeylanUnicode.cc.

References _buffer, setCapacity(), size(), Ceylan::swapBytes(), and UnicodeString().

TextDisplayable::TextOutputFormat TextDisplayable::GetOutputFormat (  )  [static, inherited]

UnicodeString& Ceylan::UnicodeString::operator= ( const UnicodeString source  )  [private]

Assignment operator made private to ensure that it will never be called.

The compiler should complain whenever this undefined operator is called, implicitly or not.

void UnicodeString::setCapacity ( Ceylan::StringSize  newSize  )  [protected, virtual]

Sets the internal character buffer so that it has the specified capacity.

Note:
The memory is allocated but the content is undefined.

Definition at line 233 of file CeylanUnicode.cc.

References _buffer, and size().

Referenced by copy(), setFromLatin1(), and setFromUTF8().

void UnicodeString::setFromLatin1 ( const std::string &  latin1String  )  [virtual]

Sets this string from the specified Latin-1 encoded string.

Parameters:
latin1String the Latin-1 encoded string which will be copied and encoded in Unicode in this string.

Definition at line 132 of file CeylanUnicode.cc.

References _buffer, and setCapacity().

void UnicodeString::setFromUTF8 ( const std::string &  utf8String,
Ceylan::StringSize  characterCount 
) [virtual]

Sets this string from the specified UTF-8 encoded string.

Parameters:
utf8String the UTF-8 encoded string which will be copied and encoded in Unicode in this string.
size the number of characters encoded in the UTF-8 string (not the string size, since a UTF-8 character may be encoded in more than one byte).

Definition at line 150 of file CeylanUnicode.cc.

References _buffer, and setCapacity().

void TextDisplayable::SetOutputFormat ( TextOutputFormat  newOutputFormat  )  [static, inherited]

Sets the current overall text format to be used by TextDisplayable instances.

Parameters:
newOutputFormat the new output format.

Definition at line 72 of file CeylanTextDisplayable.cc.

References Ceylan::TextDisplayable::_OutputFormat.

Referenced by Ceylan::Log::LogHolder::LogHolder().

Ceylan::StringSize UnicodeString::size (  )  const [virtual]

Returns the number of characters in this Unicode string.

Definition at line 65 of file CeylanUnicode.cc.

References _buffer.

Referenced by copy(), setCapacity(), and toString().

const std::string TextDisplayable::ToString ( std::list< TextDisplayable * >  displayables,
Ceylan::VerbosityLevels  level = Ceylan::high 
) [static, inherited]

Returns a user-friendly description of this list of pointers to text displayable instances.

Parameters:
displayables a list of pointers to TextDisplayable instances/
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
toString, Ceylan::VerbosityLevels

Definition at line 45 of file CeylanTextDisplayable.cc.

References Ceylan::formatStringList().

const string UnicodeString::toString ( Ceylan::VerbosityLevels  level = Ceylan::high  )  const [virtual]

Returns an user-friendly description of the state of this object.

Parameters:
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
Ceylan::TextDisplayable

Implements Ceylan::TextDisplayable.

Definition at line 213 of file CeylanUnicode.cc.

References size().


Member Data Documentation

The buffer storing Unicode characters.

Definition at line 172 of file CeylanUnicode.h.

Referenced by copy(), setCapacity(), setFromLatin1(), setFromUTF8(), size(), and ~UnicodeString().

TextDisplayable::TextOutputFormat TextDisplayable::_OutputFormat = rawText [static, protected, inherited]

The text format to be used currently by TextDisplayable instances.

Note:
Defaults to raw text.

Definition at line 158 of file CeylanTextDisplayable.h.

Referenced by Ceylan::TextDisplayable::GetOutputFormat(), and Ceylan::TextDisplayable::SetOutputFormat().


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

Generated on Thu Jun 4 20:40:10 2009 for Ceylan by  doxygen 1.5.8