CStringInterface Class Reference 系统

#include <string.h>

Inheritance diagram for CStringInterface:

详细描述

Class to store ASCII strings. CString stores 8 bit characters. Any characters are legal, including 0C (strings are not null-terminated). 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.

@MAXON_ANNOTATION{refclass=false}

公共成员函数

MAXON_METHOD Result < Int GetCStringBlock (const Block < Char > &buffer) const
MAXON_METHOD Result < void >  GetCStringAppendArray (const NonConstArray < Char > &array) const
MAXON_METHOD Result < void >  SetCString (const Char *buffer, Int count=-1)
MAXON_FUNCTION Result < void >  SetCString (const Block < const Char > &buffer)
MAXON_METHOD Result < BaseArray < Char > >  GetCString () const
String   ToString (const FormatStatement *formatStatement=nullptr) const
MAXON_METHOD Block < const Char GetInternalData () const
-  Public Member Functions inherited from StringTemplate< CStringInterface, CString, Char >
MAXON_METHOD Int   GetLength () const
MAXON_METHOD Result < void >  Init ( Int count=0, Char fillChar=0)
MAXON_METHOD Result < void >  Shrink ()
MAXON_METHOD Result < void >  Append (const CStringInterface *str)
MAXON_METHOD Result < void >  Append (const Char *str, Int len)
MAXON_FUNCTION Result < void >  AppendChar ( Char v)
MAXON_METHOD Int   FindIndex (const CStringInterface *str, StringPosition start=0) const
MAXON_METHOD Int   FindIndex ( Char ch, StringPosition start=0) const
MAXON_METHOD Int   FindLastIndex (const CStringInterface *str, StringPosition start= StringEnd ()) const
MAXON_METHOD Int   FindLastIndex ( Char ch, StringPosition start= StringEnd ()) const
MAXON_METHOD Int   FindUpperIndex (const CStringInterface *str, StringPosition start=0) const
MAXON_METHOD Int   FindLastUpperIndex (const CStringInterface *str, StringPosition start= StringEnd ()) const
MAXON_METHOD Result < void >  Erase ( StringPosition position, StringCount count)
MAXON_METHOD Result < void >  Insert ( StringPosition position, const CStringInterface *str, StringPosition strStart=0, StringCount strCount= StringEnd ())
MAXON_METHOD Result < void >  Insert ( StringPosition position, Char ch)
MAXON_METHOD CStringInterface GetPart ( StringPosition start, StringCount count) const
MAXON_METHOD CStringInterface ToUpper () const
MAXON_METHOD CStringInterface ToLower () const
MAXON_METHOD COMPARERESULT   ComparePart (const CStringInterface *str, STRINGCOMPARISON 模式, StringPosition position, StringCount count) const
MAXON_FUNCTION COMPARERESULT   比较 (const CStringInterface *str, STRINGCOMPARISON mode= STRINGCOMPARISON::UNICODE_NUMBERS ) const
MAXON_FUNCTION Bool   IsEqual (const CStringInterface *str) const
MAXON_METHOD HashInt   GetHashCode () const
MAXON_METHOD void  SetChar ( Int pos, Char ch)
MAXON_METHOD Char   GetChar ( Int pos) const
MAXON_FUNCTION Result < Float64 ToFloat64 ( STRINGCONVERSION flags=STRINGCONVERSION::NONE) const
MAXON_FUNCTION Result < Float32 ToFloat32 ( STRINGCONVERSION flags=STRINGCONVERSION::NONE) const
MAXON_FUNCTION Result < Float ToFloat ( STRINGCONVERSION flags=STRINGCONVERSION::NONE) const
MAXON_FUNCTION Result < Int64 ToInt64 ( STRINGCONVERSION flags=STRINGCONVERSION::NONE) const
MAXON_FUNCTION Result < Int32 ToInt32 ( STRINGCONVERSION flags=STRINGCONVERSION::NONE) const
MAXON_FUNCTION Result < Int ToInt ( STRINGCONVERSION flags=STRINGCONVERSION::NONE) const
MAXON_FUNCTION Result < UInt64 ToUInt64 ( STRINGCONVERSION flags=STRINGCONVERSION::NONE) const
MAXON_FUNCTION Result < UInt32 ToUInt32 ( STRINGCONVERSION flags=STRINGCONVERSION::NONE) const
MAXON_FUNCTION Result < UInt ToUInt ( STRINGCONVERSION flags=STRINGCONVERSION::NONE) const
MAXON_FUNCTION CStringInterface AppendInt ( Int32 v)
MAXON_FUNCTION CStringInterface AppendInt ( Int64 v)
MAXON_FUNCTION CStringInterface AppendUInt ( UInt32 v)
MAXON_FUNCTION CStringInterface AppendUInt ( UInt64 v)
MAXON_METHOD Result < void >  GetUtf32 ( Utf32CharBuffer &stringData) const
MAXON_METHOD Result < void >  TrimLeft ()
MAXON_METHOD Result < void >  TrimRight ()
MAXON_METHOD Result < void >  Split (const CString &splitSymbol, Bool trim, const ValueReceiver < const CString & > &parts) const
MAXON_METHOD Result < Int 替换 ( Char find, Char replace)
MAXON_METHOD Result < Int 替换 (const CString &find, const CString &replace)
MAXON_METHOD Result < Int 替换 ( Char find, const CString &replace)
MAXON_FUNCTION Bool   Find (const CString &str, Int *pos, StringPosition start=0) const
MAXON_FUNCTION Bool   Find ( Char ch, Int *pos, StringPosition start=0) const
MAXON_FUNCTION Bool   FindLast (const CString &str, Int *pos, StringPosition start= StringEnd ()) const
MAXON_FUNCTION Bool   FindLast ( Char ch, Int *pos, StringPosition start= StringEnd ()) const
MAXON_FUNCTION Bool   FindUpper (const CString &str, Int *pos, StringPosition start=0) const
MAXON_FUNCTION Bool   FindLastUpper (const CString &str, Int *pos, StringPosition start= StringEnd ()) const
MAXON_FUNCTION CStringInterface GetLeftPart ( StringPosition start) const
MAXON_FUNCTION CStringInterface GetRightPart ( StringPosition start) const
MAXON_FUNCTION Bool   StartsWith ( Char ch) const
MAXON_FUNCTION Bool   StartsWith (const CString &str) const
MAXON_FUNCTION Bool   EndsWith ( Char ch) const
MAXON_FUNCTION Bool   EndsWith (const CString &str) const
MAXON_FUNCTION Result < void >  Trim ()

静态公共成员函数

static const MAXON_METHOD CString GetAndCacheConstString (const Char *chr, Int len)
-  Static Public Member Functions inherited from StringTemplate< CStringInterface, CString, Char >
static MAXON_FUNCTION CString   FloatToString ( Float32 value, Int charsBeforeComma=STRING_DYNAMIC_DIGITS, Int digitsAfterComma=-3, Bool exponent=false, Char fillChar=' ')
static MAXON_FUNCTION CString   FloatToString ( Float64 value, Int charsBeforeComma=STRING_DYNAMIC_DIGITS, Int digitsAfterComma=-3, Bool exponent=false, Char fillChar=' ')
static MAXON_FUNCTION CString   IntToString ( Int32 v)
static MAXON_FUNCTION CString   IntToString ( Int64 v)
static MAXON_FUNCTION CString   UIntToString ( UInt32 v)
static MAXON_FUNCTION CString   UIntToString ( UInt64 v)
static MAXON_FUNCTION CString   MemorySizeToString ( Int64 v, Bool mebibytes=true)
static MAXON_FUNCTION CString   HexToString ( UInt32 v, Bool prefix0x=true)
static MAXON_FUNCTION CString   HexToString ( UInt64 v, Bool prefix0x=true)
static MAXON_FUNCTION CString   PointerToString (const void *v)

私有成员函数

  MAXON_INTERFACE_NONVIRTUAL ( CStringInterface , MAXON_REFERENCE_COPY_ON_WRITE , "net.maxon.interface.cstring")

Additional Inherited Members

-  Public Types inherited from StringTemplate< CStringInterface, CString, Char >
using  Super = StringTemplate

成员函数文档编制

◆  MAXON_INTERFACE_NONVIRTUAL()

MAXON_INTERFACE_NONVIRTUAL ( CStringInterface   ,
MAXON_REFERENCE_COPY_ON_WRITE   ,
"net.maxon.interface.cstring"   
)
private

◆  GetCStringBlock()

MAXON_METHOD Result < Int > GetCStringBlock ( const Block < Char > &  buffer ) const

Copies the string into 'buffer'.

参数
[in,out] buffer Block describing the buffer. A \0 byte will be appended to the string in any case.
返回
The length of the corresponding 8-bit string for the given encoding. the \0 byte is not counted.

◆  GetCStringAppendArray()

MAXON_METHOD Result <void> GetCStringAppendArray ( const NonConstArray < Char > &  array ) const

Appends the string to the given array .

参数
[in,out] array Array to be filled with the string. The string is NOT terminated with a \0 byte.
返回
OK on success.

◆  SetCString() [1/2]

MAXON_METHOD Result <void> SetCString ( const Char buffer ,
Int   count = -1  
)

Initializes the string with a given 8-bit Char string (the CString will contain an exact copy of the buffer, there's no encoding to a different character set).

参数
[out] buffer Pointer to the 8-bit character string.
[in] count Number of valid characters in the buffer, a value of -1 automatically detects the string length by searching for the first \0 character, otherwise count is relevant and not \0.
返回
OK on success.

◆  SetCString() [2/2]

MAXON_FUNCTION Result <void> SetCString ( const Block < const Char > &  buffer )

Initializes the string with a given 8-bit Char string with the given encoding.

参数
[out] buffer Block with an 8-bit character string.
返回
OK on success.

◆  GetCString()

MAXON_METHOD Result < BaseArray < Char > > GetCString ( ) const

Returns a copy of the C string in a new memory block. If a string is empty this function returns a string with a terminating null character.

返回
BaseArray<Char> with the encoded string. The string is \0 - terminated, so the last character in the array is \0.

◆  ToString()

String ToString ( const FormatStatement formatStatement = nullptr ) const

Returns a readable string of the content.

参数
[in] formatStatement Nullptr or additional formatting instruction. Currently no additional formatting instructions are supported.
返回
The converted result.

◆  GetInternalData()

MAXON_METHOD Block <const Char > GetInternalData ( ) const

Returns the internal character array.

返回
Block describing the internal character buffer. The data is read only!

◆  GetAndCacheConstString()

static const MAXON_METHOD CString & GetAndCacheConstString ( const Char chr ,
Int   len  
)
static

Internal . Caches a static constant string and returns a maxon::CString .