libUTL++
General

General-purpose classes. More...

Classes

class  utl::Application
 Application base class. More...
class  utl::AutoPtr< T >
 Smart pointer. More...
class  utl::CmdLineArgs
 Parse command-line arguments. More...
class  utl::FlagGuard
 Flag guard. More...
class  utl::LogMgr
 Manage application event logging. More...
class  utl::MaxObject
 Sentinel maximum value. More...
class  utl::NaturalOrdering
 Natural object ordering. More...
class  utl::InvertedNaturalOrdering
 Inverted natural object ordering. More...
class  utl::KeyOrdering
 Key-based object ordering. More...
class  utl::InvertedKeyOrdering
 Inverted key-based object ordering. More...
class  utl::TypeOrdering
 Order objects by type name first, and use the given ordering to compare objects of the same type. More...
class  utl::AddressOrdering
 Address-based object ordering. More...
class  utl::Pair
 Simple container for two objects. More...
class  utl::RunTimeClass
 Encapsulate class-related knowledge. More...
class  utl::TRunTimeClass< T >
 Template version of RunTimeClass. More...
class  utl::TConcreteRunTimeClass< T >
 Encapsulate class-related knowledge for concrete classes. More...
class  utl::TypeInfo< T >
 Provide type information. More...
class  utl::ConcreteTypeInfo< T >
 Provide type information for concrete types. More...

Macros

#define UTL_APP(appName)
 Declare a simple application.
#define isA(className)   _isA(CLASS(className))
 Determine whether the class is derived from the given class.
#define isA2(className, T1, T2)   _isA(CLASS2(className, T1, T2))
 Determine whether the class is derived from a template class instantiated with the two given parameters.
#define CLASS(className)   (className::getThisClass())
 Get the RunTimeClass object for the given class.
#define CLASS2(className, T1, T2)   (className< T1, T2 >::getThisClass())
 Get the RunTimeClass object for a template class instantiated with the two given parameters.
#define UTL_CLASS_DECL_RTTI(className)
 Declares the methods that are associated with run-time type identification (RTTI).
#define UTL_CLASS_DECL_RTTI_TPL(className, T)
 Declares the methods that are associated with run-time type identification (RTTI) for a template class with one parameter.
#define UTL_CLASS_DECL_RTTI_TPL2(className, T1, T2)
 Declares the methods that are associated with run-time type identification (RTTI) for a template class with two parameters.
#define UTL_CLASS_DECL_RTTI_ABC(className)
 Declares the methods that are associated with run-time type identification (RTTI).
#define UTL_CLASS_IMPL_RTTI(className, baseClassName)
 Implements the methods that are associated with run-time type identification (RTTI).
#define UTL_CLASS_IMPL_RTTI_NT_TPL2(className, baseClassName, T1, T2)
 Implements the methods that are associated with run-time type identification (RTTI) for a non-template class that inherits from a template class with two parameters.
#define UTL_CLASS_IMPL_RTTI_TPL(className, T, baseClassName)
 Implements the methods that are associated with run-time type identification (RTTI) for a template class.
#define UTL_CLASS_IMPL_RTTI_TPL2(className, T1, T2, baseClassName)
 Implements the methods that are associated with run-time type identification (RTTI) for a template class.
#define UTL_CLASS_IMPL_RTTI_TPL2_TPLxTPL2(DC, DC_T1, DC_T2, BC, BC_TC, BC_T1_T1, BC_T1_T2)
 Implement run-time type identification (RTTI) for a template class that inherits from a template class with a single parameter (which is a template class with two parameters).
#define UTL_CLASS_IMPL_RTTI_ABC(className, baseClassName)
 Implements the methods that are associated with run-time type identification (RTTI).
#define self   (*this)
 Refers to the object the method was invoked on.
#define ASSERT(x)   if (!(x)) utl::abort(__FILE__, __LINE__, "assertion failed: "#x)
 Declares a defect if x is false (or 0).
#define ABORT()   utl::abort(__FILE__, __LINE__)
 Immediately terminates the program.
#define DIE(text)   die(__FILE__, __LINE__, text)
 Terminates with an error message.
#define BREAKPOINT   { int __bp__ = 0; __bp__ = __bp__; }
 Expands to a no-op - sometimes useful when debugging.
#define UTL_SHOW(x)   cout << #x " = " << x << endl
 Show a value (useful when debugging)
#define ASSERTD   ASSERT
 Do an assertion in DEBUG mode only.
#define ASSERTFNZ(x)   ASSERT(x == 0)
 Evaluate x, and in DEBUG mode, assert that x is zero.
#define ASSERTFNP(x)   ASSERT(x != 0)
 Evaluate x, and in DEBUG mode, assert that x is non-zero.
#define IFDEBUG(x)   x
 Do x in DEBUG mode only.
#define INLINE
 Expands to inline in RELEASE mode only.
#define K(x)   (1024UL * (x))
 K(x) = x kilobytes.
#define M(x)   (1024UL * 1024UL * (x))
 M(x) = x megabytes.
#define UTL_INSTANTIATE_TPL(className, T)
 Instantiate a template class with the given parameter.
#define UTL_INSTANTIATE_TPL2(className, T1, T2)
 Instantiate a template class with two given parameters.
#define UTL_INSTANTIATE_TPLxTPL2(className, TC, T1, T2)
 Instantiate a template class with a single parameter (which is a template class with two parameters).
#define UTL_MAIN(appName)
 A standard UTL++ implementation of main().
#define UTL_MAIN_RL(appName)
 A standard UTL++ implementation of main() with a check for memory leaks in DEBUG mode.
#define UTL_USE(className)   { className::getThisClass(); }
 Ensure the RunTimeClass instance for the given class is referenced so it won't be optimized away.
#define UTL_USE_TPL2(className, T1, T2)   { className<T1,T2>::getThisClass(); }
 Ensure the RunTimeClass instance for the given class is referenced so it won't be optimized away.
#define for_each_ln(head, var_type, var_name)
 Iterate over the objects in a double-linked list.
#define for_each_sln(head, var_type, var_name)
 Iterate over the objects in a single-linked list.
#define for_each_end
 Terminate a forEach block.
#define UTL_CLASS_CONSTRUCT(className)
 Default constructor - calls init().
#define UTL_CLASS_COPYCONSTRUCT(className)
 Copy constructor - calls init(), then calls copy(rhs).
#define UTL_CLASS_COPYCONSTRUCT_TPL(className, myClass)
 Copy constructor - calls init(), then calls copy(rhs).
#define UTL_CLASS_MOVECONSTRUCT(className)
 Copy constructor - calls init(), then calls copy(rhs).
#define UTL_CLASS_MOVECONSTRUCT_TPL(className, myClass)
 Copy constructor - calls init(), then calls copy(rhs).
#define UTL_CLASS_DESTRUCT(className)
 Virtual destructor - calls deInit().
#define UTL_CLASS_DESTRUCT_TPL(className, T)
 Virtual destructor for a templated class with one parameter.
#define UTL_CLASS_DESTRUCT_TPL2(className, T1, T2)
 Virtual destructor for a templated class with two parameters.
#define UTL_CLASS_DEFID
 Default init() and deInit() (which are merely place-holders).
#define UTL_CLASS_CLONE(className)
 Create a new copy of self.
#define UTL_CLASS_CREATE(className)
 Create a fresh instance of self's class.
#define UTL_CLASS_EQUALS(lhsClassName, rhsClassName)
 operator=(rhs) simply calls Object::copy(rhs).
#define UTL_CLASS_EQUALS_MOVE(lhsClassName, rhsClassName)
 operator=(rhs) for the case where rhs is a temporary.
#define UTL_CLASS_POINTER(className)
 Conversion to pointer.
#define UTL_CLASS_CONSTPOINTER(className)
 Conversion to const pointer.
#define UTL_CLASS_VOIDPOINTER(className)
 Conversion to void pointer.
#define UTL_CLASS_NO_COMPARE
 Declare that a class cannot do compare().
#define UTL_CLASS_NO_COPY
 Declare that a class cannot do copy().
#define UTL_CLASS_NO_CREATE(className)
 Declare that a class cannot create().
#define UTL_CLASS_NO_KEY(className)
 Declare that a class has no key.
#define UTL_CLASS_NO_SERIALIZE
 Declare that a class cannot do serialize().
#define UTL_CLASS_SERIALIZE(className)
 Implement serialize() for a class.
#define UTL_TYPE_NO_SERIALIZE(typeName)
 Declare that a type cannot be serialized.
#define UTL_CLASS_DECL_ABC(className)
 Declaration of standard UTL++ functionality for an abstract base class (ABC).
#define UTL_CLASS_DECL(className)
 Declaration of standard UTL++ class functionality.
#define UTL_CLASS_DECL_TPL(className, T)
 Declaration of standard UTL++ functionality for a template class with one parameter.
#define UTL_CLASS_DECL_TPL2(className, T1, T2)
 Declaration of standard UTL++ functionality for a template class with two parameters.
#define UTL_CLASS_IMPL_ABC(className, baseClassName)
 Implementation of standard UTL++ functionality for an abstract base class (ABC).
#define UTL_CLASS_IMPL(className, baseClassName)
 Implementation of standard UTL++ class functionality.
#define UTL_CLASS_IMPL_NT_TPL2(className, baseClassName, T1, T2)
 Implementation of standard UTL++ functionality for a non-template class that inherits from a template class with two parameters.
#define UTL_CLASS_IMPL_TPL(className, T, baseClassName)   UTL_CLASS_IMPL_RTTI_TPL(className, T, baseClassName)
 Implementation of standard UTL++ functionality for a template class.
#define UTL_CLASS_IMPL_TPL2(className, T1, T2, baseClassName)   UTL_CLASS_IMPL_RTTI_TPL2(className, T1, T2, baseClassName)
 Implementation of standard UTL++ functionality for a template class with two parameters.
#define UTL_CLASS_IMPL_TPL2_TPLxTPL2(DC, DC_T1, DC_T2, BC, BC_TC, BC_T1_T1, BC_T1_T2)
 Implementation of standard UTL++ functionality for a template class that inherits from a template class with a single parameter (which is a template class with two parameters).
#define UTL_CLASS_IMPL_TPL2_TPL2(DC, DC_T1, DC_T2, BC, BC_T1, BC_T2)   UTL_CLASS_IMPL_RTTI_TPL2_TPL2(DC, DC_T1, DC_T2, BC, BC_T1, BC_T2)
 Implementation of standard UTL++ functionality for a template class with two parameters that inherits from a template class with two parameters.
#define UTL_CLASS_IMPL_TYPEINFO(className)
 Implement ConcreteTypeInfo for a class.
#define UTL_CLASS_IMPL_TYPEINFO_TPL(className, T)
 Implement TypeInfo for a template class with one parameter.
#define UTL_CLASS_IMPL_TYPEINFO_TPLxTPL2(className, TC, T1, T2)
 Implement TypeInfo for a template class with one parameter (which is a template class with two parameters).
#define UTL_CLASS_IMPL_TYPEINFO_TPL2(className, T1, T2)
 Implement TypeInfo for a template class with two parameters.
#define UTL_CLASS_IMPL_TYPEINFO_ABC(className)
 Implement TypeInfo for an abstract base class (ABC).

Typedefs

typedef double utl::double_t
 Floating-point value.
typedef unsigned char utl::byte_t
 Unsigned character.
typedef unsigned char utl::uint8_t
 Unsigned 8-bit integer.
typedef signed char utl::char_t
 Signed character.
typedef signed char utl::int8_t
 Signed 8-bit integer.
typedef unsigned short utl::ushort_t
 Unsigned short integer.
typedef unsigned short utl::uint16_t
 Unsigned 16-bit integer.
typedef signed short utl::short_t
 Signed short integer.
typedef signed short utl::int16_t
 Signed 16-bit integer.
typedef unsigned int utl::uint_t
 Unsigned integer.
typedef unsigned int utl::uint32_t
 Unsigned 32-bit integer.
typedef signed int utl::int_t
 Signed integer.
typedef signed int utl::int32_t
 Signed 32-bit integer.
typedef unsigned long utl::ulong_t
 Unsigned long integer.
typedef signed long utl::long_t
 Signed long integer.
typedef unsigned long utl::uint64_t
 Unsigned 64-bit integer.
typedef long utl::int64_t
 Signed 64-bit integer.

Variables

const MaxObject utl::maxObject
 Global instance of MaxObject.
const NaturalOrdering utl::naturalOrdering
 Global instance of NaturalOrdering.
const InvertedNaturalOrdering utl::invertedNaturalOrdering
 Global instance of InvertedNaturalOrdering.
const KeyOrdering utl::keyOrdering
 Global instance of KeyOrdering.
const InvertedKeyOrdering utl::invertedKeyOrdering
 Global instance of KeyOrdering.
const TypeOrdering utl::typeOrdering
 Global instance of TypeOrdering.
const AddressOrdering utl::addressOrdering
 Global instance of AddressOrdering.
const double_t utl::double_t_min
 Minimum double_t value.
const double_t utl::double_t_max
 Maximum double_t value.
const byte_t utl::byte_t_min
 Minimum byte_t value.
const byte_t utl::byte_t_max
 Maximum byte_t value.
const uint8_t utl::uint8_t_min
 Minimum uint8_t value.
const uint8_t utl::uint8_t_max
 Maximum uint8_t value.
const char_t utl::char_t_min
 Minimum char_t value.
const char_t utl::char_t_max
 Maximum char_t value.
const int8_t utl::int8_t_min
 Minimum int8_t value.
const int8_t utl::int8_t_max
 Maximum int8_t value.
const ushort_t utl::ushort_t_min
 Minimum ushort_t value.
const ushort_t utl::ushort_t_max
 Maximum ushort_t value.
const uint16_t utl::uint16_t_min
 Minimum uint16_t value.
const uint16_t utl::uint16_t_max
 Maximum uint16_t value.
const short_t utl::short_t_min
 Minimum short_t value.
const short_t utl::short_t_max
 Maximum short_t value.
const int16_t utl::int16_t_min
 Minimum int16_t value.
const int16_t utl::int16_t_max
 Maximum int16_t value.
const uint_t utl::uint_t_min
 Minimum uint_t value.
const uint_t utl::uint_t_max
 Maximum uint_t value.
const uint32_t utl::uint32_t_min
 Minimum uint32_t value.
const uint32_t utl::uint32_t_max
 Maximum uint32_t value.
const int_t utl::int_t_min
 Minimum int_t value.
const int_t utl::int_t_max
 Maximum int_t value.
const int32_t utl::int32_t_min
 Minimum int32_t value.
const int32_t utl::int32_t_max
 Maximum int32_t value.
const uint64_t utl::uint64_t_min
 Minimum uint64_t value.
const uint64_t utl::uint64_t_max
 Maximum uint64_t value.
const int64_t utl::int64_t_min
 Minimum int64_t value.
const int64_t utl::int64_t_max
 Maximum int64_t value.
const ulong_t utl::ulong_t_min
 Minimum unsigned long value.
const ulong_t utl::ulong_t_max
 Maximum unsigned long value.
const long_t utl::long_t_min
 Minimum long value.
const long_t utl::long_t_max
 Maximum long value.
const size_t utl::size_t_min
 Minimum size_t value.
const size_t utl::size_t_max
 Maximum size_t value.
const ssize_t utl::ssize_t_min
 Minimum ssize_t value.
const ssize_t utl::ssize_t_max
 Maximum ssize_t value.

Detailed Description

General-purpose classes.


Macro Definition Documentation

#define UTL_APP (   appName)
Value:
class appName : public utl::Application \
{ \
UTL_CLASS_DECL(appName); \
UTL_CLASS_DEFID; \
public: \
virtual int run(int argc = 0, char** argv = NULL); \
}; \
UTL_CLASS_IMPL(appName, utl::Application);

Declare a simple application.

It is appropriate for short, simple applications such as example programs.

Definition at line 55 of file Application.h.

#define isA (   className)    _isA(CLASS(className))

Determine whether the class is derived from the given class.

See also:
Object::_isA()
RunTimeClass::_isA()

Definition at line 185 of file RunTimeClass.h.

Referenced by utl::cast().

#define isA2 (   className,
  T1,
  T2 
)    _isA(CLASS2(className, T1, T2))

Determine whether the class is derived from a template class instantiated with the two given parameters.

See also:
Object::_isA()
RunTimeClass::_isA()

Definition at line 196 of file RunTimeClass.h.

Referenced by utl::SpanAllocator< T, D >::copy().

#define UTL_USE_TPL2 (   className,
  T1,
  T2 
)    { className<T1,T2>::getThisClass(); }

Ensure the RunTimeClass instance for the given class is referenced so it won't be optimized away.

This version is for a template class with two parameters.

Definition at line 245 of file macros.h.

#define for_each_ln (   head,
  var_type,
  var_name 
)
Value:
{ \
for (const ListNode* __ln = head; \
(__ln != NULL) && !__ln->isSentinelTail(); \
__ln = __ln->next()) \
{ \
utl::Object* __lnPtr = __ln->get(); \
ASSERTD(__lnPtr->isA(var_type)); \
var_type& var_name = *(var_type*)__lnPtr;

Iterate over the objects in a double-linked list.

Parameters:
headhead node
var_typecontained type (e.g. MyClass)
var_namename of current object (e.g. myObject)

Definition at line 257 of file macros.h.

#define for_each_sln (   head,
  var_type,
  var_name 
)
Value:
{ \
for (const SlistNode* __ln = head; \
(__ln != NULL) && !__ln->isSentinelTail(); \
__ln = __ln->next()) \
{ \
utl::Object* __lnPtr = __ln->get(); \
ASSERTD(__lnPtr->isA(var_type)); \
var_type& var_name = *(var_type*)__lnPtr;

Iterate over the objects in a single-linked list.

Parameters:
headhead node
var_typecontained type (e.g. MyClass)
var_namename of current object (e.g. myObject)

Definition at line 276 of file macros.h.