gloox::util Namespace Reference

A namespace holding a couple utility functions. More...

Classes

class  Mutex
 A simple implementation of mutex as a wrapper around a pthread mutex or a win32 critical section. More...
class  MutexGuard
 A simple implementation of a mutex guard. More...

Functions

int internalLog2 (unsigned int n)
unsigned _lookup (const std::string &str, const char *values[], unsigned size, int def)
const std::string _lookup (unsigned code, const char *values[], unsigned size, const std::string &def)
unsigned _lookup2 (const std::string &str, const char *values[], unsigned size, int def)
const std::string _lookup2 (unsigned code, const char *values[], unsigned size, const std::string &def)
const std::string escape (std::string what)
bool checkValidXMLChars (const std::string &data)
void replaceAll (std::string &target, const std::string &find, const std::string &replace)
template<typename T , typename F >
void ForEach (T &t, F f)
template<typename T , typename F , typename D >
void ForEach (T &t, F f, D &d)
template<typename T , typename F , typename D1 , typename D2 >
void ForEach (T &t, F f, D1 &d1, D2 &d2)
template<typename T , typename F , typename D1 , typename D2 , typename D3 >
void ForEach (T &t, F f, D1 &d1, D2 &d2, D3 &d3)
template<typename T >
void clearList (std::list< T * > &L)
template<typename Key , typename T >
void clearMap (std::map< Key, T * > &M)
template<typename Key , typename T >
void clearMap (std::map< const Key, T * > &M)

Detailed Description

A namespace holding a couple utility functions.


Function Documentation

GLOOX_API const std::string _lookup ( unsigned  code,
const char *  values[],
unsigned  size,
const std::string &  def = EmptyString 
)

Finds the string associated with an enumerated type.

Parameters:
code Code of the string to search for.
values Array of String/Code pairs to look into.
size The array's size.
def Default value returned in case the lookup failed.
Returns:
The associated string (empty in case there's no match).
GLOOX_API unsigned _lookup ( const std::string &  str,
const char *  values[],
unsigned  size,
int  def = -1 
)

Finds the enumerated value associated with a string value.

Parameters:
str String to search for.
values Array of String/Code pairs to look into.
size The array's size.
def Default value returned in case the lookup failed.
Returns:
The associated enum code.
GLOOX_API const std::string _lookup2 ( unsigned  code,
const char *  values[],
unsigned  size,
const std::string &  def = EmptyString 
)

Finds the string associated with an ORable enumerated type.

Parameters:
code Code of the string to search for.
values Array of String/Code pairs to look into.
size The array's size.
def The default value to return if the lookup failed.
Returns:
The associated string (empty in case there's no match).
GLOOX_API unsigned _lookup2 ( const std::string &  str,
const char *  values[],
unsigned  size,
int  def = -1 
)

Finds the ORable enumerated value associated with a string value.

Parameters:
str String to search for.
values Array of String/Code pairs to look into.
size The array's size.
def The default value to return if the lookup failed.
Returns:
The associated enum code.
GLOOX_API bool checkValidXMLChars ( const std::string &  data  ) 

Checks whether the given input is valid UTF-8.

Parameters:
data The data to check for validity.
Returns:
@b True if the input is valid UTF-8, false otherwise.
void gloox::util::clearList ( std::list< T * > &  L  )  [inline]

Delete all elements from a list of pointers.

Parameters:
L List of pointers to delete.

Definition at line 144 of file util.h.

void gloox::util::clearMap ( std::map< const Key, T * > &  M  )  [inline]

Delete all associated values from a map (not the key elements). Const key type version.

Parameters:
M Map of pointer values to delete.

Definition at line 179 of file util.h.

void gloox::util::clearMap ( std::map< Key, T * > &  M  )  [inline]

Delete all associated values from a map (not the key elements).

Parameters:
M Map of pointer values to delete.

Definition at line 161 of file util.h.

GLOOX_API const std::string escape ( std::string  what  ) 

Does some fancy escaping. (& --> &amp;, etc).

Parameters:
what A string to escape.
Returns:
The escaped string.
void gloox::util::ForEach ( T &  t,
f,
D1 &  d1,
D2 &  d2,
D3 &  d3 
) [inline]

A convenience function that executes the given function on each object in a given list, passing the given arguments.

Parameters:
t The object to execute the function on.
f The function to execute.
d1 An argument to pass to the function.
d2 An argument to pass to the function.
d3 An argument to pass to the function.

Definition at line 133 of file util.h.

void gloox::util::ForEach ( T &  t,
f,
D1 &  d1,
D2 &  d2 
) [inline]

A convenience function that executes the given function on each object in a given list, passing the given arguments.

Parameters:
t The object to execute the function on.
f The function to execute.
d1 An argument to pass to the function.
d2 An argument to pass to the function.

Definition at line 117 of file util.h.

void gloox::util::ForEach ( T &  t,
f,
D &  d 
) [inline]

A convenience function that executes the given function on each object in a given list, passing the given argument.

Parameters:
t The object to execute the function on.
f The function to execute.
d An argument to pass to the function.

Definition at line 102 of file util.h.

void gloox::util::ForEach ( T &  t,
f 
) [inline]

A convenience function that executes the given function on each object in a given list.

Parameters:
t The object to execute the function on.
f The function to execute.

Definition at line 88 of file util.h.

GLOOX_API int internalLog2 ( unsigned int  n  ) 

Custom log2() implementation.

Parameters:
n Figure to take the logarithm from.
Returns:
The logarithm to the basis of 2.
GLOOX_API void replaceAll ( std::string &  target,
const std::string &  find,
const std::string &  replace 
)

Replace all instances of one substring of arbitrary length with another substring of arbitrary length. Replacement happens in place (so make a copy first if you don't want the original modified).

Parameters:
target The string to process. Changes are made "in place".
find The sub-string to find within the target string
replace The sub-string to substitute for the find string.
Todo:
Look into merging with util::escape() and Parser::decode().

Generated by  doxygen 1.6.2