Xpace
Xpace::String Class Reference

A string, Unicode UTF-16 and reference-counted. More...

#include <types.h>

Public Member Functions

 String (const utf8_t *s, size_t len=0)
 Construct a String from a UTF-8 array of 8-bit chars. More...
 
 String (const utf16_t *s, size_t len=0)
 Construct a String from a UTF-16 array of 16-bit chars. More...
 
 String (const char *s, size_t len=0)
 Construct a String from an array of 8-bit chars. More...
 
 String (const String8 &s)
 Construct a String from a String8. More...
 
size_t getLength () const
 
utf8_ttoUtf8 (utf8_t *buf, size_t bufLen) const
 convert a String into a (null-terminated) UTF-8 string, writing it into a buffer More...
 
std::vector< utf8_ttoUtf8 () const
 convert a String into a (null-terminated) UTF-8 string, writing it into a vector More...
 
const utf16_ttoUtf16 () const
 
 String (const QString &s)
 Convert a QString to a String. More...
 
 operator const QString () const
 Convert a (const) String into a (const) QString. More...
 
 operator QString ()
 Convert a String into a QString. More...
 
 String (const std::string &s)
 Convert a std::string to a String param s the std::string. More...
 
 String (const std::wstring &s)
 Convert a std::string to a String param s the std::string. More...
 
std::string toStdString () const
 Convert a String into a std::string return the std::string. More...
 
std::wstring toStdWString () const
 Convert a String into a std::string return the std::string. More...
 
 String ()
 Construct an empty string. More...
 
 String (const String &)
 
Stringoperator= (const String &)
 
 ~String ()
 
void clear ()
 Make a string empty. More...
 
int64 getInt (bool *ok=0) const
 Get a number from a (base-10) string. More...
 
bool operator! () const
 
bool operator== (const String &rhs) const
 
bool operator!= (const String &rhs) const
 
bool operator< (const String &rhs) const
 
bool matchNoCase (const String &rhs) const
 
Stringoperator+= (utf16_t rhs)
 concatenate rhs to this string More...
 
Stringoperator+= (const String &rhs)
 concatenate rhs to this string More...
 

Static Public Member Functions

static String setNum (int64 n)
 Make a string from a number. More...
 

Friends

class access
 

Detailed Description

A string, Unicode UTF-16 and reference-counted.

Definition at line 269 of file types.h.

Constructor & Destructor Documentation

Xpace::String::String ( const utf8_t s,
size_t  len = 0 
)

Construct a String from a UTF-8 array of 8-bit chars.

Parameters
sthe array of chars
lenif != 0, the length of the array; if 0, array is 0-terminated
Xpace::String::String ( const utf16_t s,
size_t  len = 0 
)

Construct a String from a UTF-16 array of 16-bit chars.

Parameters
sthe array of chars
lenif != 0, the length of the array; if 0, array is 0-terminated
Xpace::String::String ( const char *  s,
size_t  len = 0 
)

Construct a String from an array of 8-bit chars.

Parameters
sthe array of chars
lenif != 0, the length of the array; if 0, array is 0-terminated
Xpace::String::String ( const String8 s)

Construct a String from a String8.

Parameters
sthe String8
Xpace::String::String ( const QString &  s)

Convert a QString to a String.

Parameters
sthe source QString
Xpace::String::String ( const std::string &  s)

Convert a std::string to a String param s the std::string.

Xpace::String::String ( const std::wstring &  s)

Convert a std::string to a String param s the std::string.

Xpace::String::String ( )

Construct an empty string.

Xpace::String::String ( const String )
Xpace::String::~String ( )

Member Function Documentation

size_t Xpace::String::getLength ( ) const
Returns
the length of the string, in chars

Referenced by Xpace::DecimalFloat::DecimalFloat().

utf8_t* Xpace::String::toUtf8 ( utf8_t buf,
size_t  bufLen 
) const

convert a String into a (null-terminated) UTF-8 string, writing it into a buffer

Parameters
bufthe buffer into which to write
bufLenthe lemgth of the buffer
Returns
the buffer

Referenced by Xpace::MatchString< STR >::MatchString().

std::vector<utf8_t> Xpace::String::toUtf8 ( ) const

convert a String into a (null-terminated) UTF-8 string, writing it into a vector

const utf16_t* Xpace::String::toUtf16 ( ) const
Returns
the (null-terminated) UTF-16 representation of the string

Referenced by Xpace::DecimalFloat::DecimalFloat(), and Xpace::MatchString< STR >::MatchString().

Xpace::String::operator const QString ( ) const

Convert a (const) String into a (const) QString.

Returns
the QString
Xpace::String::operator QString ( )

Convert a String into a QString.

Returns
the QString
std::string Xpace::String::toStdString ( ) const

Convert a String into a std::string return the std::string.

std::wstring Xpace::String::toStdWString ( ) const

Convert a String into a std::string return the std::string.

String& Xpace::String::operator= ( const String )
void Xpace::String::clear ( )

Make a string empty.

static String Xpace::String::setNum ( int64  n)
static

Make a string from a number.

Parameters
nthe source number
Returns
the string

Referenced by Xpace::IndexList::CantOpenIndex::CantOpenIndex().

int64 Xpace::String::getInt ( bool ok = 0) const

Get a number from a (base-10) string.

Parameters
fillintrue if the string could be converted, false if not
Returns
value converted
bool Xpace::String::operator! ( ) const
Returns
true is String is empty
bool Xpace::String::operator== ( const String rhs) const
Returns
true if this String matches rhs
bool Xpace::String::operator!= ( const String rhs) const
inline
Returns
true if this String does not match rhs

Definition at line 398 of file types.h.

bool Xpace::String::operator< ( const String rhs) const
Returns
true if this String is less than rhs
bool Xpace::String::matchNoCase ( const String rhs) const
Returns
true if theis String matches rhs w/o case sensitvity
String& Xpace::String::operator+= ( utf16_t  rhs)

concatenate rhs to this string

Parameters
rhsthe char to concatenate
Returns
*this
String& Xpace::String::operator+= ( const String rhs)

concatenate rhs to this string

Parameters
rhsthe string to concatenate
Returns
*this

Friends And Related Function Documentation

friend class access
friend

Definition at line 427 of file types.h.


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

current as of Wed Jun 10 2026 12:00:06