CrystalSpace

Public API Reference

csStringFast< LEN > Class Template Reference

Subclass of csStringBase that contains an internal buffer which is faster than the always dynamically allocated buffer of csStringBase. More...

#include <csutil/csstring.h>

Inheritance diagram for csStringFast< LEN >:

List of all members.

Public Member Functions

 csStringFast (unsigned char c)
 Create a csStringFast object from a single unsigned character.
 csStringFast (char c)
 Create a csStringFast object from a single signed character.
 csStringFast (const wchar_t *src, size_t _length)
 Create a csStringBase object from a wide string, given the length.
 csStringFast (const wchar_t *src)
 Create a csString object from a null-terminated wide string.
 csStringFast (const char *src, size_t _length)
 Create a csStringFast object from a C string, given the length.
 csStringFast (const char *src)
 Create a csStringFast object from a null-terminated C string.
 csStringFast (const csStringFast &copy)
 Copy constructor.
 csStringFast (const csStringBase &copy)
 Copy constructor.
 csStringFast (size_t Length)
 Create a csStringFast object and reserve space for at least Length characters.
 csStringFast ()
 Create an empty csStringFast object.
virtual char * Detach ()
 Detach the low-level null-terminated C-string buffer from the csString object.
virtual void Free ()
 Free the memory allocated for the string.
virtual size_t GetCapacity () const
 Return the current capacity, not including the space for the implicit null terminator.
virtual char const * GetData () const
 Get a pointer to the null-terminated character array.
template<typename T >
const csStringFastoperator= (T const &s)
 Assign a formatted value to this string.
const csStringFastoperator= (const csStringBase &copy)
 Assign a value to this string.
virtual void ShrinkBestFit ()
 Set string buffer capacity to hold exactly the current content.
virtual ~csStringFast ()
 Destroy the csStringFast.

Protected Member Functions

virtual char * GetDataMutable ()
 Get a pointer to the null-terminated character array.
virtual void SetCapacityInternal (size_t NewSize, bool soft)
 Set the buffer to hold NewSize bytes.

Protected Attributes

char minibuff [LEN]
 Internal buffer; used when capacity fits within LEN bytes.
size_t miniused
 Amount of minibuff allocated by SetCapacityInternal(); not necessarily same as Size.

Detailed Description

template<int LEN = 36>
class csStringFast< LEN >

Subclass of csStringBase that contains an internal buffer which is faster than the always dynamically allocated buffer of csStringBase.

Definition at line 1005 of file csstring.h.


Constructor & Destructor Documentation

template<int LEN = 36>
csStringFast< LEN >::csStringFast (  )  [inline]

Create an empty csStringFast object.

Definition at line 1049 of file csstring.h.

template<int LEN = 36>
csStringFast< LEN >::csStringFast ( size_t  Length  )  [inline]

Create a csStringFast object and reserve space for at least Length characters.

Definition at line 1054 of file csstring.h.

template<int LEN = 36>
csStringFast< LEN >::csStringFast ( const csStringBase copy  )  [inline]

Copy constructor.

Definition at line 1059 of file csstring.h.

template<int LEN = 36>
csStringFast< LEN >::csStringFast ( const csStringFast< LEN > &  copy  )  [inline]

Copy constructor.

Definition at line 1064 of file csstring.h.

template<int LEN = 36>
csStringFast< LEN >::csStringFast ( const char *  src  )  [inline]

Create a csStringFast object from a null-terminated C string.

Definition at line 1069 of file csstring.h.

template<int LEN = 36>
csStringFast< LEN >::csStringFast ( const char *  src,
size_t  _length 
) [inline]

Create a csStringFast object from a C string, given the length.

Definition at line 1074 of file csstring.h.

template<int LEN = 36>
csStringFast< LEN >::csStringFast ( const wchar_t *  src  )  [inline]

Create a csString object from a null-terminated wide string.

Definition at line 1078 of file csstring.h.

template<int LEN = 36>
csStringFast< LEN >::csStringFast ( const wchar_t *  src,
size_t  _length 
) [inline]

Create a csStringBase object from a wide string, given the length.

Definition at line 1081 of file csstring.h.

template<int LEN = 36>
csStringFast< LEN >::csStringFast ( char  c  )  [inline]

Create a csStringFast object from a single signed character.

Definition at line 1085 of file csstring.h.

template<int LEN = 36>
csStringFast< LEN >::csStringFast ( unsigned char  c  )  [inline]

Create a csStringFast object from a single unsigned character.

Definition at line 1088 of file csstring.h.

template<int LEN = 36>
virtual csStringFast< LEN >::~csStringFast (  )  [inline, virtual]

Destroy the csStringFast.

Definition at line 1091 of file csstring.h.


Member Function Documentation

template<int LEN = 36>
virtual char* csStringFast< LEN >::Detach (  )  [inline, virtual]

Detach the low-level null-terminated C-string buffer from the csString object.

Returns:
The low-level null-terminated C-string buffer, or zero if this string represents a null-pointer. See the class description for a discussion about how and when the string will represent a null-pointer.
Remarks:
The caller of this function becomes the owner of the returned string buffer and is responsible for destroying it via `delete[]' when no longer needed.

Reimplemented from csStringBase.

Definition at line 1133 of file csstring.h.

template<int LEN = 36>
virtual void csStringFast< LEN >::Free (  )  [inline, virtual]

Free the memory allocated for the string.

Remarks:
Following a call to this method, invocations of GetData() and 'operator char const*' will return a null pointer (until some new content is added to the string).

Reimplemented from csStringBase.

Definition at line 1131 of file csstring.h.

template<int LEN = 36>
virtual size_t csStringFast< LEN >::GetCapacity (  )  const [inline, virtual]

Return the current capacity, not including the space for the implicit null terminator.

Reimplemented from csStringBase.

Definition at line 1104 of file csstring.h.

template<int LEN = 36>
virtual char const* csStringFast< LEN >::GetData (  )  const [inline, virtual]

Get a pointer to the null-terminated character array.

Returns:
A C-string pointer to the null-terminated character array; or zero if the string represents a null-pointer.
Remarks:
See the class description for a discussion about how and when the string will represent a null-pointer.

Reimplemented from csStringBase.

Definition at line 1101 of file csstring.h.

template<int LEN = 36>
virtual char* csStringFast< LEN >::GetDataMutable (  )  [inline, protected, virtual]

Get a pointer to the null-terminated character array.

Returns:
A C-string pointer to the null-terminated character array; or zero if the string represents a null-pointer.
Remarks:
See the class description for a discussion about how and when the string will represent a null-pointer.
Warning:
This returns a non-const pointer, so use this function with care. Call this only when you need to modify the string content. External clients are never allowed to directly modify the internal string buffer, which is why this function is not public.

Reimplemented from csStringBase.

Definition at line 1042 of file csstring.h.

template<int LEN = 36>
template<typename T >
const csStringFast& csStringFast< LEN >::operator= ( T const &  s  )  [inline]

Assign a formatted value to this string.

Reimplemented from csStringBase.

Definition at line 1099 of file csstring.h.

template<int LEN = 36>
const csStringFast& csStringFast< LEN >::operator= ( const csStringBase copy  )  [inline]

Assign a value to this string.

Reimplemented in csString.

Definition at line 1094 of file csstring.h.

template<int LEN = 36>
virtual void csStringFast< LEN >::SetCapacityInternal ( size_t  NewSize,
bool  soft 
) [inline, protected, virtual]

Set the buffer to hold NewSize bytes.

If soft is true it means the buffer can be rounded up to reduce the number of allocations needed.

Reimplemented from csStringBase.

Definition at line 1020 of file csstring.h.

template<int LEN = 36>
virtual void csStringFast< LEN >::ShrinkBestFit (  )  [inline, virtual]

Set string buffer capacity to hold exactly the current content.

Returns:
Reference to itself.
Remarks:
If the string length is greater than zero, then the buffer's capacity will be adjusted to exactly that size. If the string length is zero, then this is equivalent to an invocation of Free(), which means that GetData() and 'operator char const*' will return a null pointer after reclamation.

Reimplemented from csStringBase.

Definition at line 1107 of file csstring.h.


Member Data Documentation

template<int LEN = 36>
char csStringFast< LEN >::minibuff[LEN] [protected]

Internal buffer; used when capacity fits within LEN bytes.

Definition at line 1009 of file csstring.h.

template<int LEN = 36>
size_t csStringFast< LEN >::miniused [protected]

Amount of minibuff allocated by SetCapacityInternal(); not necessarily same as Size.

This is analogous to MaxSize in csStringBase. We need it to determine if minibuff was ever used in order to return NULL if not (to emulate the NULL returned by csStringBase when no buffer has been allocated). We also use minibuff to emulate GetCapacity(), which is a predicate of several memory management methods, such as ExpandIfNeeded().

Definition at line 1018 of file csstring.h.


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

Generated for Crystal Space 2.1 by doxygen 1.6.1