libxspf  1.2.0
Functions
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

◆ copyIfOwned()

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
destReference of destination string
ownDestReference of destination owner flag
sourceSource string
ownSourceSource owner flag
Here is the caller graph for this function:

◆ cutOffWhiteSpace()

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
inputSource text
inputNumCharsLength of source in characters
blackSpaceStartPointer to first non-white character
blackSpaceNumCharsLength of characters until whitespace tail
Since
1.0.0rc1
Here is the caller graph for this function:

◆ deleteNewAndCopy() [1/2]

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
destDestination text
srcSource text

◆ deleteNewAndCopy() [2/2]

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
destDestination text
destOwnershipDestination ownership flag
sourceSource text
sourceCopySource copy flag

◆ extractInteger()

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

Extracts an integer from text.

Parameters
textText
inclusiveMinimumInclusive minimum
outputInteger storage destination
Returns
Valid integer less or equal inclusiveMinimum flag
Since
1.0.0rc1
Here is the caller graph for this function:

◆ freeIfOwned()

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
destReference of string to delete
ownDestOwner flag, false will prevent deletion
Here is the caller graph for this function:

◆ getSetNull()

T const* Xspf::Toolbox::getSetNull ( T const *&  dest)

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

Parameters
destDestination
Returns
Old value

Definition at line 129 of file XspfToolbox.h.

References copyIfOwned(), cutOffWhiteSpace(), extractInteger(), freeIfOwned(), isAbsoluteUri(), isUri(), isWhiteSpace(), makeAbsoluteUri(), makeRelativeUri(), and trimString().

Here is the call graph for this function:

◆ isAbsoluteUri()

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

Checks wether text is a valid absolute URI.

Parameters
textText
Returns
Valid absolute URI flag
Since
1.0.0rc1
Here is the caller graph for this function:

◆ isUri()

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

Checks wether text is a valid URI.

Parameters
textText
Returns
Valid URI flag
Since
1.0.0rc1
Here is the caller graph for this function:

◆ isWhiteSpace()

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
textText to check
numCharsLength of text in characters
Returns
All-whitespace flag
Since
1.0.0rc1
Here is the caller graph for this function:

◆ makeAbsoluteUri()

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
sourceUriRelative URI to resolve
baseUriAbsolute base URI to resolve against
Returns
NULL or an absolute URI allocated with new[].
Since
1.0.0rc1
Here is the caller graph for this function:

◆ makeRelativeUri()

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
sourceUriAbsolute URI to reduce
baseUriAbsolute base URI to reduce against
Returns
NULL or an URI allocated with new[].
Since
1.0.0rc1
Here is the caller graph for this function:

◆ newAndCopy()

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
sourceSource text
Returns
Duplacated text or NULL

◆ trimString()

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

Cuts off whitespace at head and tail.

Parameters
targetString object to modify
Since
1.0.0rc1
Here is the caller graph for this function: