Dv::Util Namespace Reference

Classes

class  Bitmap
 A simple Bitmap class. More...
class  charraystreambuf
 A charraystreambuf provides a input streambuf interface to an existing character array. More...
class  charraystream
 A charraystream provides an input stream on an existing array of characters (which is not copied). More...
struct  identity
struct  CsListTag
 Class template to support defining containers using a comma separated list as in the following example. More...
class  Dispatcher
 A class template framework to dispatch control based on some value. More...
class  enum_parser
 Convenient class template to support conversion of enum types to/from strings. More...
class  fdstreambuf
 A streambuf specialization that manages a file descriptor and handles timeouts. More...
class  FileError
 A runtime exception thrown by some File operations. More...
class  File
 A File objects represents a pathname, possibly an existing file. More...
class  FileOperation
 Abstract class that can be subclassed to implement useful operations on files during a Directory::walk(). More...
class  DirectoryOperation
 Abstract class that can be subclassed to implement useful operations on directories during a Directory::walk(). More...
class  Directory
 A Directory represents a pathname that refers to a possibly non-existing directory. More...
class  filterstreambuf
 A streambuf specialization that cooperates with a filter class object. More...
class  includestream
 A stream that can include other files. More...
class  iopstream
 Start a process with its standard input/output connected to an iostream. More...
class  logstream
 A logstream is an ostream useful for logging. More...
class  nocommentstream
 A nocommentstream is an istream that strips '#' comments. More...
class  Process
 A class representing a process. More...
class  pstream
 A wrapper that makes a stream of popen(command,"r") or popen(command,"w") . More...
class  Random
 Class supporting random number generation using /dev/urandom Example usage. More...
class  SystemError
 Exception class associated with a system error. More...
class  teestream
 A teestream object extends the unix ``tee'' command. More...
class  Tty
 An iostream class that provides raw unbuffered input and output to /dev/tty. More...
class  User
 A class representing a Unix user. More...

Functions

std::ostream & operator<< (std::ostream &os, const Bitmap &map)
template<typename E >
const char * enum2str (E e)
 Convenience function to convert an enum value to a string.
template<typename 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.
size_t split_string (const std::string &input, const char separator, std::vector< std::string > &output) throw ()
 Split a string consisting of substrings separated by a separator character.

Function Documentation

std::ostream& Dv::Util::operator<< ( std::ostream &  os,
const Bitmap &  map 
) [inline]

Definition at line 103 of file bitmap.h.

References Dv::Util::Bitmap::print().

template<typename E >
const char* Dv::Util::enum2str ( e  )  [inline]

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 76 of file enum2str.h.

References Dv::Util::enum_parser< E >::enum2str().

template<typename E >
E Dv::Util::str2enum ( const std::string &  s  )  [inline]

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 85 of file enum2str.h.

References Dv::Util::enum_parser< E >::str2enum().

void Dv::Util::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.
size_t Dv::Util::split_string ( const std::string &  input,
const char  separator,
std::vector< std::string > &  output 
) throw ()

Split a string consisting of substrings separated by a separator character.

The substrings will be appended to the output vector.

Parameters:
input string, e.g. 'abcXdefX1234' (with 'X' the separator character)
separator char, e.g. 'X' in the above example
output vector, e.g. { 'abc', 'def', '1234' }
Returns:
the number of strings added to output, e.g. 3

Some borderline cases (each time with '/' as separator):

 '/abc/def' yields { '', 'abc', 'def' }
 'abc/def/1234' yields { 'abc', 'def', '1234' }
 'abc/def/' yields { 'abc', 'def', '' }

dvutil-1.0.10 [ 5 December, 2009]