Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

Dv::Util is the namepace for this package. More...


Classes

class  Dv::Util::DateError
 A runtime exception thrown by some Date operations. More...
class  Dv::Util::Date
 A simple Date class. More...
class  Dv::Util::Debug< T >
 A simple class template for dumping an object to a stream. More...
class  Dv::Util::Dispatcher< Application, Input, Value >
 A class template framework to dispatch control based on some value. More...
struct  Dv::Util::Dispatcher< Application, Input, Value >::Entry
 Type of entry in dispatch table: if value is key, h will be called. More...
class  Dv::Util::enum_parser< E >
 Convenient class template to support conversion of enum types to/from strings. More...
struct  Dv::Util::enum_parser< E >::enum_entry
 Type of entry in enum_table. More...
class  Dv::Util::fdstreambuf
 A streambuf specialization that manages a file descriptor and handles timeouts. More...
class  Dv::Util::FileError
 A runtime exception thrown by some File operations. More...
class  Dv::Util::File
 A File objects represents a pathname, possibly an existing file. More...
class  Dv::Util::Directory
 A Directory represents a pathname that refers to a possibly non-existing directory. More...
class  Dv::Util::filterstreambuf< Filter >
 A streambuf specialization that cooperates with a filter class object. More...
class  Dv::Util::includestream
 A stream that can include other files. More...
class  Dv::Util::includestream::IncludeFilter
 Implements Filter interface for filterstreambuf. More...
class  Dv::Util::logstream
 A logstream is an ostream useful for logging. More...
class  Dv::Util::logstream::LogFilter
 Implements Filter interface for filterstreambuf. More...
class  Dv::Util::nocommentstream
 A nocommentstream is an istream that strips '#' comments. More...
class  Dv::Util::nocommentstream::NoCommentFilter
 Implements Filter interface for filterstreambuf. More...
class  Dv::Util::Int
 Class wrapper for int. More...
class  Dv::Util::Long
 Class wrapper for long. More...
class  Dv::Util::Double
 Class wrapper for double. More...
class  Dv::Util::Duration
 Class representing a duration. More...
class  Dv::Util::Period
 A Period is simply a Date with a Duration. More...
class  Dv::Util::PropsException
 Exception class associated with Props. More...
class  Dv::Util::Props
 A propert list class. More...
class  Dv::Util::Props::Value
 A class representing a reference to a key-value pair in a Props object. More...
class  Dv::Util::Props::ConstValue
 A class representing a reference to a key-value pair in a Props object. More...
class  Dv::Util::pstream
 A wrapper that makes a stream of popen(command,"r"). More...
class  Dv::Util::Random
 Class supporting random number generation. More...
class  Dv::Util::ref< T >
 Reference-counted pointers. More...
class  Dv::Util::SystemError
 Exception class associated with a system error. More...
class  Dv::Util::teestream
 A teestream object extends the unix ``tee'' command. More...
class  Dv::Util::teestream::Tee
 Implements Filter interface for filterstreambuf. More...
class  Dv::Util::Tty
 An iostream class that provides raw unbuffered input and output to /dev/tty. More...
class  Dv::Util::UserError
 Exception class, thrown by some User function members. More...
class  Dv::Util::User
 A class representing a Unix user. More...

Functions

template<typename E> const char * enum2str (E e)
 Convenience function to convert an enum value to a string.
template<typename E> E str2enum (const std::string &s)
 Convenience function to convert a string to an enum value.
void make_daemon (const std::string &pidfilename="") throw (std::runtime_error)
 Make this process into a daemon.
std::string ntostr (int i, const char *fmt=0)
 Produces a string representation of its int argument.
std::string ntostr (unsigned int u, const char *fmt=0)
 Produces a string representation of its unsigned int argument.
std::string ntostr (long l, const char *fmt=0)
 Produces a string representation of its long argument.
std::string ntostr (unsigned long ul, const char *fmt=0)
 Produces a string representation of its unsigned long argument.
std::string ntostr (double d, unsigned int precision=7, const char *fmt=0)
 Produces a string representation of its double argument.
bool cstr2long (const char *p, long &l, int base=0)
 Try to convert the initial part of a C string to a long.
bool cstr2ulong (const char *p, unsigned long &ul, int base=0)
 Try to convert the initial part of a C string to an unsigned long.
bool cstr2double (const char *p, double &d)
 Try to convert the initial part of a C string to a double.
std::string & s2lower (std::string &s)
 Change (in-place) all chars in string to lower case.
std::string & s2upper (std::string &s)
 Change (in-place) all chars in string to upper case.
std::string & strim (std::string &s)
 Remove leading and trailing white noise (' ', '\n', '\t') from string.
char * strim (char *pc)
 Remove leading and trailing white noise (' ','\n','\t') from C string.
Propsenv2props (Props &props)
 This function adds its environment to its props parameter.
std::string strstream2str (std::strstream &ss)
 Safely convert ss to string.
std::string strstream2str (std::ostrstream &ss)
 Safely convert ss to string.
std::string & strstream2str (std::strstream &ss, std::string &s)
 Safely convert ss to string s, return s.
std::string & strstream2str (std::ostrstream &ss, std::string &s)
 Safely convert ss to string s, return s.
template<typename T> std::string tostring (const T &t)
 A function that converts anything that can be written to a stream to a string (using the ostringstream class).
template<typename T> bool fromstring (T &t, const std::string &s)
 A function that converts anything that can be read from a stream to a string (using the istringstream class).


Detailed Description

Dv::Util is the namepace for this package.

Function Documentation

template<typename E>
const char* enum2str e  ) 
 

Convenience function to convert an enum value to a string.

Parameters:
e Enum value.
Returns:
C-string representation of e (never 0).
Exceptions:
std::logic_error if string representation not found.
Definition at line 72 of file enum2str.h.

template<typename E>
E str2enum const std::string &  s  ) 
 

Convenience function to convert a string to an enum value.

Parameters:
s string representing an enum value.
Returns:
enum value represented by string.
Exceptions:
std::logic_error if string does not represent an E value.
Definition at line 83 of file enum2str.h.

void make_daemon const std::string &  pidfilename = ""  )  throw (std::runtime_error)
 

Make this process into a daemon.

Become process session leader, close fd 0,1,2, no controlling terminal, chdir("/");

Parameters:
pidfilename to which pid of daemon process will be written if the size of the filename is not 0.
Exceptions:
runtime_error upon error.

std::string ntostr int  i,
const char *  fmt = 0
 

Produces a string representation of its int argument.

The representation is determined by a sprintf format string.

Parameters:
i integer to represent
fmt format C-string, the default (if 0) is "%d".
Returns:
string representation of i, according to fmt.
Warning:
The buffer size is 20.

std::string ntostr unsigned int  u,
const char *  fmt = 0
 

Produces a string representation of its unsigned int argument.

The representation is determined by a sprintf format string.

Parameters:
u unsigned integer to represent
fmt format string, the default (if 0) is "%u".
Returns:
string representation of u, according to fmt.
Warning:
The buffer size is 20.

std::string ntostr long  l,
const char *  fmt = 0
 

Produces a string representation of its long argument.

The representation is determined by a sprintf format string.

Parameters:
l long integer to represent
fmt format string, the default (if 0) is "%ld".
Returns:
string representation of l, according to fmt.
Warning:
The buffer size is 20.

std::string ntostr unsigned long  ul,
const char *  fmt = 0
 

Produces a string representation of its unsigned long argument.

The representation is determined by a sprintf format string.

Parameters:
ul unsigned long integer to represent
fmt format string, the default (if 0) is "%lu".
Returns:
string representation of ul, according to fmt.
Warning:
The buffer size is 20.

std::string ntostr double  d,
unsigned int  precision = 7,
const char *  fmt = 0
 

Produces a string representation of its double argument.

The representation is determined by a sprintf format string.

Parameters:
d unsigned long integer to represent
precision number of digits after decimal point in representation
fmt format string, the default (if 0) is "%.Pf".
Returns:
string representation of d, according to fmt and precision.
Warning:
The buffer size is 20.

bool cstr2long const char *  p,
long &  l,
int  base = 0
 

Try to convert the initial part of a C string to a long.

Parameters:
p C-string to convert
l long receiving the value
base to be used in the conversion. The default base (0) reads decimal or octal (if the string starts with 0) numbers.
Returns:
true iff an initial part of the C string p can be converted to a long value.
Warning:
If decimal is necessary, specify base 10 explicitely!

bool cstr2ulong const char *  p,
unsigned long &  ul,
int  base = 0
 

Try to convert the initial part of a C string to an unsigned long.

Parameters:
p C-string to convert
ul unsigned long receiving the value
base to be used in the conversion. The default base (0) reads decimal or octal (if the string starts with 0) numbers.
Returns:
true iff an initial part of the C string p can be converted to an unsigned long value.
Warning:
If decimal is necessary, specify base 10 explicitely!

bool cstr2double const char *  p,
double &  d
 

Try to convert the initial part of a C string to a double.

Parameters:
p C-string to convert
d double receiving the value
Returns:
true iff an initial part of the C string p can be converted to a double value.

std::string& s2lower std::string &  s  ) 
 

Change (in-place) all chars in string to lower case.

Parameters:
s string to convert.
Returns:
reference to first argument.

std::string& s2upper std::string &  s  ) 
 

Change (in-place) all chars in string to upper case.

Parameters:
s string to convert.
Returns:
reference to first argument.

std::string& strim std::string &  s  ) 
 

Remove leading and trailing white noise (' ', '\n', '\t') from string.

The argument is changed and returned

Parameters:
s string to trim
Returns:
reference to the argument

char* strim char *  pc  ) 
 

Remove leading and trailing white noise (' ','\n','\t') from C string.

Parameters:
pc C-string to trim.
Returns:
pointer to first non-white-space character in the argument.
Warning:
The argument is changed. Since the return value points to the first non-white-space char in the argument, the following is a recepy for disaster:
  char* pc = new char[10];
  ..
  pc = strim(pc);
  delete[] pc;

Props& env2props Props &  props  ) 
 

This function adds its environment to its props parameter.

It returns a reference to its parameter. See man (5) environ for information about the environment.

Parameters:
props to add environment variables to.
Returns:
reference to props.

std::string strstream2str std::strstream &  ss  ) 
 

Safely convert ss to string.

std::string strstream2str std::ostrstream &  ss  ) 
 

Safely convert ss to string.

std::string& strstream2str std::strstream &  ss,
std::string &  s
 

Safely convert ss to string s, return s.

std::string& strstream2str std::ostrstream &  ss,
std::string &  s
 

Safely convert ss to string s, return s.

template<typename T>
std::string tostring const T &  t  ) 
 

A function that converts anything that can be written to a stream to a string (using the ostringstream class).

Parameters:
t object for which a string representation is sought.
Returns:
a string representation of t.
Definition at line 18 of file tostring.h.

Referenced by Dv::Util::enum_parser< E >::enum2str().

template<typename T>
bool fromstring T &  t,
const std::string &  s
 

A function that converts anything that can be read from a stream to a string (using the istringstream class).

Parameters:
t object for which a string representation is sought.
s string representation from which t is to be computed
Returns:
true iff success
Definition at line 35 of file tostring.h.


dvutil-0.13.15 [30 December, 2004]