Clarisse 4.0 SP10 SDK  4.0.0.0.10
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Static Public Member Functions | List of all members
CoreString Class Reference
Inheritance diagram for CoreString:
CoreBasicString

Public Member Functions

 CoreString ()
 
 CoreString (const CoreString &str)
 
 CoreString (const CoreBasicString &str)
 
 CoreString (CoreString &&str)
 
 CoreString (const char *str, size_t size=CORE_INVALID_INDEX_64)
 
 ~CoreString ()
 
CoreStringoperator= (const CoreString &str)
 
CoreStringoperator= (const CoreBasicString &str)
 
CoreStringoperator= (CoreString &&str)
 
CoreStringoperator= (const char *str)
 
CoreStringoperator= (char c)
 
void set_data (const char *str, size_t size=CORE_INVALID_INDEX_64)
 
void clear ()
 
char & front ()
 
char & first ()
 
char & back ()
 
char & last ()
 
char & operator[] (unsigned int index)
 
void append (const char *str)
 
void append (const CoreString &str)
 
void append_number_with_unit (double number, bool short_scale=true)
 append a numeric value with a quantifier string unit (see CoreString::CountUnits) ex: 500000000 -> "500 millions"
 
void replace (char token, char replacement)
 Search for a character in the string and replace it with another.
 
void remove_occurences (char token)
 Remove all occurences of a character in string.
 
void remove_last ()
 
void make_title ()
 
void make_identifier ()
 
void upper_case ()
 
void lower_case ()
 
void camel_case ()
 
bool is_identifier () const
 returns true if the current string is an identifier-compliant string.
 
bool is_number () const
 returns true if the current string is a numeric value
 
CoreString replace (const CoreString &token, const CoreString &replacement, bool case_sensitive=true) const
 Search for a string token and replace it with replacement string token.
 
CoreString sub_string (unsigned int start, unsigned int length) const
 
CoreString get_title () const
 Builds and returns a "title string" from current string.
 
CoreString get_identifier () const
 Builds and returns an identifier-compliant string from current string.
 
CoreString get_upper_case () const
 Builds and returns an upper-case string from current string.
 
CoreString get_lower_case () const
 Builds and returns a lower-case string from current string.
 
CoreString get_camel_case () const
 Builds and returns a camel case string from current string.
 
CoreString get_trim () const
 Return a string without all white-space characters from the start and end of the current string.
 
CoreString get_trim_left () const
 Return a string without all white-space characters from the start of the current string.
 
CoreString get_trim_right () const
 Return a string without all white-space characters from the end of the current string.
 
size_t get_memory_size () const
 
size_t get_serial_size () const
 
bool serialize (CoreSerial &serial) const
 
bool deserialize (CoreSerial &serial)
 
CoreVector< CoreStringsplit (const CoreString &separator, bool explicit_output=false) const
 Split the string from the specified separators.
 
void split (const CoreString &separator, CoreVector< CoreString > &slist, bool explicit_output=false) const
 Split string into several strings each time a separator is found.
 
void split_word (const CoreString &separator, CoreVector< CoreString > &slist, bool remove_blank=true) const
 Split string into several strings, using a word separator (which can be a single character too).
 
CoreBasicStringIterator< false > begin (void)
 
CoreBasicStringIterator< false > end (void)
 
void shrink_to_fit (void)
 
size_t capacity (void) const noexcept
 
CoreStringoperator+= (const char *str)
 
CoreStringoperator+= (const CoreString &str)
 
CoreStringoperator+= (const CoreBasicString &str)
 
CoreStringoperator+= (const void *p)
 
CoreStringoperator+= (std::nullptr_t null)
 
CoreStringoperator+= (bool b)
 
CoreStringoperator+= (unsigned char uc)
 
CoreStringoperator+= (char c)
 
CoreStringoperator+= (short s)
 
CoreStringoperator+= (unsigned short us)
 
CoreStringoperator+= (int i)
 
CoreStringoperator+= (unsigned int ui)
 
CoreStringoperator+= (long l)
 
CoreStringoperator+= (unsigned long ul)
 
CoreStringoperator+= (long long ll)
 
CoreStringoperator+= (unsigned long long ull)
 
CoreStringoperator+= (float f)
 
CoreStringoperator+= (double d)
 
CoreStringoperator<< (const char *str)
 
CoreStringoperator<< (const CoreString &str)
 
CoreStringoperator<< (const CoreBasicString &str)
 
CoreStringoperator<< (const void *p)
 
CoreStringoperator<< (std::nullptr_t null)
 
CoreStringoperator<< (bool b)
 
CoreStringoperator<< (unsigned char uc)
 
CoreStringoperator<< (char c)
 
CoreStringoperator<< (short s)
 
CoreStringoperator<< (unsigned short us)
 
CoreStringoperator<< (int i)
 
CoreStringoperator<< (unsigned int ui)
 
CoreStringoperator<< (long l)
 
CoreStringoperator<< (unsigned long ul)
 
CoreStringoperator<< (long long ll)
 
CoreStringoperator<< (unsigned long long ull)
 
CoreStringoperator<< (float f)
 
CoreStringoperator<< (double d)
 
CoreString operator+ (const char *str) const
 
CoreString operator+ (const CoreString &str) const
 
CoreString operator+ (const CoreBasicString &str) const
 
CoreString operator+ (const void *p) const
 
CoreString operator+ (std::nullptr_t null) const
 
CoreString operator+ (bool b) const
 
CoreString operator+ (unsigned char uc) const
 
CoreString operator+ (char c) const
 
CoreString operator+ (short s) const
 
CoreString operator+ (unsigned short us) const
 
CoreString operator+ (int i) const
 
CoreString operator+ (unsigned int ui) const
 
CoreString operator+ (long l) const
 
CoreString operator+ (unsigned long ul) const
 
CoreString operator+ (long long ll) const
 
CoreString operator+ (unsigned long long ull) const
 
CoreString operator+ (float f) const
 
CoreString operator+ (double d) const
 
 operator bool () const
 
 operator char () const
 
 operator unsigned char () const
 
 operator short () const
 
 operator unsigned short () const
 
 operator int () const
 
 operator unsigned int () const
 
 operator long () const
 
 operator unsigned long () const
 
 operator long long () const
 
 operator unsigned long long () const
 
 operator float () const
 
 operator double () const
 
- Public Member Functions inherited from CoreBasicString
 CoreBasicString (void)
 
 CoreBasicString (const char *data, size_t length=CORE_INVALID_INDEX_64)
 
bool is_empty () const
 
unsigned int get_length () const
 
unsigned int get_count () const
 
unsigned int get_capacity () const
 
const char * get_data () const
 
const char & front () const
 
const char & first () const
 
const char & back () const
 
const char & last () const
 
const char & operator[] (unsigned int index) const
 
bool start_with (const CoreBasicString &str) const
 
bool end_with (const CoreBasicString &str) const
 
bool contains (const CoreBasicString &str) const
 
unsigned int count_occurences (char token) const
 
unsigned int find (const CoreBasicString &str, unsigned int start_index=0) const
 
unsigned int find (char str, unsigned int start_index=0) const
 
unsigned int rev_find (const CoreBasicString &str, unsigned int start_index=CORE_INVALID_INDEX) const
 
unsigned int rev_find (char c, unsigned int start_index=CORE_INVALID_INDEX) const
 
bool start_with (const char *str) const
 
bool end_with (const char *str) const
 
bool contains (const char *str) const
 
unsigned int find (const char *str, unsigned int start_index=0) const
 
unsigned int rev_find (const char *str, unsigned int start_index=CORE_INVALID_INDEX) const
 
CoreBasicStringIterator< true > begin (void) const
 
CoreBasicStringIterator< true > end (void) const
 
bool operator== (const CoreBasicString &str) const
 
bool operator== (const char *str) const
 
bool operator!= (const CoreBasicString &str) const
 
bool operator!= (const char *str) const
 
bool operator< (const CoreBasicString &str) const
 
bool operator< (const char *str) const
 

Static Public Member Functions

static CoreString join (const CoreBasicArray< CoreString > &strings, const CoreString &separator, bool keep_empty=false)
 
static const CoreStringget_null_string ()
 
static CoreString camel_case (const CoreString &name)
 
static CoreString before_first (const CoreString &str, char c)
 Returns the substring which is left to a separator in a string, starting at the begining.
 
static CoreString after_first (const CoreString &str, char c)
 Returns the substring which is right to a separator in a string, starting at the begining.
 
static CoreString before_last (const CoreString &str, char c)
 Returns the substring which is left to a separator in a string, starting at the end.
 
static CoreString after_last (const CoreString &str, char c)
 Returns the substring which is right to a separator in a string, starting at the end.
 
static void alpha_sort (CoreArray< CoreString > &array, bool sensitive_case=true)
 Sorts a CoreString array in increasing order.
 
static void alpha_sort (CoreVector< CoreString > &vector, bool sensitive_case=true)
 Sorts a CoreString vector in increasing order.
 
static void alpha_sort (CoreArray< CoreString * > &array, bool sensitive_case=true)
 
static void alpha_sort (CoreVector< CoreString * > &vector, bool sensitive_case=true)
 
static int compare (const CoreString &str1, const CoreString &str2)
 

Additional Inherited Members

- Static Public Attributes inherited from CoreBasicString
static constexpr unsigned int INVALID_INDEX = CORE_INVALID_INDEX
 For backward compatibility only. Please use CORE_INVALID_INDEX instead.
 
- Protected Member Functions inherited from CoreBasicString
constexpr CoreBasicString (const char *data, size_t length, unsigned int capacity)
 
- Protected Attributes inherited from CoreBasicString
char * m_data
 Pointer to the first element of the string.
 
unsigned int m_length
 The length of the string.
 
unsigned int m_capacity
 

Detailed Description

Full-feature null-terminated string class.

Constructor & Destructor Documentation

CoreString::CoreString ( )
inline

Empty constructor

CoreString::CoreString ( const CoreString str)
inline

Copy Constructor

CoreString::CoreString ( const CoreBasicString str)
inline

Copy Constructor

CoreString::CoreString ( CoreString &&  str)
inline

Move constructor.

CoreString::CoreString ( const char *  str,
size_t  size = CORE_INVALID_INDEX_64 
)
inline

Create a string from a C-style string. See set_data(const char *, size_t).

CoreString::~CoreString ( )

Destructor

Member Function Documentation

CoreString CoreString::after_first ( const CoreString str,
char  c 
)
static

Returns the substring which is right to a separator in a string, starting at the begining.

Parameters
strconst CoreString& string to search in
cconst char& separator
Returns
the substring if separator was found or full string if not
CoreString CoreString::after_last ( const CoreString str,
char  c 
)
static

Returns the substring which is right to a separator in a string, starting at the end.

Parameters
strconst CoreString& string to search in
cconst char& separator
Returns
the substring if separator was found or full string if not
void CoreString::alpha_sort ( CoreArray< CoreString > &  array,
bool  sensitive_case = true 
)
static

Sorts a CoreString array in increasing order.

Parameters
[in]arrayCoreString array
[in]sensitive_caseuse case sensitive compare or not
void CoreString::alpha_sort ( CoreVector< CoreString > &  vector,
bool  sensitive_case = true 
)
static

Sorts a CoreString vector in increasing order.

Parameters
[in]vectorCoreString vector
[in]sensitive_caseuse case sensitive compare or not
void CoreString::append ( const char *  str)
inline

Append a C-style string

void CoreString::append ( const CoreString str)
inline

Append another core string

void CoreString::append_number_with_unit ( double  number,
bool  short_scale = true 
)

append a numeric value with a quantifier string unit (see CoreString::CountUnits) ex: 500000000 -> "500 millions"

Parameters
[in]numbernumeric value to append
[in]short_scaleDepending of the region (USA or Europe), nomenclature differs. see: http://en.wikipedia.org/wiki/Names_of_large_numbers
char & CoreString::back ( )
inline

Get a reference to the last character. Asserts if the string is empty.

CoreString CoreString::before_first ( const CoreString str,
char  c 
)
static

Returns the substring which is left to a separator in a string, starting at the begining.

Parameters
strconst CoreString& string to search in
cconst char& separator
Returns
the substring if separator was found or full string if not
CoreString CoreString::before_last ( const CoreString str,
char  c 
)
static

Returns the substring which is left to a separator in a string, starting at the end.

Parameters
strconst CoreString& string to search in
cconst char& separator
Returns
the substring if separator was found or full string if not
CoreBasicStringIterator< false > CoreString::begin ( void  )
inline

Get a pointer to the beginning of the string. Asserts if the string is empty.

void CoreString::camel_case ( )

Transform the current to CamelCase. See camel_cast(const CoreString&)

CoreString CoreString::camel_case ( const CoreString name)
static

Build and return a CamelCase String from incoming string. Separators are '_' and ' '.

size_t CoreString::capacity ( void  ) const
inlinenoexcept

Returns the number of characters currently allocated (this takes the null terminator into account)

void CoreString::clear ( void  )

Clears string content.

CoreBasicStringIterator< false > CoreString::end ( void  )
inline

Get a pointer to the end of the string. Asserts if the string is empty.

char & CoreString::first ( )
inline

Same as front (don't ask me why...)

char & CoreString::front ( )
inline

Get a reference to the first character. Asserts if the string is empty.

CoreString CoreString::get_identifier ( ) const

Builds and returns an identifier-compliant string from current string.

See Also
CoreString::make_identifier
size_t CoreString::get_memory_size ( void  ) const
inline

Get the size in bytes of this instance

const CoreString & CoreString::get_null_string ( )
static

Returns a statically allocating empty string.

CoreString CoreString::get_title ( ) const

Builds and returns a "title string" from current string.

See Also
CoreString::make_title
CoreString CoreString::join ( const CoreBasicArray< CoreString > &  strings,
const CoreString separator,
bool  keep_empty = false 
)
static

Joins an array of strings into a single string with each string separated by the given separator.

Strings containing only with whitespace are not considered empty (because length > 0).

Parameters
stringsarray of strings, can contain empty values
separatorstring used as separator between each string of the array, can be a single character or even empty
keep_emptyif true, empty strings are preserved in the joined result
Returns
single string containing the joined result
char & CoreString::last ( )
inline

Same as back (don't ask me why...)

void CoreString::lower_case ( )

Transform the string to a LOWERCASE string.

void CoreString::make_identifier ( )

Modifies the current string to match the Identifier string restrictions: all characters must be either alphanumeric or '_'. Any other will be turned into '_' character.

void CoreString::make_title ( )

Transform a string to be used as a UI title. What this does is split the string on _ and space characters, capitalize the first letter of each word.

CoreString & CoreString::operator= ( const CoreString str)
inline

Assign another string

CoreString & CoreString::operator= ( const CoreBasicString str)
inline

Assign another string

CoreString & CoreString::operator= ( CoreString &&  str)
inline

Move assignment operator

CoreString & CoreString::operator= ( const char *  str)
inline

Assign a C-style string

CoreString & CoreString::operator= ( char  c)
inline

Assign a character

char & CoreString::operator[] ( unsigned int  index)
inline

Get a character by index

void CoreString::remove_last ( )

Remove the last character (does nothing if the string is empty)

void CoreString::remove_occurences ( char  token)

Remove all occurences of a character in string.

Parameters
[in]tokencharacter to look for
void CoreString::replace ( char  token,
char  replacement 
)

Search for a character in the string and replace it with another.

Parameters
[in]tokencharacter to look for
[in]replacementcharacter to replace token
CoreString CoreString::replace ( const CoreString token,
const CoreString replacement,
bool  case_sensitive = true 
) const

Search for a string token and replace it with replacement string token.

Parameters
[in]tokento search for
[in]replacementstring to replace token with
[in]case_sensitivespecifies if token search is case sensitive or not.
void CoreString::set_data ( const char *  str,
size_t  size = CORE_INVALID_INDEX_64 
)

Sets string data with incoming buffer and size. If the string has a null terminating character, you don't need to specify size. Otherwise you have to specify it, and in this case we'll automatically add the null terminating character.

void CoreString::shrink_to_fit ( void  )
inline

If the capacity of the string is greater than its actual size, the string will be reallocated to save the unused memory.

CoreVector< CoreString > CoreString::split ( const CoreString separator,
bool  explicit_output = false 
) const

Split the string from the specified separators.

Parameters
separatorcharacters that marks beginning and ending point of each new substrings (separator characters will be removed)
[in]explicit_outputspecifies if we also want the empty string parts in output
Returns
a list of substrings
void CoreString::split ( const CoreString separator,
CoreVector< CoreString > &  slist,
bool  explicit_output = false 
) const

Split string into several strings each time a separator is found.

Parameters
[in]separatorcontains separators. Separators are single characters.
[out]slistlist of strings resulting from split
[in]explicit_outputspecifies if we also want the empty string parts in output
void CoreString::split_word ( const CoreString separator,
CoreVector< CoreString > &  slist,
bool  explicit_output = true 
) const

Split string into several strings, using a word separator (which can be a single character too).

Parameters
[in]separatorto use to split the string
[out]slistoutgoing generated string list
[in]explicit_outputspecify if we want empty outputs at the begining or the end to show that a separator was found there, or an empty output in the middle when 2 occurences of separator are found successively. Example: [we are we] -> explicit_output false -> output(are) [we are we] -> explicit_output true -> output(empty,are,empty)
CoreString CoreString::sub_string ( unsigned int  start,
unsigned int  length 
) const

Return a sub-string of current string.

Parameters
[in]startstarting index
[in]startsub string string length
Returns
extracted substring
void CoreString::upper_case ( )

Transform the string to an UPPERCASE string.