Main Page   Class Hierarchy   Alphabetical List   Compound List   Compound Members  

util::Util Class Reference

#include <Util.h>

List of all members.


Detailed Description

A class that contains miscellaneous utility methods that do not fit anywhere else.


Static Public Methods

char * getData (const std::string &str)
 Get a newly allocated character array that contains a copy of the contents of str with a null at the end.

std::string substitute (const std::string &str, Map< std::string, std::string > &variables)
 Use the provided map of variable name - value pairs to replace all shell-syntax variables in str.

int parseInt (const std::string &str)
 Get an integer out of a string.

double parseDouble (const std::string &str)
 Get a double out of a string.

std::string parseName (const char *name)
 Parse a class name as returned by type_info::name() to a readable format.

template<class T> std::string getClassName (const T &obj)
 A handy template for getting the class name for an object.

std::string stripTemplateParameters (const std::string &className)
 Strip template paremeters from a class name.

template<class T> void writeItem (std::ostream &sout, const T &item) throw (io::IOException&)
 Write any type to a stream.

template<class T> void readItem (std::istream &sin, T &item) throw (io::IOException&)
 Read an object written by writeItem.

template<class T> void writeXMLItem (std::ostream &sout, const T &item) throw (io::IOException&,xml::XMLException&)
 Write any type to a stream as XML.

template<class T> void readXMLItem (std::istream &sin, T &item) throw (io::IOException&,xml::XMLException&)
 Read an object written by writeXMLItem.

template<class T> T * copyArray (const T *from, T *to, int len)
 Efficiently copy an array to another.


Member Function Documentation

template<class T>
T * util::Util::copyArray const T *    from,
T *    to,
int    len
[inline, static]
 

Efficiently copy an array to another.

This method uses direct memory transfers where possible.

template<class T>
std::string util::Util::getClassName const T &    obj [static]
 

A handy template for getting the class name for an object.

Parameters:
obj  the object whose name is to be fetched. The class of the object or at least one of its superclasses must contain a virtual method. Otherwise there will be no type information and the result is ambiguous.
Returns:
the class name formatted with parseName(const char*)
See also:
parseName(const char*)

char * util::Util::getData const std::string &    str [static]
 

Get a newly allocated character array that contains a copy of the contents of str with a null at the end.

Deprecated:
Use String::getData instead
See also:
String::getData(const string&)

double util::Util::parseDouble const std::string &    str [static]
 

Get a double out of a string.

Deprecated:
Use String::parseDouble instead
See also:
String::parseDouble(const string&)

int util::Util::parseInt const std::string &    str [static]
 

Get an integer out of a string.

Deprecated:
Use String::parseInt instead
See also:
String::parseInt(const string&)

string util::Util::parseName const char *    name [static]
 

Parse a class name as returned by type_info::name() to a readable format.

A typical return from type_info::name() is of the form "Q24test7MyClass", which converts to a more readable "test::MyClass".

Parameters:
a  class name as returned by type_info::name()
Returns:
a formatted class name

string util::Util::stripTemplateParameters const std::string &    className [static]
 

Strip template paremeters from a class name.

If the formatted name of a class is, say, mynamespace::Test<int>, the returned string says "mynamespace::Test".

string util::Util::substitute const std::string &    str,
Map< std::string, std::string > &    variables
[static]
 

Use the provided map of variable name - value pairs to replace all shell-syntax variables in str.

Parameters:
str  the string that has variables inserted
variables  the variables that are to be used
Deprecated:
Use String::substitute instead
See also:
String::substitute(const string&, Map<string,string>&)

template<class T>
void util::Util::writeItem std::ostream &    sout,
const T &    item
throw (io::IOException&) [static]
 

Write any type to a stream.

An object (or elementary type) written to a stream using this method should be possible to read unambiguously using the readItem method. The write/readItem pair is needed because some types (like strings) cannot be read from a stream once they have been written.

Parameters:
sout  the output stream
item  the object to be written

template<class T>
void util::Util::writeXMLItem std::ostream &    sout,
const T &    item
throw (io::IOException&,xml::XMLException&) [static]
 

Write any type to a stream as XML.

An object (or elementary type) written to a stream using this method should be possible to read unambiguously using the readXMLItem method. The write/readItem pair is needed because some types (like strings) cannot be read from a stream once they have been written.

Parameters:
sout  the output stream
item  the object to be written


The documentation for this class was generated from the following files:
Documentation generated on 11.09.2003 with Doxygen.
The documentation is copyrighted material.
Copyright © Topi Mäenpää 2003. All rights reserved.