The Micro C++ Library
micxx Namespace Reference

The Micro C++ Library. More...

Namespaces

namespace  traits

Classes

class  Buffer
 A simple generic Buffer that could dynamically grow or shrink. More...
class  Condition
 A Condition provides yet another way for threads to synchronize based upon the actual value of data. More...
class  PrivateKey
 The PrivateKey class is a memory representation of a private key. More...
class  X509Certificate
 The X509Certificate class is a memory representation of a X.509 certificate. More...
class  X509CertificateList
 The X509Certificate class is a list of X509Certificate objects. More...
class  PKCS12Store
 The PKCS12Store class is a memory representation of a PKCS#12 container. More...
class  Exception
 An Exception is able to represent an error code, a message text and a stack of exception causes. More...
class  File
 A File is a special Stream associated to a filename. More...
class  Filename
 A Filename class represents a file or directory name within a filesystem. More...
class  Log
 The class Log provides a simple logging facility. More...
class  Mutex
 A Mutex provides mutual exclusive access to critical sections of concurrent threads. More...
class  ClientSocket
 A ClientSocket represents a Transmission Control Protocol (TCP) client endpoint of a StreamSocket. More...
class  Datagram
 The Datagram class implements an unrelated network packet for any unreliable transmission protocol (e.g. UDP). More...
class  DatagramSocket
 A DatagramSocket represents a User Datagram Protocol (UDP) Socket for sending and receiving single (short) datagram packets. More...
class  HTTPConnection
 A HTTPConnection implements a HTTP client connection as defined by RFC2616 Hypertext Transfer Protocol -- HTTP/1.1. More...
class  HTTPReceiver
class  InetAddress
 An InetAddress represents a BSD socket API compliant Internet Protocol (IPv4) specific SocketAddress. More...
class  InetDatagram
 An InetDatagram represents an UDP Internet Protocol (IP) specific Datagram. More...
class  MulticastAddress
 A MulticastAddress represents an Internet Protocol (IPv4) specific Multicast InetAddress. More...
class  MulticastSocket
 A MulticastSocket represents an Internet Protocol (IP) specific Multicast DatagramSocket that adds capabilities for joining multicast groups of other multicast hosts on the internet. More...
class  ServerSocket
 A ServerSocket represents a Transmission Control Protocol (TCP) server endpoint of a StreamSocket. It adds the capability to listen for and to accept other TCP client connections. More...
class  Socket
 A Socket class could be bound to a SocketAddress and provides the interface to generic BSD socket API compliant Socket properties. More...
class  SocketAddress
 A SocketAddress represents an abstract and protocol unspecific Socket address. More...
class  SocketSet
 A SocketSet resembles fd_set the BSD compliant set of sockets used with select and synchronous I/O multiplexing. More...
class  SSLClientSocket
 A SSLClientSocket represents a Secure Socket Layer (TCP) client endpoint of a StreamSocket. More...
class  SSLProtocol
 The SSLProtocol provides a Secure Socket Layer protocol implementation. More...
class  SSLServerSocket
 A SSLServerSocket represents a Secure Socket Layer (TCP) server endpoint of a StreamSocket. More...
class  StreamSocket
 A StreamSocket represents one endpoint of a bidirectional, reliable, in-order stream oriented connection as used with the Transmission Control Protocol (TCP). More...
class  PCQueue
 A PCQueue implements a threadsafe blocking Producer/Consumer Queue supporting a maximum size. More...
class  Semaphore
 The Semaphore implements a counting semaphore with the ability of claiming or returning more than one unit from the semaphore and with support for timeout detection. More...
class  SharedPtr
 The SharedPtr template is used to store a pointer of type T* which must have been allocated by new and which is automatically deleted when the SharedPtr instance is deallocated. More...
class  RefCountPtr
 The RefCountPtr template is used by SharedPtr to store a shared pointer that keeps a reference counter. More...
class  StreamReader
 An StreamReader is a Stream implementation that is based on std::istream associated to a name. More...
class  Strings
 The Strings class provides lots of string conversion and formatting functions. More...
class  Synchronized
 A Synchronized is used to automatically lock and unlock a mutex. More...
class  System
 The System class provides access to shared static data structures that need to exist exactly once in each process like the System properties or the System mutex. More...
class  Thread
 A Thread represents a thread of execution within a process that could be run synchronously or started asynchronously and joined later to regain synchronization. More...
class  Throttle
 A Throttle could either be used to measure or to limit the througput per second. More...
class  URL
 The URL class implements a uniform resource locator as referenced by RFC 2396 and RFC 3305 etc. More...
class  Wildcard
 Implementation of UN*X wildcards. More...
class  SCMHandle
 This class takes care of releasing a SCM Handles within its destructor by calling CloseServiceHandle as required. More...
class  Service
 A Service is a background task, that usually does not require any user interaction. More...
class  Win32SDK
 Win32 SDK related functions. More...
class  XMLFormatter
 The XMLFormatter class provides a simple XML formatter by implementing the Formatter interface. More...

Typedefs

typedef std::map< std::wstring,
std::wstring
Properties
 Type used to store properties like System properties.
typedef pthread_t ThreadId
 Either pthread_t (if compiled with pthread support) or unsigned long (if compiled for _WIN32).

Enumerations

enum  ClosingMode { UniDirectional, BiDirectional }
 The closing modes of Connection::close(ClosingMode). More...

Functions

template<typename IntType >
IntType getBE (const void *data)
 Parse an integer type IntType in big endianess byte order from the address given by data.
template<typename IntType >
IntType getLE (const void *data)
 Parse an integer type IntType in little endianess byte order from the address given by data.
template<typename IntType >
void setBE (void *dest, IntType value)
 Stores the integer type value into address given by dest in big endianess byte order.
template<typename IntType >
void setLE (void *dest, IntType value)
 Stores the integer type value into address given by dest in little endianess byte order.
template<typename Ptr >
bool lessPtr (const Ptr *left, const Ptr *right)
 Comparison of Pointers usable with e.g. sort(RandomAccessIterator, RandomAccessIterator, BinaryPredicate)
template<typename Stream >
void dump (std::ostream &out, Stream &stream, typename Stream::off_type size=0)
 Dump size bytes from the current stream position of stream to the std::ostream out.
template<typename T , typename Stream >
Stream::off_type read (std::basic_string< T > &buffer, Stream &stream, typename Stream::off_type size)
 Try to read size bytes from stream into buffer.
template<typename IntType , typename Reader >
bool readLE (IntType &value, Reader &reader)
 Extracts an integer type in little endian byte order from reader at the current reader position.
template<typename IntType , typename Writer >
void writeLE (const IntType &value, Writer &writer)
 Writes an integer type in little endian byte order to writer at the current writer position.

Variables

class MICXX_EXPORT Datagram
class MICXX_EXPORT Buffer
class MICXX_EXPORT Mutex
class MICXX_EXPORT Log
class MICXX_EXPORT Exception
class MICXX_EXPORT Thread

Detailed Description

The Micro C++ Library.

Author:
Norbert Klose (norbert.klose@web.de)
Date:
December, 2006

Typedef Documentation

Type used to store properties like System properties.

Author:
Norbert Klose

micxx::Properties are a simple set of keys/value pairs. They could either

  • be parsed from command line arguments like -Dname=value, or
  • be loaded from Java 2 Platform Standard Ed. compliant configuration files.
See also:
micxx::System::parseProperties(const std::wstring&, Properties&)
micxx::System::getProperties()
micxx::System::parseArgs(int, const char**, std::vector<std::wstring>&, Properties&)
micxx::System::getArgs()

Either pthread_t (if compiled with pthread support) or unsigned long (if compiled for _WIN32).


Enumeration Type Documentation

The closing modes of Connection::close(ClosingMode).

Enumerator:
UniDirectional 
BiDirectional 

Function Documentation

template<typename Stream >
void micxx::dump ( std::ostream &  out,
Stream &  stream,
typename Stream::off_type  size = 0 
)

Dump size bytes from the current stream position of stream to the std::ostream out.

Parameters:
outThe std::ostream, where to dump number of size bytes from the current stream position to
streamThe stream to dump from.
sizeIf 0, dump the whole rest.
{
    __MICXXTRY__
    unsigned char buffer[512];
    typename Stream::off_type readSize = 0, currentSize = 0;
    if (!size)
    {
        size = ~((typename Stream::off_type)0);
    }
    while (size > 0 && readSize >= currentSize)
    {
        currentSize = size < sizeof(buffer) ? size : sizeof(buffer);
        typename Stream::pos_type acurrentPosition = stream.tellg();
        readSize = stream.read(buffer, currentSize);
        Strings::dump(out, buffer, readSize, acurrentPosition);
        size -= readSize;
    }
    __MICXXEND__
}
template<typename IntType >
IntType micxx::getBE ( const void *  data)

Parse an integer type IntType in big endianess byte order from the address given by data.

Parameters:
datathe address from where to read the integer in big endianess byte order
Returns:
The integer resulting from the first sizeof(IntTypes) bytes of data in big endianess byte order, or
0, if data is 0.
{
    const unsigned char * p = static_cast<const unsigned char*>(data);
    IntType result = 0;
    for (std::size_t i = 0, s = 8 * (sizeof(IntType) - 1); i < sizeof(IntType); ++i, s -= 8)
    {
        result |= static_cast<IntType>(p[i]) << s;
    }
    return result;
}
template<typename IntType >
IntType micxx::getLE ( const void *  data)

Parse an integer type IntType in little endianess byte order from the address given by data.

Parameters:
datathe address from where to read the integer in little endianess byte order
Returns:
The integer resulting from the first sizeof(IntType) bytes of data in little endianess byte order, or
0, if data is 0.
{
    const unsigned char * p = static_cast<const unsigned char*>(data);
    IntType result = 0;
    for (std::size_t i = 0, s = 0; i < sizeof(IntType); ++i, s += 8)
    {
        result |= static_cast<IntType>(p[i]) << s;
    }
    return result;
}
template<typename Ptr >
bool micxx::lessPtr ( const Ptr *  left,
const Ptr *  right 
)

Comparison of Pointers usable with e.g. sort(RandomAccessIterator, RandomAccessIterator, BinaryPredicate)

{
    if (!left)
    {
        return true;
    }
    if (!right)
    {
        return false;
    }
    return *left < *right;
};
template<typename T , typename Stream >
Stream::off_type micxx::read ( std::basic_string< T > &  buffer,
Stream &  stream,
typename Stream::off_type  size 
)

Try to read size bytes from stream into buffer.

Parameters:
bufferThe buffer where the read content will be appended to.
streamThe stream to read from.
sizeIf 0, read the whole rest.
Returns:
The number of bytes read.
{
    __MICXXTRY__
    T abuffer[512];
    typename Stream::off_type readSize = 0, currentSize = 0, totalSize = 0;
    if (!size)
    {
        size = ~((typename Stream::off_type)0);
    }
    while (size > 0 && readSize >= currentSize)
    {
        currentSize = size < sizeof(buffer) ? size : sizeof(buffer);
        readSize = stream.read(abuffer, currentSize);
        totalSize += readSize;
        buffer.append(abuffer, readSize);
        size -= readSize;
    }
    return totalSize;
    __MICXXEND__
}
template<typename IntType , typename Reader >
bool micxx::readLE ( IntType &  value,
Reader &  reader 
)

Extracts an integer type in little endian byte order from reader at the current reader position.

Returns:
true, if an integer has been read successfully,
false, if EOF was encountered when the first byte was read.
{
    __MICXXTRY__
    value = static_cast<IntType>(0);
    unsigned char cs[sizeof(IntType)];
    typename Reader::off_type bytesRead =
        reader.read(cs, sizeof(cs) / sizeof(typename Reader::char_type));
    if (!bytesRead)
    {
        return false;
    }
    if ((bytesRead * sizeof(typename Reader::char_type)) != sizeof(cs))
    {
        throw Exception(__FILE__, __LINE__, "unexpected end of file: %u bytes missing",
                        (unsigned) (sizeof(cs) - bytesRead));
    }
    for (typename Reader::off_type i = 0, s = 0; i < sizeof(cs); ++i, s += 8)
    {
        value |= static_cast<IntType>(cs[i]) << s;
    }
    return true;
    __MICXXEND__
}
template<typename IntType >
void micxx::setBE ( void *  dest,
IntType  value 
)

Stores the integer type value into address given by dest in big endianess byte order.

Parameters:
destThe address where to store the value in big endianess byte order.
valueThe value to be stored.
{
    unsigned char * bytes = static_cast<unsigned char*>(dest) + sizeof(IntType) - 1;
    IntType byteMask = static_cast<IntType>(0xFF);
    for (std::size_t i = 0, s = 0; i < sizeof(IntType); ++i, s += 8)
    {
        *bytes = static_cast<unsigned char>((value & byteMask) >> s);
        byteMask <<= 8;
        --bytes;
    }
}
template<typename IntType >
void micxx::setLE ( void *  dest,
IntType  value 
)

Stores the integer type value into address given by dest in little endianess byte order.

Parameters:
destThe address where to store the value in big endianess byte order.
valueThe value to be stored.
{
    unsigned char * bytes = static_cast<unsigned char*>(dest);
    IntType byteMask = static_cast<IntType>(0xFF);
    for (std::size_t i = 0, s = 0; i < sizeof(IntType); ++i, s += 8)
    {
        *bytes = static_cast<unsigned char>((value & byteMask) >> s);
        byteMask <<= 8;
        ++bytes;
    }
}
template<typename IntType , typename Writer >
void micxx::writeLE ( const IntType &  value,
Writer &  writer 
)

Writes an integer type in little endian byte order to writer at the current writer position.

{
    __MICXXTRY__
    unsigned char cs[sizeof(IntType)];
    IntType mask = (unsigned char) 0xFF;
    for (size_t i = 0, s = 0; i < sizeof(IntType); ++i, s += 8)
    {
        cs[i] = (value & mask) >> s;
        mask <<= 8;
    }
    writer.write(static_cast<const typename Writer::char_type*>(cs),
                 static_cast<typename Writer::off_type>(
                     sizeof(IntType) / sizeof(typename Writer::char_type)));
    __MICXXEND__
}

Variable Documentation

class MICXX_EXPORT micxx::Buffer
class MICXX_EXPORT micxx::Datagram
class MICXX_EXPORT micxx::Exception
class MICXX_EXPORT micxx::Log
class MICXX_EXPORT micxx::Mutex
class MICXX_EXPORT micxx::Thread