lestes::std::ucn_string Class Reference

String of ucn characters. More...

#include <ucn_string.hh>

Inheritance diagram for lestes::std::ucn_string:

basic_ucn_string List of all members.

Public Member Functions

 ucn_string (void)
 Creates empty string.
 ucn_string (const ucn_string &str)
 Creates ucn string, initializes with other string.
 ucn_string (const ucn_string &str, size_type pos, size_type n=npos)
 Creates string, initializes with part of string.
 ucn_string (size_type n, value_type c)
 Creates string, fills with character.
template<class InputIterator>
 ucn_string (InputIterator beg, InputIterator end)
 Creates ucn string, initializes with iterator.
 ucn_string (const char *data)
 Creates string, initializes with host characters.
lstring to_host_string (void) const
 Returns escaped host representation.

Detailed Description

String of ucn characters.

Represents string of ucn characters. The string is intended for storing internal representation of identifiers and literals. It shall not be used for ordinary messages or texts. All data is implicitly stored in superset of ASCII and has to be converted to host character set before displaying

Definition at line 56 of file ucn_string.hh.


Constructor & Destructor Documentation

lestes::std::ucn_string::ucn_string ( void   )  [inline]

Creates empty string.

Creates empty ucn string.

Definition at line 87 of file ucn_string.hh.

00087                                  :
00088         basic_ucn_string()
00089 {
00090 }

lestes::std::ucn_string::ucn_string ( const ucn_string str  )  [inline]

Creates ucn string, initializes with other string.

Creates ucn string, initializes with another string.

Parameters:
str The initializer.

Definition at line 96 of file ucn_string.hh.

00096                                                   :
00097         basic_ucn_string(str)
00098 {
00099 }

lestes::std::ucn_string::ucn_string ( const ucn_string str,
size_type  pos,
size_type  n = npos 
) [inline]

Creates string, initializes with part of string.

Creates ucn string, initializes with a portion of another string.

Parameters:
str The initializer.
pos The starting position in the initializer.
n The length of the portion.

Definition at line 107 of file ucn_string.hh.

00107                                                                               :
00108         basic_ucn_string(str,pos,n)
00109 {
00110 }

lestes::std::ucn_string::ucn_string ( size_type  n,
value_type  c 
) [inline]

Creates string, fills with character.

Creates ucn string, fills with characters.

Parameters:
n The length of the string.
c The character to fill.

Definition at line 117 of file ucn_string.hh.

00117                                                       :
00118         basic_ucn_string(n,c,allocator_type())
00119 {
00120 }

template<class InputIterator>
lestes::std::ucn_string::ucn_string ( InputIterator  beg,
InputIterator  end 
) [inline]

Creates ucn string, initializes with iterator.

Creates ucn string, initializes with iterator.

Parameters:
InputIterator The type of the iterator.
beg The starting position of the iterator.
end The ending position of the iterator.

Definition at line 129 of file ucn_string.hh.

00129                                                                  :
00130         basic_ucn_string(beg,end,allocator_type())
00131 {
00132 }

lestes::std::ucn_string::ucn_string ( const char *  s  )  [inline]

Creates string, initializes with host characters.

Creates ucn string from regular characters ASCIIZ string.

Parameters:
s The characters to convert.

Definition at line 138 of file ucn_string.hh.

References lestes::std::character::create_from_host().

00138                                           :
00139         basic_ucn_string(strlen(s),0xdeadbeef)
00140 {
00141         for (ucn_string::iterator it = this->begin(), end = this->end(); it != end; ++it, ++s) {
00142                 *it = character::create_from_host(*s);
00143         }
00144 }


Member Function Documentation

lstring lestes::std::ucn_string::to_host_string ( void   )  const

Returns escaped host representation.

Converts ucn string, escapes extended characters with backslash u or U. Any external characters are considered to have host encoding.

Returns:
Host string with representation of the ucn string.

Definition at line 47 of file ucn_string.cc.

References lestes::std::character::extract_value(), lestes::std::character::is_basic(), lestes::std::character::is_external(), lestes::std::character::to_host(), and u.

Referenced by lestes::std::operator<<().

00048 {
00049         hchar c;
00050         ucn u;
00051         ulint x;
00052 
00053         ::std::stringbuf sb;
00054         ::std::ostream os(&sb);
00055         
00056         for (ucn_string::const_iterator it = begin(), last = end(); it != last; ++it) {
00057                 u = *it;
00058 
00059                 if (character::is_external(u)) {
00060                         c = static_cast<hchar>(character::extract_value(u));
00061                         os << c;
00062                 } else if (character::is_basic(u)) {
00063                         c = character::to_host(u);
00064                         os << c;
00065                 } else {
00066                         x = character::extract_value(u);
00067                         if (x <= 0xFFFF) {
00068                                 os << "\\u" << ::std::hex << ::std::setfill('0') << ::std::setw(4) << x;
00069                         } else {
00070                                 os << "\\U" << ::std::hex << ::std::setfill('0') << ::std::setw(8) << x;
00071                         }
00072                 }
00073         }
00074 
00075         return sb.str();
00076 }


The documentation for this class was generated from the following files:
Generated on Mon Feb 12 18:26:00 2007 for lestes by doxygen 1.5.1-20070107