PixelLightAPI  .
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
PLCore::StringBuffer Class Reference

Abstract base class that contains the buffer for a string. More...

#include <StringBuffer.h>

Inheritance diagram for PLCore::StringBuffer:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual uint32 GetFormat () const =0
 Returns the internal string format.
virtual StringBufferASCIIGetASCII ()=0
 Returns an ASCII string buffer version of the current string.
virtual StringBufferUnicodeGetUnicode ()=0
 Returns an Unicode string buffer version of the current string.
virtual StringBufferUTF8GetUTF8 ()=0
 Returns an UTF8 string buffer version of the current string.
virtual uint32 GetNumOfBytes () const =0
 Returns the number of bytes the string buffer is using (excluding the terminating zero, NEVER 0!)
virtual StringBufferClone () const =0
 Returns a clone of this string buffer.
virtual StringBufferDuplicate ()=0
 Returns a duplicate of this string buffer.
virtual bool IsLessThan (const char szString[], uint32 nLength) const =0
 Compares this string and the given one lexicographically.
virtual bool IsLessThan (const wchar_t szString[], uint32 nLength) const =0
virtual bool IsGreaterThan (const char szString[], uint32 nLength) const =0
 Compares this string and the given one lexicographically.
virtual bool IsGreaterThan (const wchar_t szString[], uint32 nLength) const =0
virtual bool Compare (const char szString[], uint32 nLength, uint32 nPos, uint32 nCount) const =0
 Compare function (case sensitive)
virtual bool Compare (const wchar_t szString[], uint32 nLength, uint32 nPos, uint32 nCount) const =0
virtual bool CompareNoCase (const char szString[], uint32 nLength, uint32 nPos, uint32 nCount) const =0
 Compare function (case insensitive)
virtual bool CompareNoCase (const wchar_t szString[], uint32 nLength, uint32 nPos, uint32 nCount) const =0
virtual bool IsAlphabetic () const =0
 Determines whether the string is alphabetic or not.
virtual bool IsAlphaNumeric () const =0
 Determines whether the string is alpha-numeric or not.
virtual bool IsNumeric () const =0
 Determines whether the string is numeric.
virtual bool IsSubstring (const char szString[], uint32 nLength) const =0
 Checks whether the given string is a substring of this string or not.
virtual bool IsSubstring (const wchar_t szString[], uint32 nLength) const =0
virtual int IndexOf (const char szString[], uint32 nPos, uint32 nLength) const =0
 Returns the index of the substring if contained in this string.
virtual int IndexOf (const wchar_t szString[], uint32 nPos, uint32 nLength) const =0
virtual int LastIndexOf (const char szString[], int nPos, uint32 nLength) const =0
 Searches from backwards for the index of the substring within this string.
virtual int LastIndexOf (const wchar_t szString[], int nPos, uint32 nLength) const =0
virtual StringBufferGetSubstring (uint32 nPos, uint32 nCount) const =0
 Get a substring from the string.
virtual StringBufferToLower ()=0
 Change all characters to lower case.
virtual StringBufferToUpper ()=0
 Change all characters to upper case.
virtual StringBufferDelete (uint32 nPos, uint32 nCount)=0
 Delete a substring.
virtual StringBufferAppend (const char szString[], uint32 nCount)=0
 Appends a string at the end of the current string.
virtual StringBufferAppend (const wchar_t szString[], uint32 nCount)=0
virtual StringBufferInsert (const char szString[], uint32 nPos, uint32 nCount)=0
 Insert a string at a given location.
virtual StringBufferInsert (const wchar_t szString[], uint32 nPos, uint32 nCount)=0
virtual StringBufferReplace (char nOld, char nNew, uint32 &nReplaced)=0
 Replaces all occurrences of a character by another character.
virtual StringBufferReplace (wchar_t nOld, wchar_t nNew, uint32 &nReplaced)=0
virtual StringBufferReplace (const char szOld[], uint32 nOldLength, const char szNew[], uint32 nNewLength, uint32 &nReplaced)=0
 Replaces all occurrences of a substring by another string.
virtual StringBufferReplace (const wchar_t szOld[], uint32 nOldLength, const wchar_t szNew[], uint32 nNewLength, uint32 &nReplaced)=0
virtual StringBufferSetCharacter (uint32 nIndex, char nCharacter)=0
 Sets a character at the given index.
virtual StringBufferSetCharacter (uint32 nIndex, wchar_t nCharacter)=0
virtual StringBufferTrimLeading ()=0
 Removes all whitespace (tabs and spaces) at the beginning of the string.
virtual StringBufferTrimTrailing ()=0
 Removes all whitespace (tabs and spaces) at the end of the string.
virtual StringBufferRemoveLineEndings ()=0
 Removes line endings ("\r" or "\n") at the end of the string.

Protected Member Functions

 StringBuffer (uint32 nLength, uint32 nMaxLength, uint8 nType)
 Constructor.
virtual ~StringBuffer ()
 Destructor.
PLCORE_API uint32 GetLength () const
 Returns the length of the string buffer (excluding the terminating zero, NEVER 0!)
uint32 AddReference ()
 Increases the reference count.
uint32 Release ()
 Decreases the reference count.
uint32 GetRefCount () const
 Gets the current reference count.

Protected Attributes

uint32 m_nRefCount
uint32 m_nLength
uint32 m_nMaxLength
uint8 m_nType

Static Protected Attributes

static PLCORE_API
StringBufferManager 
Manager

Detailed Description

Abstract base class that contains the buffer for a string.

Note:
  • Implementation of the bridge design pattern, this class is the implementor of the 'String' abstraction

Constructor & Destructor Documentation

PLCore::StringBuffer::StringBuffer ( uint32  nLength,
uint32  nMaxLength,
uint8  nType 
) [protected]

Constructor.

Parameters:
[in]nLengthLength of the string buffer (excluding the terminating zero)
[in]nMaxLengthMaximum available length of the string buffer (excluding the terminating zero)
virtual PLCore::StringBuffer::~StringBuffer ( ) [protected, virtual]

Destructor.


Member Function Documentation

PLCORE_API uint32 PLCore::StringBuffer::GetLength ( ) const [protected]

Returns the length of the string buffer (excluding the terminating zero, NEVER 0!)

Returns:
Length of the string buffer, NEVER 0!
uint32 PLCore::StringBuffer::AddReference ( ) [protected]

Increases the reference count.

Returns:
Current reference count
uint32 PLCore::StringBuffer::Release ( ) [protected]

Decreases the reference count.

Returns:
Current reference count
uint32 PLCore::StringBuffer::GetRefCount ( ) const [protected]

Gets the current reference count.

Returns:
Current reference count
virtual uint32 PLCore::StringBuffer::GetFormat ( ) const [pure virtual]

Returns the internal string format.

Returns:
Internal string format (type: "String::EFormat")

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

Returns an ASCII string buffer version of the current string.

Returns:
ASCII string buffer version of the current string, NEVER a null pointer! (can be THIS)
Remarks:
This string buffer keeps a reference to the ASCII string buffer as long as this string buffer content is NOT manipulated. (ASCII version becomes 'dirty')

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

Returns an Unicode string buffer version of the current string.

Returns:
Unicode string buffer version of the current string, NEVER a null pointer! (can be THIS)
Remarks:
This string buffer keeps a reference to the Unicode string buffer as long as this string buffer content is NOT manipulated. (Unicode version becomes 'dirty')

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual StringBufferUTF8* PLCore::StringBuffer::GetUTF8 ( ) [pure virtual]

Returns an UTF8 string buffer version of the current string.

Returns:
UTF8 string buffer version of the current string, NEVER a null pointer! (can be THIS)
Remarks:
This string buffer keeps a reference to the UTF8 string buffer as long as this string buffer content is NOT manipulated. (UTF8 version becomes 'dirty')

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual uint32 PLCore::StringBuffer::GetNumOfBytes ( ) const [pure virtual]

Returns the number of bytes the string buffer is using (excluding the terminating zero, NEVER 0!)

Returns:
The number of bytes the string buffer is using, NEVER 0!

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual StringBuffer* PLCore::StringBuffer::Clone ( ) const [pure virtual]

Returns a clone of this string buffer.

Returns:
Clone of this string buffer, a null pointer on terrible error
Note:
  • The internal memory is also cloned
  • The clone has no initial reference

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual StringBuffer* PLCore::StringBuffer::Duplicate ( ) [pure virtual]

Returns a duplicate of this string buffer.

Returns:
Duplicate of this string buffer, a null pointer on terrible error
Remarks:
Unlike Clone(), this function ONLY returns a duplicate if the string buffer is shared between multiple strings, else a pointer to this string buffer is returned.

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual bool PLCore::StringBuffer::IsLessThan ( const char  szString[],
uint32  nLength 
) const [pure virtual]

Compares this string and the given one lexicographically.

Parameters:
[in]szStringString to compare with
[in]nLengthLength of the given string (excluding the terminating zero, if another format NEVER 0!)
Returns:
'true' if this string is less than the given one

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual bool PLCore::StringBuffer::IsLessThan ( const wchar_t  szString[],
uint32  nLength 
) const [pure virtual]
virtual bool PLCore::StringBuffer::IsGreaterThan ( const char  szString[],
uint32  nLength 
) const [pure virtual]

Compares this string and the given one lexicographically.

Parameters:
[in]szStringString to compare with
[in]nLengthLength of the given string (excluding the terminating zero, if another format NEVER 0!)
Returns:
'true' if this string is greater than the given one

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual bool PLCore::StringBuffer::IsGreaterThan ( const wchar_t  szString[],
uint32  nLength 
) const [pure virtual]
virtual bool PLCore::StringBuffer::Compare ( const char  szString[],
uint32  nLength,
uint32  nPos,
uint32  nCount 
) const [pure virtual]

Compare function (case sensitive)

Parameters:
[in]szStringString to compare with
[in]nLengthLength of the given string (excluding the terminating zero, NEVER 0!)
[in]nPosStart position within this string (MUST be valid!)
[in]nCountNumber of characters to compare, if 0 compare all characters
Returns:
'true' if the two strings are identical, else 'false'

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual bool PLCore::StringBuffer::Compare ( const wchar_t  szString[],
uint32  nLength,
uint32  nPos,
uint32  nCount 
) const [pure virtual]
virtual bool PLCore::StringBuffer::CompareNoCase ( const char  szString[],
uint32  nLength,
uint32  nPos,
uint32  nCount 
) const [pure virtual]

Compare function (case insensitive)

Parameters:
[in]szStringString to compare with
[in]nLengthLength of the given string (excluding the terminating zero, NEVER 0!)
[in]nPosStart position within this string (MUST be valid!)
[in]nCountNumber of characters to compare, if 0 compare all characters
Returns:
'true' if the two strings are identical, else 'false'

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual bool PLCore::StringBuffer::CompareNoCase ( const wchar_t  szString[],
uint32  nLength,
uint32  nPos,
uint32  nCount 
) const [pure virtual]
virtual bool PLCore::StringBuffer::IsAlphabetic ( ) const [pure virtual]

Determines whether the string is alphabetic or not.

Returns:
'true' if the string is alphabetic (or empty)
Note:
  • Examples: 'abc' is alphabetic while 'abc12' or 'ab-c' are not

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual bool PLCore::StringBuffer::IsAlphaNumeric ( ) const [pure virtual]

Determines whether the string is alpha-numeric or not.

Returns:
'true' if the string is alpha-numeric (or empty)
Note:
  • Examples: 'abc', '12' or 'abc12' are alpha-numeric while 'abc-12' is not

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual bool PLCore::StringBuffer::IsNumeric ( ) const [pure virtual]

Determines whether the string is numeric.

Returns:
'true' if the string is numeric (or empty)
Note:
  • Examples: '5' or '0' are numeric, while '5.1', '.', 'AD', '3D', '5,5', '5.2.8' are not

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual bool PLCore::StringBuffer::IsSubstring ( const char  szString[],
uint32  nLength 
) const [pure virtual]

Checks whether the given string is a substring of this string or not.

Parameters:
[in]szStringString to check
[in]nLengthLength of the given string (excluding the terminating zero, if another format NEVER 0!)
Returns:
'true', if the given string is a substring of this string, else 'false'

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual bool PLCore::StringBuffer::IsSubstring ( const wchar_t  szString[],
uint32  nLength 
) const [pure virtual]
virtual int PLCore::StringBuffer::IndexOf ( const char  szString[],
uint32  nPos,
uint32  nLength 
) const [pure virtual]

Returns the index of the substring if contained in this string.

Parameters:
[in]szStringString to check
[in]nPosStart position within this string (MUST be valid!)
[in]nLengthLength of the given string (excluding the terminating zero, if another format NEVER 0!)
Returns:
Index of the substring if found within this string, < 0 on error

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual int PLCore::StringBuffer::IndexOf ( const wchar_t  szString[],
uint32  nPos,
uint32  nLength 
) const [pure virtual]
virtual int PLCore::StringBuffer::LastIndexOf ( const char  szString[],
int  nPos,
uint32  nLength 
) const [pure virtual]

Searches from backwards for the index of the substring within this string.

Parameters:
[in]szStringString to check
[in]nPosStart position within this string (MUST be valid!)
[in]nLengthLength of the given string (excluding the terminating zero, NEVER 0!)
Returns:
Index of the substring if found within this string, < 0 on error

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual int PLCore::StringBuffer::LastIndexOf ( const wchar_t  szString[],
int  nPos,
uint32  nLength 
) const [pure virtual]
virtual StringBuffer* PLCore::StringBuffer::GetSubstring ( uint32  nPos,
uint32  nCount 
) const [pure virtual]

Get a substring from the string.

Parameters:
[in]nPosStart position (MUST be valid!)
[in]nCountNumber of characters to copy (MUST be valid!)
Returns:
The substring (without any initial reference)

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual StringBuffer* PLCore::StringBuffer::ToLower ( ) [pure virtual]

Change all characters to lower case.

Returns:
This string buffer if nothing was changed, else new string buffer (without any initial reference)

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual StringBuffer* PLCore::StringBuffer::ToUpper ( ) [pure virtual]

Change all characters to upper case.

Returns:
This string buffer if nothing was changed, else new string buffer (without any initial reference)

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual StringBuffer* PLCore::StringBuffer::Delete ( uint32  nPos,
uint32  nCount 
) [pure virtual]

Delete a substring.

Parameters:
[in]nPosStart position of deletion (MUST be valid!)
[in]nCountNumber of characters to delete (MUST be valid!)
Returns:
The new string buffer (without any initial reference)

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual StringBuffer* PLCore::StringBuffer::Append ( const char  szString[],
uint32  nCount 
) [pure virtual]

Appends a string at the end of the current string.

Parameters:
[in]szStringString to insert (NEVER empty!)
[in]nCountNumber of characters to add (MUST be valid!)
Returns:
The new string buffer (without any initial reference)

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual StringBuffer* PLCore::StringBuffer::Append ( const wchar_t  szString[],
uint32  nCount 
) [pure virtual]
virtual StringBuffer* PLCore::StringBuffer::Insert ( const char  szString[],
uint32  nPos,
uint32  nCount 
) [pure virtual]

Insert a string at a given location.

Parameters:
[in]szStringString to insert (NEVER empty!)
[in]nPosPosition at which to insert the string (MUST be valid!)
[in]nCountNumber of characters to add (MUST be valid!)
Returns:
The new string buffer (without any initial reference)
Note:
  • Due to the possibility to insert the new string at every position, the implementation is more complex as the one of "Append()", so, whenever possible use "Append()" for better performance!

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual StringBuffer* PLCore::StringBuffer::Insert ( const wchar_t  szString[],
uint32  nPos,
uint32  nCount 
) [pure virtual]
virtual StringBuffer* PLCore::StringBuffer::Replace ( char  nOld,
char  nNew,
uint32 &  nReplaced 
) [pure virtual]

Replaces all occurrences of a character by another character.

Parameters:
[in]nOldCharacter to be replaced
[in]nNewCharacter to replace with (nNew != nOld!!)
[out]nReplacedReceives the number of replaced characters (0 if new = old, MUST be set!)
Returns:
This string buffer if nothing was changed, else new string buffer (without any initial reference)

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual StringBuffer* PLCore::StringBuffer::Replace ( wchar_t  nOld,
wchar_t  nNew,
uint32 &  nReplaced 
) [pure virtual]
virtual StringBuffer* PLCore::StringBuffer::Replace ( const char  szOld[],
uint32  nOldLength,
const char  szNew[],
uint32  nNewLength,
uint32 &  nReplaced 
) [pure virtual]

Replaces all occurrences of a substring by another string.

Parameters:
[in]szOldSubstring to be replaced (NEVER empty!)
[in]nOldLengthLength of the old substring (MUST be valid!)
[in]szNewString to replace with (szNew != szOld, can be empty!)
[in]nNewLengthLength of the new substring (MUST be valid but can be 0!)
[out]nReplacedReceives the number of replaced characters (0 if new = old, MUST be set!)
Returns:
This string buffer if nothing was changed, else new string buffer (without any initial reference)

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual StringBuffer* PLCore::StringBuffer::Replace ( const wchar_t  szOld[],
uint32  nOldLength,
const wchar_t  szNew[],
uint32  nNewLength,
uint32 &  nReplaced 
) [pure virtual]
virtual StringBuffer* PLCore::StringBuffer::SetCharacter ( uint32  nIndex,
char  nCharacter 
) [pure virtual]

Sets a character at the given index.

Parameters:
[in]nIndexCharacter index (MUST be valid!)
[in]nCharacterCharacter to set at the given index
Returns:
This string buffer if nothing was changed, else new string buffer (without any initial reference)

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual StringBuffer* PLCore::StringBuffer::SetCharacter ( uint32  nIndex,
wchar_t  nCharacter 
) [pure virtual]
virtual StringBuffer* PLCore::StringBuffer::TrimLeading ( ) [pure virtual]

Removes all whitespace (tabs and spaces) at the beginning of the string.

Returns:
This string buffer if nothing was changed, else new string buffer, (without any initial reference) a null pointer if the string is now empty

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

virtual StringBuffer* PLCore::StringBuffer::TrimTrailing ( ) [pure virtual]

Removes all whitespace (tabs and spaces) at the end of the string.

Returns:
This string buffer if nothing was changed, else new string buffer, (without any initial reference) a null pointer if the string is now empty

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.

Removes line endings ("\r" or "\n") at the end of the string.

Returns:
This string buffer if nothing was changed, else new string buffer, (without any initial reference) a null pointer if the string is now empty

Implemented in PLCore::StringBufferASCII, PLCore::StringBufferUnicode, and PLCore::StringBufferUTF8.


Member Data Documentation

PLCORE_API StringBufferManager PLCore::StringBuffer::Manager [static, protected]

String buffer manager

Reference count - the "RefCount"-template isn't used because the string buffer manager requires some "special" access to this reference counter

uint32 PLCore::StringBuffer::m_nLength [protected]

Length of the string (excluding the terminating zero, NEVER 0!)

Maximum available length of the string (excluding the terminating zero, NEVER 0!)

uint8 PLCore::StringBuffer::m_nType [protected]

String buffer type for variable inspection in debug mode


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


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:51:16
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported