Xspf::Toolbox Namespace Reference


Functions

XML_Char * newAndCopy (XML_Char const *source)
void deleteNewAndCopy (XML_Char **dest, XML_Char const *src)
void deleteNewAndCopy (XML_Char const *&dest, bool &destOwnership, XML_Char const *source, bool sourceCopy)
template<class T >
T const * getSetNull (T const *&dest)
void copyIfOwned (XML_Char const *&dest, bool &ownDest, XML_Char const *source, bool ownSource)
void freeIfOwned (XML_Char const *&dest, bool ownDest)
XML_Char * makeAbsoluteUri (XML_Char const *sourceUri, XML_Char const *baseUri)
XML_Char * makeRelativeUri (XML_Char const *sourceUri, XML_Char const *baseUri)
bool isUri (XML_Char const *text)
bool isAbsoluteUri (XML_Char const *text)
bool extractInteger (XML_Char const *text, int inclusiveMinimum, int *output)
bool isWhiteSpace (XML_Char const *text, int numChars)
void cutOffWhiteSpace (XML_Char const *input, int inputNumChars, XML_Char const *&blackSpaceStart, int &blackSpaceNumChars)
void trimString (std::basic_string< XML_Char > &target)

Detailed Description

Provides common helper functions.


Function Documentation

void Xspf::Toolbox::copyIfOwned ( XML_Char const *&  dest,
bool &  ownDest,
XML_Char const *  source,
bool  ownSource 
)

Copies a string's content if owned or just it's address if not.

Parameters:
dest Reference of destination string
ownDest Reference of destination owner flag
source Source string
ownSource Source owner flag

void Xspf::Toolbox::cutOffWhiteSpace ( XML_Char const *  input,
int  inputNumChars,
XML_Char const *&  blackSpaceStart,
int &  blackSpaceNumChars 
)

Cuts off whitespace at head and tail. The source string is not modified so this more is a detection function.

Parameters:
input Source text
inputNumChars Length of source in characters
blackSpaceStart Pointer to first non-white character
blackSpaceNumChars Length of characters until whitespace tail
Since:
1.0.0rc1

void Xspf::Toolbox::deleteNewAndCopy ( XML_Char const *&  dest,
bool &  destOwnership,
XML_Char const *  source,
bool  sourceCopy 
)

Replaces the string in dest by a duplicate of the string in src (using new() not malloc()). The old string is deleted. If destOwnership is false the old string is not deleted. If sourceCopy is false only source's pointer is copied, not the string.

Parameters:
dest Destination text
destOwnership Destination ownership flag
source Source text
sourceCopy Source copy flag

void Xspf::Toolbox::deleteNewAndCopy ( XML_Char **  dest,
XML_Char const *  src 
)

Replaces the string in *dest by a duplicate of the string in src (using new() not malloc()). The old string is deleted.

Parameters:
dest Destination text
src Source text

bool Xspf::Toolbox::extractInteger ( XML_Char const *  text,
int  inclusiveMinimum,
int *  output 
)

Extracts an integer from text.

Parameters:
text Text
inclusiveMinimum Inclusive minimum
output Integer storage destination
Returns:
Valid integer less or equal inclusiveMinimum flag
Since:
1.0.0rc1

void Xspf::Toolbox::freeIfOwned ( XML_Char const *&  dest,
bool  ownDest 
)

Deletes the text behind dest if owned and non-NULL. NOTE: dest is not set to NULL after

Parameters:
dest Reference of string to delete
ownDest Owner flag, false will prevent deletion

T const* Xspf::Toolbox::getSetNull ( T const *&  dest  )  [inline]

Sets a pointer to NULL and returns the original value. This helper is used for stealing memory.

Parameters:
dest Destination
Returns:
Old value

Definition at line 129 of file XspfToolbox.h.

bool Xspf::Toolbox::isAbsoluteUri ( XML_Char const *  text  ) 

Checks wether text is a valid absolute URI.

Parameters:
text Text
Returns:
Valid absolute URI flag
Since:
1.0.0rc1

bool Xspf::Toolbox::isUri ( XML_Char const *  text  ) 

Checks wether text is a valid URI.

Parameters:
text Text
Returns:
Valid URI flag
Since:
1.0.0rc1

bool Xspf::Toolbox::isWhiteSpace ( XML_Char const *  text,
int  numChars 
)

Checks a string for being all whitespace. Whitespace is: ' ', '\r', '\n', '\t' as defined here: http://www.w3.org/TR/xmlschema-2/#rf-whiteSpace

Parameters:
text Text to check
numChars Length of text in characters
Returns:
All-whitespace flag
Since:
1.0.0rc1

XML_Char* Xspf::Toolbox::makeAbsoluteUri ( XML_Char const *  sourceUri,
XML_Char const *  baseUri 
)

Resolves a URI reference against a given base URI. If the given URI already is absolute the result will be that URI again. You can think of this function as "make my URI absolute if it isn't already". Please note you are responbsible to run delete [] on the return value.

Parameters:
sourceUri Relative URI to resolve
baseUri Absolute base URI to resolve against
Returns:
NULL or an absolute URI allocated with new[].
Since:
1.0.0rc1

XML_Char* Xspf::Toolbox::makeRelativeUri ( XML_Char const *  sourceUri,
XML_Char const *  baseUri 
)

Reduces a given absolute URI to a relative URI reference if possible. If there is no commonality between sourceUri and baseUri the resulting URI will still be absolute. You can think of this function as "make my URI relative if possible". Please note you are responbsible to run delete [] on the return value.

Parameters:
sourceUri Absolute URI to reduce
baseUri Absolute base URI to reduce against
Returns:
NULL or an URI allocated with new[].
Since:
1.0.0rc1

XML_Char* Xspf::Toolbox::newAndCopy ( XML_Char const *  source  ) 

Duplicates the string (using new() not malloc()) and returns the duplicate. If source is NULL the return value also is NULL.

Parameters:
source Source text
Returns:
Duplacated text or NULL

void Xspf::Toolbox::trimString ( std::basic_string< XML_Char > &  target  ) 

Cuts off whitespace at head and tail.

Parameters:
target String object to modify
Since:
1.0.0rc1


Generated on Sat Mar 7 01:09:37 2009 for libxspf by  doxygen 1.5.8