All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HSEP::StringTool Class Reference

Provides basic extensions on the stl string functionality. More...

#include <StringTool.h>

Static Public Member Functions

static ErrorCode split (char *pSourcePtr, const char *pSepLevelsPtr, StringDictionary &pDestRef)
 Split the given pSource string, expecting it has a two level separator, and order the parts inside a dictionary.
 
static ErrorCode split (string &pSourceRef, const string pSeparator, StringArray &pDestRef)
 Fast split processor using the stl string facilities.
 
static ErrorCode toHex (void *pSource, size_t pSize, string &pDestination)
 
static ErrorCode fromHex (string &pSource, void *pDestination, size_t pDestinationSize)
 
static ErrorCode ltrim (string &pStringRef)
 Eliminates all white space before the first non-white space in the provided string.
 
static ErrorCode drop (string &pStringRef, const char *pDropHead)
 Eliminates all string content after the occurrence of the pDropHead element.
 

Detailed Description

Provides basic extensions on the stl string functionality.

Definition at line 64 of file StringTool.h.

Member Function Documentation

ErrorCode HSEP::StringTool::drop ( string &  pStringRef,
const char *  pDropHead 
)
static

Eliminates all string content after the occurrence of the pDropHead element.

Parameters
pStringRef
pDropHead
Returns
EC::OK When the data has been processed without problems.
EC::IncompleteProcessing When the process was interrupted without a clear exit.

Definition at line 282 of file StringTool.cpp.

References HSEP::EC::IncompleteProcessing, and HSEP::EC::OK.

Referenced by HSEP::FileTool::retrieve().

+ Here is the caller graph for this function:

ErrorCode HSEP::StringTool::fromHex ( string &  pSource,
void *  pDestination,
size_t  pDestinationSize 
)
static
ErrorCode HSEP::StringTool::ltrim ( string &  pStringRef)
static

Eliminates all white space before the first non-white space in the provided string.

Parameters
pStringRef
Returns
EC::OK When the data has been processed without problems.
EC::IncompleteProcessing When the process was interrupted without a clear exit.

Definition at line 236 of file StringTool.cpp.

References HSEP::EC::IncompleteProcessing, and HSEP::EC::OK.

Referenced by HSEP::FileTool::retrieve().

+ Here is the caller graph for this function:

ErrorCode HSEP::StringTool::split ( char *  pSourcePtr,
const char *  pSepLevelsPtr,
StringDictionary pDestRef 
)
static

Split the given pSource string, expecting it has a two level separator, and order the parts inside a dictionary.

The two levels are defined as independent and different characters. The first one separates each ordered pair and the second one separates the key from the value. A typical value for pSepLevels would be ";=".

The present implementation defines that each key has a maximum of 128 characters. The present implementation defines that each value has a maximum of 512 characters.

Parameters
pSourcePtrWhere the data comes from
pSepLevelsPtrThe two level separator
pDestRefDictionary destination
Returns
EC::OK When the data has been processed without problems.
EC::IncompleteProcessing When the process was interrupted without a clear exit.
EC::Overflow When the key size or value sizes are longer than the given limit.

Definition at line 30 of file StringTool.cpp.

References HSEP::EC::BufferOverflow, HSEP::EC::IncompleteParameter, HSEP::EC::IncompleteProcessing, MAXTOKEN_SIZE, MAXVALUE_SIZE, HSEP::EC::OK, and HSEP::Dictionary< T >::put().

+ Here is the call graph for this function:

ErrorCode HSEP::StringTool::split ( string &  pSourceRef,
const string  pSeparator,
StringArray pDestRef 
)
static

Fast split processor using the stl string facilities.

Parameters
pSourceRefWhere the data comes from
pSeparatorA string using to split the pSource
pDestRefVector destination
Returns
EC::OK When the data has been processed without problems.
EC::IncompleteProcessing When the process was interrupted without a clear exit.

This split implementation differs from others in the sense that it calculates where could be the last possible position to find a separator. If we find a separator beyond that point, this would be the last separator.

This way, we only calculate the difference once, instead of one time for each cycle.

static const size_type npos = static_cast<size_type>(-1)

This works because natural overflow, becoming the biggest possible int number.

Definition at line 108 of file StringTool.cpp.

References HSEP::Array< T >::clear(), HSEP::EC::IncompleteProcessing, HSEP::EC::OK, and HSEP::Array< T >::push().

+ Here is the call graph for this function:

ErrorCode HSEP::StringTool::toHex ( void *  pSource,
size_t  pSize,
string &  pDestination 
)
static

Definition at line 172 of file StringTool.cpp.

References HSEP::HEXVALUES, and HSEP::EC::OK.


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