Honeycomb  0.1
Component-Model Framework
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
honey::String Class Reference

Unicode UTF-16 string class, wrapper around std::u16string. More...

#include <String.h>

Inheritance diagram for honey::String:
Inheritance graph
[legend]
Collaboration diagram for honey::String:
Collaboration graph
[legend]

Public Types

typedef vector< StringList
 List of strings. More...
 

Public Member Functions

 String ()=default
 
 String (const std::basic_string< Char > &str)
 Copy UTF-16 string. More...
 
 String (std::basic_string< Char > &&str)
 Move UTF-16 string. More...
 
 String (const std::string &str)
 Convert from UTF-8 string. More...
 
 String (const ostream &os)
 Convert from UTF-8 stringstream. More...
 
 String (const char *str, szt len=npos)
 Convert from UTF-8 string, pointer must not be null. More...
 
 String (szt n, char c)
 Convert from UTF-8 char repeated n times. More...
 
template<class T >
Stringoperator= (T &&rhs)
 Forwards to assign() More...
 
template<class T >
Stringoperator+= (T &&rhs)
 Forwards to append() More...
 
Stringoperator+= (Char rhs)
 
Stringoperator+= (char rhs)
 
Stringclear ()
 
Stringinsert (szt pos, const String &str, szt subpos=0, szt sublen=npos)
 
Stringinsert (szt pos, const std::string &str, szt subpos=0, szt sublen=npos)
 
Stringinsert (szt pos, const Char *str, szt subpos=0, szt sublen=npos)
 
Stringinsert (szt pos, const char *str, szt subpos=0, szt sublen=npos)
 
Stringinsert (szt pos, szt n, Char c)
 
Stringinsert (szt pos, szt n, char c)
 
iterator insert (const_iterator p, Char c)
 
iterator insert (const_iterator p, szt n, Char c)
 
template<class InputIterator >
iterator insert (const_iterator p, InputIterator first, InputIterator last)
 
Stringerase (szt pos=0, szt len=npos)
 
iterator erase (const_iterator position)
 
iterator erase (const_iterator first, const_iterator last)
 
Stringreplace (szt pos, szt len, const String &str, szt subpos=0, szt sublen=npos)
 
Stringreplace (const_iterator i1, const_iterator i2, const String &str)
 
template<class InputIterator >
Stringreplace (const_iterator i1, const_iterator i2, InputIterator first, InputIterator last)
 
szt copy (Char *s, szt len, szt pos=0) const
 
szt copy (char *s, szt len, szt pos=0) const
 
String substr (szt pos=0, szt len=npos) const
 
int icompare (const String &str) const
 Case-insensitive compare. More...
 
int icompare (szt pos, szt len, const String &str, szt subpos=0, szt sublen=npos) const
 
List split (const String &delim=String(1, ' '), szt pos=0, szt count=npos) const
 Split a string into a list of separate substrings delimited by delim. More...
 
String toLower () const
 Convert string to lower case. More...
 
String toUpper () const
 Convert string to upper case. More...
 
std::string u8 () const
 Convert to UTF-8 string. More...
 
 operator std::string () const
 Same as u8() More...
 
Stringappend (const String &str, szt subpos=0, szt sublen=npos)
 
Stringappend (const std::string &str, szt subpos=0, szt sublen=npos)
 
Stringappend (const Char *str, szt subpos=0, szt sublen=npos)
 
Stringappend (const char *str, szt subpos=0, szt sublen=npos)
 
Stringappend (szt n, Char c)
 
Stringappend (szt n, char c)
 
template<class InputIterator >
Stringappend (InputIterator first, InputIterator last)
 
Stringassign (const String &str, szt subpos=0, szt sublen=npos)
 
Stringassign (const std::string &str, szt subpos=0, szt sublen=npos)
 
Stringassign (const Char *str, szt subpos=0, szt sublen=npos)
 
Stringassign (const char *str, szt subpos=0, szt sublen=npos)
 
Stringassign (szt n, Char c)
 
Stringassign (szt n, char c)
 
template<class InputIterator >
Stringassign (InputIterator first, InputIterator last)
 

Static Public Member Functions

static String join (const List &strings, const String &delim=String(1, ' '), szt start=npos, szt end=npos)
 Join list into one string, separated by delim. More...
 

Friends

ostream & operator<< (ostream &os, const String &str)
 
istream & operator>> (istream &is, String &str)
 

Detailed Description

Unicode UTF-16 string class, wrapper around std::u16string.

length() returns the number of UTF-16 code units, not code points (characters or visual symbols). Some code points are 32-bit and thus are composed of 2 code units, called a surrogate pair or high / low surrogates.

Modeling the string as an array of fixed-length UTF-16 code units rather than variable-length code points is a trade-off for efficiency, as a large range of common characters can be represented by a single code unit.

Member Typedef Documentation

typedef vector<String> honey::String::List

List of strings.

Constructor & Destructor Documentation

honey::String::String ( )
default
honey::String::String ( const std::basic_string< Char > &  str)
inline

Copy UTF-16 string.

honey::String::String ( std::basic_string< Char > &&  str)
inline

Move UTF-16 string.

honey::String::String ( const std::string &  str)
inline

Convert from UTF-8 string.

honey::String::String ( const ostream &  os)
inline

Convert from UTF-8 stringstream.

honey::String::String ( const char *  str,
szt  len = npos 
)
inline

Convert from UTF-8 string, pointer must not be null.

honey::String::String ( szt  n,
char  c 
)
inline

Convert from UTF-8 char repeated n times.

Member Function Documentation

String& honey::String::append ( const String str,
szt  subpos = 0,
szt  sublen = npos 
)
inline

Forwards to insert() at back

String& honey::String::append ( const std::string &  str,
szt  subpos = 0,
szt  sublen = npos 
)
inline
String& honey::String::append ( const Char str,
szt  subpos = 0,
szt  sublen = npos 
)
inline
String& honey::String::append ( const char *  str,
szt  subpos = 0,
szt  sublen = npos 
)
inline
String& honey::String::append ( szt  n,
Char  c 
)
inline
String& honey::String::append ( szt  n,
char  c 
)
inline
template<class InputIterator >
String& honey::String::append ( InputIterator  first,
InputIterator  last 
)
inline
String& honey::String::assign ( const String str,
szt  subpos = 0,
szt  sublen = npos 
)
inline

Clears and forwards to append()

String& honey::String::assign ( const std::string &  str,
szt  subpos = 0,
szt  sublen = npos 
)
inline
String& honey::String::assign ( const Char str,
szt  subpos = 0,
szt  sublen = npos 
)
inline
String& honey::String::assign ( const char *  str,
szt  subpos = 0,
szt  sublen = npos 
)
inline
String& honey::String::assign ( szt  n,
Char  c 
)
inline
String& honey::String::assign ( szt  n,
char  c 
)
inline
template<class InputIterator >
String& honey::String::assign ( InputIterator  first,
InputIterator  last 
)
inline
String& honey::String::clear ( )
inline
szt honey::String::copy ( Char s,
szt  len,
szt  pos = 0 
) const
inline
szt honey::String::copy ( char *  s,
szt  len,
szt  pos = 0 
) const
inline
String& honey::String::erase ( szt  pos = 0,
szt  len = npos 
)
inline
iterator honey::String::erase ( const_iterator  position)
inline
iterator honey::String::erase ( const_iterator  first,
const_iterator  last 
)
inline
int honey::String::icompare ( const String str) const
inline

Case-insensitive compare.

int honey::String::icompare ( szt  pos,
szt  len,
const String str,
szt  subpos = 0,
szt  sublen = npos 
) const
String & honey::String::insert ( szt  pos,
const String str,
szt  subpos = 0,
szt  sublen = npos 
)
String & honey::String::insert ( szt  pos,
const std::string &  str,
szt  subpos = 0,
szt  sublen = npos 
)
String & honey::String::insert ( szt  pos,
const Char str,
szt  subpos = 0,
szt  sublen = npos 
)
String & honey::String::insert ( szt  pos,
const char *  str,
szt  subpos = 0,
szt  sublen = npos 
)
String& honey::String::insert ( szt  pos,
szt  n,
Char  c 
)
inline
String& honey::String::insert ( szt  pos,
szt  n,
char  c 
)
inline
iterator honey::String::insert ( const_iterator  p,
Char  c 
)
inline
iterator honey::String::insert ( const_iterator  p,
szt  n,
Char  c 
)
inline
template<class InputIterator >
iterator honey::String::insert ( const_iterator  p,
InputIterator  first,
InputIterator  last 
)
inline
String honey::String::join ( const List strings,
const String delim = String(1, ' '),
szt  start = npos,
szt  end = npos 
)
static

Join list into one string, separated by delim.

honey::String::operator std::string ( ) const
inline

Same as u8()

template<class T >
String& honey::String::operator+= ( T &&  rhs)
inline

Forwards to append()

String& honey::String::operator+= ( Char  rhs)
inline
String& honey::String::operator+= ( char  rhs)
inline
template<class T >
String& honey::String::operator= ( T &&  rhs)
inline

Forwards to assign()

String & honey::String::replace ( szt  pos,
szt  len,
const String str,
szt  subpos = 0,
szt  sublen = npos 
)
String& honey::String::replace ( const_iterator  i1,
const_iterator  i2,
const String str 
)
inline
template<class InputIterator >
String& honey::String::replace ( const_iterator  i1,
const_iterator  i2,
InputIterator  first,
InputIterator  last 
)
inline
String::List honey::String::split ( const String delim = String(1, ' '),
szt  pos = 0,
szt  count = npos 
) const

Split a string into a list of separate substrings delimited by delim.

String honey::String::substr ( szt  pos = 0,
szt  len = npos 
) const
inline
String honey::String::toLower ( ) const

Convert string to lower case.

String honey::String::toUpper ( ) const

Convert string to upper case.

std::string honey::String::u8 ( ) const
inline

Convert to UTF-8 string.

Friends And Related Function Documentation

ostream& operator<< ( ostream &  os,
const String str 
)
friend
istream& operator>> ( istream &  is,
String str 
)
friend

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