ZFFramework
Loading...
Searching...
No Matches
zft_zfstring< T_Char > Class Template Reference

low level string container More...

#include <zfstring.h>

Public Member Functions

 zft_zfstring (void)
 construct an empty string
 zft_zfstring (const zft_zfstring< T_Char > &s)
 copy content from another string
 zft_zfstring (const zft_zfstring< T_Char > &s, zfindex len)
 copy content from another string
 zft_zfstring (const zft_zfstring< T_Char > &s, zfindex pos, zfindex len)
 copy content from another string
 zft_zfstring (const T_Char *s)
 copy content from another string
 zft_zfstring (const T_Char *s, zfindex len)
 copy content from another string
 zft_zfstring (const T_Char *s, zfindex pos, zfindex len)
 copy content from another string
 zft_zfstring (const zft_zfnullT &dummy)
 construct empty string
void set (zfindex pos, T_Char c)
 change char at index
T_Char get (zfindex pos) const
 get char at index
void swap (zft_zfstring< T_Char > &ref)
 swap internal data without deep copy, designed for performance
zft_zfstring< T_Char > & append (T_Char c)
 append string
zft_zfstring< T_Char > & append (const zft_zfstring< T_Char > &s)
 append string
zft_zfstring< T_Char > & append (const zft_zfstring< T_Char > &s, zfindex len)
 append string
zft_zfstring< T_Char > & append (const zft_zfstring< T_Char > &s, zfindex offset, zfindex len)
 append string
zft_zfstring< T_Char > & append (const void *s, zfindex len=((zfindex) -1))
 append string
zft_zfstring< T_Char > & assign (const zft_zfstring< T_Char > &s)
 replace all content of the string
zft_zfstring< T_Char > & assign (const zft_zfstring< T_Char > &s, zfindex len)
 replace all content of the string
zft_zfstring< T_Char > & assign (const zft_zfstring< T_Char > &s, zfindex offset, zfindex len)
 replace all content of the string
zft_zfstring< T_Char > & assign (const void *s, zfindex len=((zfindex) -1))
 replace all content of the string
zft_zfstring< T_Char > & assign (const zft_zfnullT &dummy)
 replace all content of the string
zft_zfstring< T_Char > & insert (zfindex insertAt, const zft_zfstring< T_Char > &s)
 insert string
zft_zfstring< T_Char > & insert (zfindex insertAt, const void *s, zfindex len=((zfindex) -1))
 insert string
zft_zfstring< T_Char > & replace (zfindex replacePos, zfindex replaceLen, const zft_zfstring< T_Char > &s)
 replace string in range
zft_zfstring< T_Char > & replace (zfindex replacePos, zfindex replaceLen, const void *s, zfindex len=((zfindex) -1))
 replace string in range
const T_Char * cString (void) const
 access string value, see shared
zfindex length (void) const
 length of the string
zfbool isShared (void) const
 whether this string is created from shared
zfbool isEmpty (void) const
 true if empty
zfbool isEqual (const zft_zfstring< T_Char > &ref) const
 true if equal
zfbool isEqual (const T_Char *s) const
 true if equal
zfbool capacity (zfindex capacity)
 ensure the string's capacity (including tail '\0'), note the result capacity is not ensured same as requested one
zfindex capacity (void) const
 get current capacity (including tail '\0')
void capacityTrim (void)
 trim to a proper capacity to save memory
void remove (zfindex pos, zfindex len=((zfindex) -1))
 remove part of the string
void removeAll (void)
 remove all content of the string
zfint compare (const zft_zfstring< T_Char > &s) const
 compare with another string
zfint compare (const T_Char *s, zfindex len=((zfindex) -1)) const
 compare with another string
const void * buffer (void) const
 return internal buffer
void zfunsafe_bufferGiveUp (void *&ret, zfindex &length)
 give up the buffer's ownership and return the buffer, you must free it manually by zfunsafe_bufferFree
T_Char * zfunsafe_buffer (void)
 directly access internal writable buffer
void zfunsafe_length (zfindex length)
 directly modify the string's length
const zft_zfstring< T_Char > & sharedCopy (void) const
 see shared

Static Public Member Functions

static void zfunsafe_bufferFree (void *buf)
 free buffer returned by zfunsafe_bufferGiveUp
static const zft_zfstring< T_Char > & Empty (void)
 global null string ref for impl
static zft_zfstring< T_Char > shared (const void *sLiteral, zfindex length=((zfindex) -1))
 explicitly create from literal string

Detailed Description

template<typename T_Char>
class zft_zfstring< T_Char >

low level string container

Member Function Documentation

◆ shared()

template<typename T_Char>
zft_zfstring< T_Char > zft_zfstring< T_Char >::shared ( const void * sLiteral,
zfindex length = ((zfindex)-1) )
inlinestatic

explicitly create from literal string

note:

  • you must ensure the literal's life exceeds the returned string
  • zfstring use reference count to manage object, you must also ensure the literal's life acrossing all of the references

a shared string may not be null-terminated, but you must ensure it's safe for caller to access cString

isShared can be used to check whether it's shared, sharedCopy can be manually called to explicitly copy from shared


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