ucommon/generics.h File Reference

Generic templates for C++. More...

#include <ucommon/cpr.h>
#include <stdlib.h>
#include <string.h>
#include <stdexcept>
Include dependency graph for generics.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

class  array_pointer< T >
 Generic smart array class. More...
class  pointer< T >
 Generic smart pointer class. More...
class  save_restore< T >
 Save and restore global objects in function call stack frames. More...
class  temp_array< T >
 Manage temporary array stored on the heap. More...
class  temporary< T >
 Manage temporary object stored on the heap. More...

Defines

#define THROW(x)   throw x
#define THROWS(x)   throw(x)
#define THROWS_ANY   throw()

Functions

template<typename T >
void copy_unsafe (T *target, const T *source)
 Convenience function to copy class.
template<typename T >
T * dup (const T &object)
 Convenience function to duplicate object pointer to heap.
template<>
char * dup< char > (const char &object)
template<typename T >
void dupfree (T object)
template<>
void dupfree< char * > (char *object)
template<class T >
bool is (T &object)
 Convenience function to validate object assuming it is castable to bool.
template<typename T >
bool isnull (T &object)
 Convenience function to test pointer object.
template<typename T >
bool isnullp (T *object)
 Convenience function to test pointer-pointer object.
template<typename T >
T &() limit (T &value, T &low, T &high)
 Convenience macro to range restrict values.
template<typename T >
T &() max (T &o1, T &o2)
 Convenience function to return max of two objects.
template<typename T >
T &() min (T &o1, T &o2)
 Convenience function to return min of two objects.
template<typename T >
void reset_unsafe (T &object)
 Convenience function to reset an existing object.
template<typename T >
void store_unsafe (T &target, const T *source)
 Convenience function to store object pointer into object.
template<typename T >
void swap (T &o1, T &o2)
 Convenience function to swap objects.
template<typename T >
void zero_unsafe (T &object)
 Convenience function to zero an object and restore type info.

Detailed Description

Generic templates for C++.

These are templates that do not depend on any ucommon classes. They can be used for generic C++ programming.

Definition in file generics.h.


Function Documentation

template<typename T >
void copy_unsafe ( T *  target,
const T *  source 
) [inline]

Convenience function to copy class.

Parameters:
target to copy into.
source to copy from.

Definition at line 515 of file generics.h.

template<typename T >
T* dup ( const T &  object  )  [inline]

Convenience function to duplicate object pointer to heap.

Parameters:
object we are duping.
Returns:
heap pointer instance.

Definition at line 478 of file generics.h.

template<class T >
bool is ( T &  object  )  [inline]

Convenience function to validate object assuming it is castable to bool.

Parameters:
object we are testing.
Returns:
true if object valid.
Examples:
datetime.cpp, and shell.cpp.

Definition at line 449 of file generics.h.

template<typename T >
bool isnull ( T &  object  )  [inline]

Convenience function to test pointer object.

This solves issues where some compilers get confused between bool and pointer operators.

Parameters:
object we are testing.
Returns:
true if object points to NULL.

Definition at line 459 of file generics.h.

template<typename T >
bool isnullp ( T *  object  )  [inline]

Convenience function to test pointer-pointer object.

This solves issues where some compilers get confused between bool and pointer operators.

Parameters:
object we are testing.
Returns:
true if object points to NULL.

Definition at line 469 of file generics.h.

template<typename T >
T&() limit ( T &  value,
T &  low,
T &  high 
) [inline]

Convenience macro to range restrict values.

Parameters:
value to check.
low value.
high value.
Returns:
adjusted value.

Definition at line 568 of file generics.h.

template<typename T >
T&() max ( T &  o1,
T &  o2 
) [inline]

Convenience function to return max of two objects.

Parameters:
o1 to check.
o2 to check.
Returns:
max object.
Examples:
string.cpp.

Definition at line 543 of file generics.h.

template<typename T >
T&() min ( T &  o1,
T &  o2 
) [inline]

Convenience function to return min of two objects.

Parameters:
o1 to check.
o2 to check.
Returns:
min object.

Definition at line 555 of file generics.h.

template<typename T >
void reset_unsafe ( T &  object  )  [inline]

Convenience function to reset an existing object.

Parameters:
object type to reset.

Definition at line 498 of file generics.h.

template<typename T >
void store_unsafe ( T &  target,
const T *  source 
) [inline]

Convenience function to store object pointer into object.

Parameters:
target to copy into.
source to copy from.

Definition at line 524 of file generics.h.

template<typename T >
void swap ( T &  o1,
T &  o2 
) [inline]

Convenience function to swap objects.

Parameters:
o1 to swap.
o2 to swap.

Definition at line 533 of file generics.h.

Here is the call graph for this function:

template<typename T >
void zero_unsafe ( T &  object  )  [inline]

Convenience function to zero an object and restore type info.

Parameters:
object to zero in memory.

Definition at line 506 of file generics.h.


Generated on 24 Sep 2014 for ucommon by  doxygen 1.6.1