CString Class Reference 系统

#include <string.h>

Inheritance diagram for CString:

详细描述

Class to store 8 bit strings. The CString stores 8 bit characters. Any characters are legal, including 0C (for example CString ("\0\0\0\0", 4) will result in a CString with length 4). CStrings are reference-counted objects. This means that as long as you copy and do not modify strings they are just referenced. The first modification breaks the link and it becomes a unique new object. For error handling see String .

Public Types

using  ConstIterator = BaseIterator < const CString , false >
using  Iterator = ConstIterator
using  ValueType = Char

公共成员函数

  MAXON_DEFAULT_REFERENCE_CONSTRUCTORS ( CString , Reference)
  CString (const Char *str, Int count=-1)
  CString ( Int count, Char fillChar)
  CString (const Block < const Char > &str)
  CString (const String &str, const StringEncodingRef &stringEncoding= GetUtf8DefaultEncoder ())
Char   operator[] ( Int pos) const
MAXON_ATTRIBUTE_FORCE_INLINE CStringInterface::CharPtr  operator[] ( Int position)
ConstIterator   Begin () const
ConstIterator   End () const
Bool   IsEmpty () const
Bool   IsPopulated () const
CString operator+= (const CString &str)
  operator const Char * () const
  operator Block< const Char > () const

静态公共成员函数

static const CString GetLineEnd ()

私有成员函数

void  operator-> () const

Member Typedef Documentation

◆  ConstIterator

using ConstIterator = BaseIterator <const CString , false>

◆  Iterator

using Iterator = ConstIterator

◆  ValueType

using ValueType = Char

构造函数 & 析构函数文档编制

◆  CString() [1/4]

CString ( const Char str ,
Int   count = -1  
)
explicit

Constructor for Char array. If you have static Char strings use "..."_cs instead.

参数
[in] str C string block.
[in] count Number of characters, -1 to auto detect the length of the string (search for the first 0).

◆  CString() [2/4]

CString ( Int   count ,
Char   fillChar  
)
explicit

Constructor to create a string with a specific length and a default character.

参数
[in] count Number of characters of the new string.
[in] fillChar Character to fill the string with.

◆  CString() [3/4]

CString ( const Block < const Char > &  str )
explicit

Constructor from a Char Block . If you have static strings use "..."_cs instead.

参数
[in] str Char block, for example a BaseArray<Char> .

◆  CString() [4/4]

CString ( const String str ,
const StringEncodingRef &  stringEncoding = GetUtf8DefaultEncoder()  
)
explicit

Constructor to create a CString from a String . The lower byte of each character will be copied, whereas the upper byte will be discarded.

参数
[in] str Unicode string.
[in] stringEncoding Encoding for the string. By default utf8 is selected. If a nullptr is passed the data is truncated to Char and no conversion takes place.

成员函数文档编制

◆  MAXON_DEFAULT_REFERENCE_CONSTRUCTORS()

MAXON_DEFAULT_REFERENCE_CONSTRUCTORS ( CString   ,
Reference   
)

◆  operator[]() [1/2]

Char operator[] ( Int   pos ) const

Index operator to access single characters of the string.

参数
[in] pos Position within the string the first character starts with an index of 0. If the position is out of boundaries 0 will be returned.
返回
Utf32Char for read (right of =), Utf32Char& for write (left of =).

◆  operator[]() [2/2]

MAXON_ATTRIBUTE_FORCE_INLINE CStringInterface::CharPtr operator[] ( Int   position )

Index operator to access single characters of the string.

参数
[in] position Position within the string the first character starts with an index of 0. if the position is out of boundaries no changes will be made.
返回
Utf32Char for read (right of =), Utf32Char& for write (left of =).

◆  Begin()

ConstIterator Begin ( ) const

◆  End()

ConstIterator End ( ) const

◆  IsEmpty()

Bool IsEmpty ( ) const

Returns if the string length is zero.

返回
True if the string doesn't contain any character, or if it is a nullptr.

◆  IsPopulated()

Bool IsPopulated ( ) const

Returns if the string contains any characters.

返回
True if the string contains any character.

◆  operator+=()

CString & operator+= ( const CString str )

◆  operator const Char *()

operator const Char * ( ) const

Conversion to const Char*, returns the pointer to a null-terminated C string.

返回
Pointer to null terminated C string (can never be a nullptr).

◆  operator Block< const Char >()

operator Block < const Char > ( ) const

Converts this CString to a block of characters. The null-terminator isn't part of the block.

返回
Block of characters of this CString .

◆  GetLineEnd()

static const CString & GetLineEnd ( )
static

Returns a string with the platform specific line ending.

返回
String containing the line ending ("\r\n" or "\r").

◆  operator->()

void operator-> ( ) const
private