Clarisse 5.0 SP8 SDK  5.0.5.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
CoreBasicString Class Reference
Inheritance diagram for CoreBasicString:
CoreString CoreStringView

Public Member Functions

 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 Attributes

static constexpr unsigned int INVALID_INDEX = CORE_INVALID_INDEX
 For backward compatibility only. Please use CORE_INVALID_INDEX instead.
 

Protected Member Functions

constexpr CoreBasicString (const char *data, size_t length, unsigned int capacity)
 

Protected Attributes

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

Base interface for string manipulation. Only provides a read-only API. This class does not own the string data and all of its methods are const and do not provide any mean to modify its value.

For write operations, use CoreString. For constexpr strings, use CoreStringView.

Constructor & Destructor Documentation

CoreBasicString::CoreBasicString ( void  )
inline

Empty constructor

CoreBasicString::CoreBasicString ( const char *  data,
size_t  length = CORE_INVALID_INDEX_64 
)
inline

Public string literal constructor. See CoreBasicString(const char *, size_t, unsigned int)

constexpr CoreBasicString::CoreBasicString ( const char *  data,
size_t  length,
unsigned int  capacity 
)
explicitprotected

Private constructor used by the default CoreString constructor, and the CoreStringView constructors.

Parameters
dataThe string data. CoreBasicString will NOT own this data. Make sure it persists during the lifetime of this instance.
lengthNumber of characters in the string.
capacityWhen inherited by CoreString, set the capacity of the data buffer.

Member Function Documentation

const char & CoreBasicString::back ( ) const
inline

Get the last char. Asserts if the data is null.

CoreBasicStringIterator< true > CoreBasicString::begin ( void  ) const
inline

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

bool CoreBasicString::contains ( const CoreBasicString str) const
inline

Check if the string contains another one.

bool CoreBasicString::contains ( const char *  str) const
inline

See contains(const CoreBasicString&)

unsigned int CoreBasicString::count_occurences ( char  token) const

Count all occurences of a character in string

Parameters
tokencharacter to look for
CoreBasicStringIterator< true > CoreBasicString::end ( void  ) const
inline

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

bool CoreBasicString::end_with ( const CoreBasicString str) const
inline

Check if the string ends with another string.

bool CoreBasicString::end_with ( const char *  str) const
inline

See end_with(const CoreBasicString&)

unsigned int CoreBasicString::find ( const CoreBasicString str,
unsigned int  start_index = 0 
) const

Find a string starting at an optional index.

Parameters
strThe string to look for
start_indexOptional index where to start looking. 0 by default.
Returns
The index of the first occurence of str, or CORE_INVALID_INDEX if not found.
unsigned int CoreBasicString::find ( char  c,
unsigned int  start_index = 0 
) const

Find the first occurence of a given character.

Parameters
cThe character to look for
start_indexOptional index where to start looking. 0 by default. This will assert if start_index is out of range.
Returns
The index of the first occurence of str, or CORE_INVALID_INDEX if not found.
unsigned int CoreBasicString::find ( const char *  str,
unsigned int  start_index = 0 
) const
inline

See find(const CoreBasicString&, unsigned int)

const char & CoreBasicString::first ( ) const
inline

Same as front()

const char & CoreBasicString::front ( ) const
inline

Get the first char. Asserts if the data is null.

unsigned int CoreBasicString::get_capacity ( ) const
inline

Return the capacity (the size of the internal buffer)

unsigned int CoreBasicString::get_count ( ) const
inline

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

const char * CoreBasicString::get_data ( ) const
inline

Get the wrapped char pointer

unsigned int CoreBasicString::get_length ( ) const
inline

Get the length of the string

bool CoreBasicString::is_empty ( ) const
inline

Check if the string is empty or not

const char & CoreBasicString::last ( ) const
inline

Same as back()

bool CoreBasicString::operator!= ( const CoreBasicString str) const
inline

Inequality operator

bool CoreBasicString::operator!= ( const char *  str) const
inline

Inequality operator. str must be a null terminated string.

bool CoreBasicString::operator< ( const CoreBasicString str) const
inline

Less than comparison operator

bool CoreBasicString::operator< ( const char *  str) const
inline

Less than comparison operator. str must be a null terminated string.

bool CoreBasicString::operator== ( const CoreBasicString str) const
inline

Equality operator

bool CoreBasicString::operator== ( const char *  str) const
inline

Equality operator. str must be a null terminated string.

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

Get a character by index. This will assert if index is out of range, or if the data is null.

unsigned int CoreBasicString::rev_find ( const CoreBasicString str,
unsigned int  start_index = CORE_INVALID_INDEX 
) const

Same as find(), but search in a reverse order. start_index is a bit weird in this case: imagine that a sub string in the range [0, start_index[ is created, and then this sub string is searched for str in reverse order.

unsigned int CoreBasicString::rev_find ( char  c,
unsigned int  start_index = CORE_INVALID_INDEX 
) const

Reverse-find a character. Search will start at start_index and go to index 0.

unsigned int CoreBasicString::rev_find ( const char *  str,
unsigned int  start_index = CORE_INVALID_INDEX 
) const
inline

See rev_find(const CoreBasicString&, unsigned int)

bool CoreBasicString::start_with ( const CoreBasicString str) const
inline

Check if this string starts with another string.

bool CoreBasicString::start_with ( const char *  str) const
inline

See start_with(const CoreBasicString&)

Member Data Documentation

unsigned int CoreBasicString::m_capacity
protected

Ok, after m_length, we WILL have padding when inheriting CoreBasicString. And since most classes implementing CoreBasicString will need some other data (CoreString stores the buffer's capacity, string views and const strings store the hash) we create the member here to avoid wasting the space. So even if it's named m_capacity, it's not used in this class, and might be used to store what you need in child classes.