Home Libraries Author Links

DivAids: Diverse Aids
[SysToMath Aids C++ Library]

Collaboration diagram for DivAids: Diverse Aids:

Detailed Description

Collection types, functions, function tempates, classes and class templates providing endian handling, buffer handling, byte iterator ranges, integral ranges, integral sets, condition variables, scoped locks and string handling support.

The declarations of these utilities are all contained in the namespace stm.


Files

file  divaids.hpp
 Declarations for diverse aids.

Namespaces

namespace  stm
 Namespace for the SysToMath C++ Libraries.
namespace  stm::buffer
 Namespace containing all buffer related utilities.
namespace  stm::rectrl
 Namespace for regular expression matching issues.

Modules

 DivAids Test
 Demonstration of the usage and tests of the implementation of the SysToMath Aids C++ Library module DivAids.

Classes

class  stm::byte_iterator_range
 Byte iterator range class. More...
class  stm::integral_range< IntegralT, minVal, maxVal >
 Class template representing a range of integral objects of type IntegralT constrained by the minimal and maximal values minVal and maxVal. More...
class  stm::integral_set< IntegralRangeT, RangeSetT >
 Class template integral_set is a set container representing a set of integral type objects constrained by minimal and maximal values wrapping a set of integral ranges. More...
class  stm::condition
 Condition class. More...
class  stm::system_condition
 System condition class. More...
class  stm::scoped_lock
 Scoped lock class. More...
class  stm::system_scoped_lock
 System scoped lock class. More...
struct  stm::fmtflags
 Base class of class template stm::hexfmt specifying format flags. More...
class  stm::hexfmt< UnsignedT, DefaultFlags >
 Class template allowing to format the unsigned number held as hexadecimal string. More...
class  stm::hexfmt< ElemT *, DefaultFlags >
 Class template partial specialization allowing to format the pointer held as hexadecimal string. More...
class  stm::fixedfmt< FloatT >
 Class template allowing to format the floating point number of type FloatT held on an output stream in fixed point notation using a specified precision. More...
struct  stm::space< CharT >
 Unary predicate functor template determining if a CharT object is a white space as defined by the current locale. More...
struct  stm::nospace< CharT >
 Unary predicate functor template determining if a CharT object is no white space as defined by the current locale. More...

Common unsigned and signed integer types

typedef boost::uint8_t stm::byte
typedef boost::uint16_t stm::word
typedef boost::uint32_t stm::dword
typedef boost::uint64_t stm::qword
typedef boost::int8_t stm::int8
typedef boost::int16_t stm::int16
typedef boost::int32_t stm::int32
typedef boost::int64_t stm::int64
typedef boost::uint_t< sizeof(void
*)*CHAR_BIT >::leas 
stm::addrword )
 Unsigned integer type capable of holding an address.

Endianness

typedef boost::mpl::bool_
< __BYTE_ORDER==__LITTLE_ENDIAN > 
stm::littleendian
 Type being boost::mpl::true_ or boost::mpl::false_ depending on the host endianness.
typedef boost::mpl::bool_
< __BYTE_ORDER==__BIG_ENDIAN > 
stm::bigendian
 Type being boost::mpl::true_ or boost::mpl::false_ depending on the host endianness.
bool stm::hostlittleendian ()
 Returns true, if the host byte order is little-endian.
bool stm::hostbigendian ()
 Returns true, if the host byte order is big-endian.

Predefined StmReCtrl Objects

The predefined StmReCtrl objects stm::rectrl::identity and stm::rectrl::tolower provide control and error handling for regular expressions (see Abstract Data Type StmRe).

StmReCtrl stm::rectrl::identity
StmReCtrl stm::rectrl::tolower
 Control and error handling of non-case-sensitive regular expressions.

Defines

#define StmRectrlTry(envbuf)   StmRectrlTryImpl_ (envbuf)
 std::logic_error exception based error control for normal and non-case-sensitive regular expressions controlled by the predefined StmReCtrl Objects stm::rectrl::identity and stm::rectrl::tolower.

Functions

template<typename T>
T & stm::buffer::get (byte *ptr)
 Returns a reference to the T object beginning at byte address ptr.
template<typename T>
const T & stm::buffer::get (const byte *ptr)
 Returns a constant reference to the T object beginning at byte address ptr.
template<typename T>
T & stm::buffer::fetch (T &obj, const byte *ptr)
 Creates obj T as being a copy of the T object beginning at byte address ptr and returns a reference to it.
template<typename T>
T & stm::buffer::swap (T &obj, typename boost::enable_if< boost::is_pod< T >, const byte * >::type ptr)
 Creates obj T as being a byte swapped copy of the T object beginning at byte address ptr and returns a reference to it.
template<typename T>
T & stm::buffer::endianConvertIf (T &obj, typename boost::enable_if< boost::is_pod< T >, const byte * >::type ptr, bool convert)
 Creates obj T as being an endian converted or unconverted copy of the T object beginning at byte address ptr and returns a reference to it.
template<typename T>
T & stm::buffer::endianConvertIf (T &obj, typename boost::enable_if< boost::is_pod< T >, const byte * >::type ptr, boost::mpl::false_)
 Creates obj T as being an unconverted copy of the T object beginning at byte address ptr and returns a reference to it.
template<typename T>
T & stm::buffer::endianConvertIf (T &obj, typename boost::enable_if< boost::is_pod< T >, const byte * >::type ptr, boost::mpl::true_)
 Creates obj T as being an endian converted copy of the T object beginning at byte address ptr and returns a reference to it.
template<typename T>
T & stm::buffer::networkByteOrderConvert (T &obj, typename boost::enable_if< boost::is_pod< T >, const byte * >::type ptr)
 Creates obj T as being an endian converted or unconverted copy of the T object beginning at byte address ptr and returns a reference to it.
template<typename T>
stm::buffer::swapped (typename boost::enable_if< boost::is_pod< T >, T >::type value)
 Returns an object of type T being a byte swapped copy of the T object value.
template<typename T>
stm::buffer::endianConvertedIf (typename boost::enable_if< boost::is_pod< T >, T >::type value, bool convert)
 Returns the endian converted or unconverted value of an object of type T.
template<typename T>
stm::buffer::endianConvertedIf (typename boost::enable_if< boost::is_pod< T >, T >::type value, boost::mpl::false_)
 Returns the unconverted value of an object of type T.
template<typename T>
stm::buffer::endianConvertedIf (typename boost::enable_if< boost::is_pod< T >, T >::type value, boost::mpl::true_)
 Returns the endian converted value of an object of type T.
template<typename T>
stm::buffer::networkByteOrderConverted (typename boost::enable_if< boost::is_pod< T >, T >::type value)
 Returns the endian converted or unconverted value of an object of type T.
template<typename T>
size_t stm::buffer::pad (typename boost::enable_if< has_pow2size< T >, size_t >::type offset)
 Returns the least number aligned to T not being less than offset.
template<typename T>
byte * stm::buffer::put (byte *ptr, const T &value)
 Stores a T object at byte address ptr and returns the byte address of the T object following that T object.
template<class IStreamT, typename IntegralT, IntegralT minVal, IntegralT maxVal>
IStreamT & stm::operator>> (IStreamT &is, integral_range< IntegralT, minVal, maxVal > &range)
 Extract the integral range formatted as single integral number or as expression "first-last" with integral numbers first < last enclosed in parentheses from the input stream is and store it in the integral range.
template<class OStreamT, typename IntegralT, IntegralT minVal, IntegralT maxVal>
OStreamT & stm::operator<< (OStreamT &os, const integral_range< IntegralT, minVal, maxVal > &range)
 Insert the integral range held by range into the output stream os formatted as single decimal numbers or expression "first-last" with decimal numbers first < last.
template<class IStreamT, class IntegralRangeT, class RangeSetT>
IStreamT & stm::operator>> (IStreamT &is, integral_set< IntegralRangeT, RangeSetT > &set)
 Extract the integral ranges formatted as comma separated sequence of single integral numbers and/or expressions "first-last" with integral numbers first < last enclosed in parentheses from the input stream is and store them in the integral set.
template<class OStreamT, class IntegralRangeT, class RangeSetT>
OStreamT & stm::operator<< (OStreamT &os, const integral_set< IntegralRangeT, RangeSetT > &set)
 Insert the integral ranges held by the integral set into the output stream os formatted as comma separated sequence of single decimal numbers and/or expressions "first-last" with decimal numbers first < last.
template<class OStreamT, typename UnsignedT, dword DefaultFlags>
OStreamT & stm::operator<< (OStreamT &os, const hexfmt< UnsignedT, DefaultFlags > &val)
 Insert the value held by val into the output stream os as hexadecimal string formatted according to the flags in effect.
template<class OStreamT, typename ElemT, dword DefaultFlags>
OStreamT & stm::operator<< (OStreamT &os, const hexfmt< ElemT *, DefaultFlags > &ptr)
 Insert the value held by ptr into the output stream os as hexadecimal string according to the flags in effect.
template<class OStreamT, typename FloatT>
OStreamT & stm::operator<< (OStreamT &os, const fixedfmt< FloatT > &val)
 Insert the value held by val into the output stream os in fixed point notation using the precision specified by val.
template<typename ScalarT>
dword stm::nrOfSetBits (ScalarT value)
 Function template returning the number of set bits of a ScalarT value.
template<class StringT>
StringT::size_type stm::clamped_offset (const StringT &str, typename StringT::size_type pos)
 Function template returning the offset pos of the string str clamped by its length.
template<class StringT>
StringT::size_type stm::clamped_rest (const StringT &str, typename StringT::size_type pos)
 Function template returning the length of the string str beginning with offset pos clamped by the string's length.
template<class StringT>
StringT stm::trim_back (const StringT &str)
 Function template returning a copy of str.substr without trailing white space characters as defined by the current locale.
template<class StringT>
StringT stm::trim_back (const StringT &str, typename StringT::size_type pos)
 Function template returning a copy of str.substr (0, pos) without trailing white space characters as defined by the current locale.
template<class StringT>
StringT::size_type stm::find_trim_back (const StringT &str)
 Function template returning trim_back (str).size ().
template<class StringT>
StringT::size_type stm::find_trim_back (const StringT &str, typename StringT::size_type pos)
 Function template returning trim_back (str, pos).size ().
template<class StringT>
StringT::size_type stm::find_token_end (const StringT &str, typename StringT::size_type pos=0)
 Function template returning the least index npos >= pos such that npos == str.length () or str [npos] is white space.
template<class StringT>
StringT stm::trim_back (const StringT &str, const StringT &sepchars)
 Function template returning a copy of str without trailing characters from sepchars.
template<class StringT>
StringT stm::trim_back (const StringT &str, const StringT &sepchars, typename StringT::size_type pos)
 Function template returning a copy of str.substr (0, pos) without trailing characters from sepchars.
template<class StringT>
StringT::size_type stm::find_trim_back (const StringT &str, const StringT &sepchars)
 Function template returning trim_back (str, sepchars).size ().
template<class StringT>
StringT::size_type stm::find_trim_back (const StringT &str, const StringT &sepchars, typename StringT::size_type pos)
 Function template returning trim_back (str, sepchars, pos).size ().
template<class StringT>
StringT::size_type stm::find_token_end (const StringT &str, const StringT &sepchars, typename StringT::size_type pos=0)
 Function template returning the least index npos >= pos with npos == str.length () or str [npos] is one of the characters of sepchars.
template<class StringT>
StringT stm::trim_front (const StringT &str, typename StringT::size_type pos=0)
 Function template returning a copy of str.substr (pos) without leading white space characters as defined by the current locale.
template<class StringT>
StringT::size_type stm::find_trim_front (const StringT &str, typename StringT::size_type pos=0)
 Function template returning str.size () - trim_front (str, pos).size ().
template<class StringT>
StringT stm::trim_front (const StringT &str, const StringT &sepchars, typename StringT::size_type pos=0)
 Function template returning a copy of str.substr (pos) without leading characters from sepchars.
template<class StringT>
StringT::size_type stm::find_trim_front (const StringT &str, const StringT &sepchars, typename StringT::size_type pos=0)
 Function template returning str.size () - trim_front (str, sepchars, pos).size ().
template<class StringT>
StringT stm::trim (const StringT &str)
 Function template returning a copy of str without leading and trailing white space characters as defined by the current locale.
template<class StringT>
StringT stm::trim (const StringT &str, const StringT &sepchars)
 Function template returning a copy of str without leading and trailing characters from sepchars.


Define Documentation

#define StmRectrlTry ( envbuf   )     StmRectrlTryImpl_ (envbuf)

std::logic_error exception based error control for normal and non-case-sensitive regular expressions controlled by the predefined StmReCtrl Objects stm::rectrl::identity and stm::rectrl::tolower.

To establich such an error control choose a name, say ErrorEnv, for the macro argument envbuf and place a call

      StmRectrlTry (ErrorEnv)
at the beginning of a try block inside which regular expressions (see Abstract Data Type StmRe) are used directly or implicitely (by using functions or classes using them in their implementation). Then all errors occurring in regular expression functions controlled by one of the StmReCtrl objects stm::rectrl::identity or stm::rectrl::tolower throw a std::logic_error exception with the error reason as text. Unless the macro NDEBUG is defined, that text is also output on stderr.
Examples:
filesystest.cpp.

Definition at line 446 of file divaids.hpp.


Typedef Documentation

typedef boost::uint_t<sizeof (void *) * CHAR_BIT>::leas stm::addrword)

Unsigned integer type capable of holding an address.

Definition at line 124 of file divaids.hpp.

typedef boost::mpl::bool_<__BYTE_ORDER == __LITTLE_ENDIAN> stm::littleendian

Type being boost::mpl::true_ or boost::mpl::false_ depending on the host endianness.

Definition at line 134 of file divaids.hpp.

typedef boost::mpl::bool_<__BYTE_ORDER == __BIG_ENDIAN> stm::bigendian

Type being boost::mpl::true_ or boost::mpl::false_ depending on the host endianness.

Definition at line 139 of file divaids.hpp.


Function Documentation

bool stm::hostlittleendian (  ) 

Returns true, if the host byte order is little-endian.

Deprecated:
use stm::littleendian () instead.

bool stm::hostbigendian (  ) 

Returns true, if the host byte order is big-endian.

Deprecated:
use stm::bigendian () instead.

template<typename T>
T& stm::buffer::get ( byte *  ptr  ) 

Returns a reference to the T object beginning at byte address ptr.

template<typename T>
const T& stm::buffer::get ( const byte *  ptr  ) 

Returns a constant reference to the T object beginning at byte address ptr.

template<typename T>
T& stm::buffer::fetch ( T &  obj,
const byte *  ptr 
)

Creates obj T as being a copy of the T object beginning at byte address ptr and returns a reference to it.

T must be assignable.

template<typename T>
T& stm::buffer::swap ( T &  obj,
typename boost::enable_if< boost::is_pod< T >, const byte * >::type  ptr 
)

Creates obj T as being a byte swapped copy of the T object beginning at byte address ptr and returns a reference to it.

This function template is instantiated only for POD types T.

template<typename T>
T& stm::buffer::endianConvertIf ( T &  obj,
typename boost::enable_if< boost::is_pod< T >, const byte * >::type  ptr,
bool  convert 
)

Creates obj T as being an endian converted or unconverted copy of the T object beginning at byte address ptr and returns a reference to it.

The conversion takes place, if convert is true. This function template is instantiated only for POD types T.

template<typename T>
T& stm::buffer::endianConvertIf ( T &  obj,
typename boost::enable_if< boost::is_pod< T >, const byte * >::type  ptr,
boost::mpl::false_   
)

Creates obj T as being an unconverted copy of the T object beginning at byte address ptr and returns a reference to it.

This function template is instantiated only for POD types T.

template<typename T>
T& stm::buffer::endianConvertIf ( T &  obj,
typename boost::enable_if< boost::is_pod< T >, const byte * >::type  ptr,
boost::mpl::true_   
)

Creates obj T as being an endian converted copy of the T object beginning at byte address ptr and returns a reference to it.

This function template is instantiated only for POD types T.

template<typename T>
T& stm::buffer::networkByteOrderConvert ( T &  obj,
typename boost::enable_if< boost::is_pod< T >, const byte * >::type  ptr 
)

Creates obj T as being an endian converted or unconverted copy of the T object beginning at byte address ptr and returns a reference to it.

The conversion takes place, if the host byte order is not the network byte order (big endian). This function template is instantiated only for POD types T.

template<typename T>
T stm::buffer::swapped ( typename boost::enable_if< boost::is_pod< T >, T >::type  value  ) 

Returns an object of type T being a byte swapped copy of the T object value.

This function template is instantiated only for POD types T.

template<typename T>
T stm::buffer::endianConvertedIf ( typename boost::enable_if< boost::is_pod< T >, T >::type  value,
bool  convert 
)

Returns the endian converted or unconverted value of an object of type T.

The conversion takes place, if convert is true. This function template is instantiated only for POD types T.

template<typename T>
T stm::buffer::endianConvertedIf ( typename boost::enable_if< boost::is_pod< T >, T >::type  value,
boost::mpl::false_   
)

Returns the unconverted value of an object of type T.

This function template is instantiated only for POD types T.

template<typename T>
T stm::buffer::endianConvertedIf ( typename boost::enable_if< boost::is_pod< T >, T >::type  value,
boost::mpl::true_   
)

Returns the endian converted value of an object of type T.

This function template is instantiated only for POD types T.

template<typename T>
T stm::buffer::networkByteOrderConverted ( typename boost::enable_if< boost::is_pod< T >, T >::type  value  ) 

Returns the endian converted or unconverted value of an object of type T.

The conversion takes place, if the host byte order is not the network byte order (big endian). This function template is instantiated only for POD types T.

template<typename T>
size_t stm::buffer::pad ( typename boost::enable_if< has_pow2size< T >, size_t >::type  offset  ) 

Returns the least number aligned to T not being less than offset.

This function template is instantiated only for types T with a power of two as sizeof (T).

template<typename T>
byte* stm::buffer::put ( byte *  ptr,
const T &  value 
)

Stores a T object at byte address ptr and returns the byte address of the T object following that T object.

template<class IStreamT, typename IntegralT, IntegralT minVal, IntegralT maxVal>
IStreamT& stm::operator>> ( IStreamT &  is,
integral_range< IntegralT, minVal, maxVal > &  range 
)

Extract the integral range formatted as single integral number or as expression "first-last" with integral numbers first < last enclosed in parentheses from the input stream is and store it in the integral range.

template<class OStreamT, typename IntegralT, IntegralT minVal, IntegralT maxVal>
OStreamT& stm::operator<< ( OStreamT &  os,
const integral_range< IntegralT, minVal, maxVal > &  range 
)

Insert the integral range held by range into the output stream os formatted as single decimal numbers or expression "first-last" with decimal numbers first < last.

template<class IStreamT, class IntegralRangeT, class RangeSetT>
IStreamT& stm::operator>> ( IStreamT &  is,
integral_set< IntegralRangeT, RangeSetT > &  set 
)

Extract the integral ranges formatted as comma separated sequence of single integral numbers and/or expressions "first-last" with integral numbers first < last enclosed in parentheses from the input stream is and store them in the integral set.

template<class OStreamT, class IntegralRangeT, class RangeSetT>
OStreamT& stm::operator<< ( OStreamT &  os,
const integral_set< IntegralRangeT, RangeSetT > &  set 
)

Insert the integral ranges held by the integral set into the output stream os formatted as comma separated sequence of single decimal numbers and/or expressions "first-last" with decimal numbers first < last.

template<class OStreamT, typename UnsignedT, dword DefaultFlags>
OStreamT& stm::operator<< ( OStreamT &  os,
const hexfmt< UnsignedT, DefaultFlags > &  val 
)

Insert the value held by val into the output stream os as hexadecimal string formatted according to the flags in effect.

template<class OStreamT, typename ElemT, dword DefaultFlags>
OStreamT& stm::operator<< ( OStreamT &  os,
const hexfmt< ElemT *, DefaultFlags > &  ptr 
)

Insert the value held by ptr into the output stream os as hexadecimal string according to the flags in effect.

template<class OStreamT, typename FloatT>
OStreamT& stm::operator<< ( OStreamT &  os,
const fixedfmt< FloatT > &  val 
)

Insert the value held by val into the output stream os in fixed point notation using the precision specified by val.

template<typename ScalarT>
dword stm::nrOfSetBits ( ScalarT  value  ) 

Function template returning the number of set bits of a ScalarT value.

template<class StringT>
StringT::size_type stm::clamped_offset ( const StringT &  str,
typename StringT::size_type  pos 
)

Function template returning the offset pos of the string str clamped by its length.

template<class StringT>
StringT::size_type stm::clamped_rest ( const StringT &  str,
typename StringT::size_type  pos 
)

Function template returning the length of the string str beginning with offset pos clamped by the string's length.

template<class StringT>
StringT stm::trim_back ( const StringT &  str  ) 

Function template returning a copy of str.substr without trailing white space characters as defined by the current locale.

template<class StringT>
StringT stm::trim_back ( const StringT &  str,
typename StringT::size_type  pos 
)

Function template returning a copy of str.substr (0, pos) without trailing white space characters as defined by the current locale.

template<class StringT>
StringT::size_type stm::find_trim_back ( const StringT &  str  ) 

Function template returning trim_back (str).size ().

template<class StringT>
StringT::size_type stm::find_trim_back ( const StringT &  str,
typename StringT::size_type  pos 
)

Function template returning trim_back (str, pos).size ().

template<class StringT>
StringT::size_type stm::find_token_end ( const StringT &  str,
typename StringT::size_type  pos = 0 
)

Function template returning the least index npos >= pos such that npos == str.length () or str [npos] is white space.

template<class StringT>
StringT stm::trim_back ( const StringT &  str,
const StringT &  sepchars 
)

Function template returning a copy of str without trailing characters from sepchars.

template<class StringT>
StringT stm::trim_back ( const StringT &  str,
const StringT &  sepchars,
typename StringT::size_type  pos 
)

Function template returning a copy of str.substr (0, pos) without trailing characters from sepchars.

template<class StringT>
StringT::size_type stm::find_trim_back ( const StringT &  str,
const StringT &  sepchars 
)

Function template returning trim_back (str, sepchars).size ().

template<class StringT>
StringT::size_type stm::find_trim_back ( const StringT &  str,
const StringT &  sepchars,
typename StringT::size_type  pos 
)

Function template returning trim_back (str, sepchars, pos).size ().

template<class StringT>
StringT::size_type stm::find_token_end ( const StringT &  str,
const StringT &  sepchars,
typename StringT::size_type  pos = 0 
)

Function template returning the least index npos >= pos with npos == str.length () or str [npos] is one of the characters of sepchars.

template<class StringT>
StringT stm::trim_front ( const StringT &  str,
typename StringT::size_type  pos = 0 
)

Function template returning a copy of str.substr (pos) without leading white space characters as defined by the current locale.

template<class StringT>
StringT::size_type stm::find_trim_front ( const StringT &  str,
typename StringT::size_type  pos = 0 
)

Function template returning str.size () - trim_front (str, pos).size ().

template<class StringT>
StringT stm::trim_front ( const StringT &  str,
const StringT &  sepchars,
typename StringT::size_type  pos = 0 
)

Function template returning a copy of str.substr (pos) without leading characters from sepchars.

template<class StringT>
StringT::size_type stm::find_trim_front ( const StringT &  str,
const StringT &  sepchars,
typename StringT::size_type  pos = 0 
)

Function template returning str.size () - trim_front (str, sepchars, pos).size ().

template<class StringT>
StringT stm::trim ( const StringT &  str  ) 

Function template returning a copy of str without leading and trailing white space characters as defined by the current locale.

template<class StringT>
StringT stm::trim ( const StringT &  str,
const StringT &  sepchars 
)

Function template returning a copy of str without leading and trailing characters from sepchars.


Variable Documentation

StmReCtrl stm::rectrl::identity

Control and error handling of normal regular expressions. Use stm::rectrl::identity as StmReCtrl argument of regular expression functions (see Abstract Data Type StmRe).

StmReCtrl stm::rectrl::tolower

Control and error handling of non-case-sensitive regular expressions.

Use stm::rectrl::tolower as StmReCtrl argument of regular expression functions (see Abstract Data Type StmRe).


© Copyright Tom Michaelis 2002-2007

Distributed under the SysToMath Software License (See the accompanying file license.txt or a copy at www.SysToMath.com).