GL Studio SCECpp Runtime Library
Public Member Functions | Static Public Attributes | Protected Attributes | Static Protected Attributes | List of all members
GlsString Class Reference

#include <gls_string.h>

Public Member Functions

 GlsString (const GlsUInt32 size)
 
virtual ~GlsString ()
 
const GlsCharGetString (void) const
 
void SetString (const GlsChar *const src)
 
GlsUInt32 GetLength (void) const
 

Static Public Attributes

static const GlsUInt32 MAX_STRING_SIZE = ( GLSUINT32_MAX - 3u )
 

Protected Attributes

GlsChar *const _charBuffer
 
const GlsUInt32 _size
 
GlsUInt32 _length
 

Static Protected Attributes

static const GlsChar STRING_TERMINATOR = '\0'
 

Detailed Description

This class is a simple fixed size string wrapper.

Invariant
_charBuffer != GLS_NULL, _size <= MAX_STRING_SIZE, _length <= _size, _charBuffer[ _length ] == GLS_STRING_TERMINATOR

Constructor & Destructor Documentation

GlsString::GlsString ( const GlsUInt32  size)

Constructor - create an instance

Parameters
sizenumber of characters to hold (not including NULL terminator)
Precondition
size <= MAX_STRING_SIZE
Postcondition
instance created, string is set to empty string
virtual GlsString::~GlsString ( )
virtual

Destructor - shall never be called

Precondition
none
Postcondition
none

Member Function Documentation

GlsUInt32 GlsString::GetLength ( void  ) const

Get the length of the string

Returns
length of string, number of characters before terminating NULL
Precondition
none
Postcondition
none
const GlsChar* GlsString::GetString ( void  ) const

Get a const pointer to the string

Returns
const char pointer to the string
Precondition
none
Postcondition
none
void GlsString::SetString ( const GlsChar *const  src)

Set string value

Parameters
srcnew desired value for string ( src != GLS_NULL )
Precondition
src != GLS_NULL
Postcondition
string is equal to src if buffer is large enough to hold src, else is equal to src truncated to fit in buffer

Member Data Documentation

GlsChar* const GlsString::_charBuffer
protected

NULL terminated string, buffer size = _size + 1, extra char for NULL terminator

GlsUInt32 GlsString::_length
protected

length of string contained in char buffer number of characters before terminating NULL

const GlsUInt32 GlsString::_size
protected

number of characters that can be held in _charBuffer not including NULL terminator

const GlsUInt32 GlsString::MAX_STRING_SIZE = ( GLSUINT32_MAX - 3u )
static

maximum number of characters that can be stored ( not including NULL terminator

const GlsChar GlsString::STRING_TERMINATOR = '\0'
staticprotected

string terminator (NULL character)