ui-utilcpp
1.8.5
|
Namespace for ui-utilcpp. More...
Namespaces | |
Http | |
Namespace for all HTTP related code. | |
Sys | |
Namespace for system/library calls. | |
Data Structures | |
class | AlphaNumericKey |
Class using boost::mt19937 as random engine. More... | |
class | auto_base |
Base adapter class to hold a pointer that can't be freed using standard "delete". More... | |
class | auto_cvec |
Control freeing of C vector pointers via delete[]. More... | |
class | auto_free |
Control freeing of memory via std::free. More... | |
class | AutoRemoveFile |
Guarantuee to run "remove(2)" on path in destructor. More... | |
class | BSDFileMutex |
Mutex For BSD Advisory File Locking. More... | |
class | Cap |
C++ encapsulation for libcap's 'cap_t'. More... | |
class | CapScope |
Helper to enable effective capabilities safely for a scope. More... | |
class | CFileStream |
Simple exception-save FILE abstraction. More... | |
class | CLOption |
Most general class for a command line option. Use this class for a option without argument. More... | |
class | CLOptionArg |
Class representing a command line option with mandatory argument. More... | |
class | CLOptionOptArg |
Class representing a command line option with optional argument. More... | |
class | CodeException |
Adding code facility to Exception. More... | |
class | Conversion |
Holder class for conversion results. More... | |
class | Converter |
Factory for Conversions. More... | |
class | Cpp2Base64Converter |
Converter for Base64 encoding, using CommonCpp functions. More... | |
class | CStrArray |
Helper to construct/use C-String arrays ("char **"), occasionally needed by some c functions. More... | |
class | EUIDSwap |
Helper class to get a scope executed with some other effective uid. More... | |
class | Exception |
Generic exception class for namespace UI::Util. More... | |
class | FDTypeBuf |
Template IO stream buffer for all file descriptors types. More... | |
class | FDTypeStream |
IO stream for file descriptors. More... | |
class | File |
File representation. More... | |
class | FileDescriptor |
File Descriptor Holder Class. More... | |
class | ForkThread |
Simple encapsulation of fork(2) using common thread syntax. More... | |
class | FQuotaInfo |
Variant of QuotaInfo from any file in FS. More... | |
class | FsInfo |
File system information abstraction. More... | |
class | GetOpt |
Abstraction class for GNU getopt_long(3). More... | |
class | IConvConverter |
Character set converter, using libc's "iconv" directly. More... | |
class | IdnEMailConverter |
Converter from an-char-encoded string with randomly placed email-adresse -> the same string w/ domain parts magically replaced with IDN-encoding. More... | |
class | INetSocket |
INet Socket. More... | |
class | LibRecodeConverter |
Converter based on librecode (see there). More... | |
class | MutexLock |
Mutex Lock class; an object of this class will guard a scope. More... | |
class | PIDFile |
Write and keep pid file during lifetime. More... | |
class | PosixFileMutex |
Mutex For Posix Advisory File Locking. More... | |
class | PosixRegex |
Wrapper class for POSIX.2 regex functions. More... | |
class | ProcessThread |
Simple encapsulation for any process based threading system. More... | |
class | QuotaInfo |
Quota information abstraction. More... | |
class | RealPath |
Get canonical absolute path name (mutex-protected) More... | |
class | RealTimeStamp |
RealTimeStamp class encapsulating "gettimeofday". More... | |
class | Recoder |
Meta converter class: converter switcher and generic interface. More... | |
class | RecoderCache |
This can be used to cache recoder instances. More... | |
class | Rfc2047Converter |
Converter charEncoding -> rfc2047 (MIME). More... | |
class | Rfc3490Utf8Converter |
Converter UTF-8 <-> rfc3490 (IDN). More... | |
class | ScopeRealTime |
Log time used for a scope. More... | |
class | Socket |
Socket abstraction. More... | |
class | SocketPair |
socketpair(2) abstraction. More... | |
class | StdFreeConversion |
Conversion w/ std::free call on the supplied C-String. More... | |
class | StringConversion |
Conversion w/ std::string holder. More... | |
class | SysLogMono |
C++ Abstraction of syslog(3) for mono threaded applications. More... | |
class | SysLogMonoSingleton |
Singleton class holding one SysLogMono object. More... | |
class | UnixSocket |
Unix Socket. More... | |
class | URLConverter |
Converter for URL-Encoding. More... | |
class | XConversion |
a class to convert between different systems. More... | |
Typedefs | |
typedef std::ios_base &(* | StreamModifier) (std::ios_base &) |
Stream modifier function (is there a std:: type??). | |
Shortcuts for often used types and convenience stream operators. | |
typedef std::vector< std::string > | StrVec |
typedef std::list< std::string > | StrList |
typedef std::map< std::string, std::string > | StrMap |
Functions | |
std::string | getenv (std::string const &name) |
Like getenv(3), but returns empty string when env is missing. | |
std::string | guessConfFile (std::string const &id, std::string const &suffix=".conf") |
Guess a config file (/etc/id.conf or ~/.id.conf). | |
void | fileCopy (std::string const &src, std::string const &dest) |
File copy from file names. | |
bool | fileExists (std::string const &fName) |
Check if a file exists using stat(2). More... | |
time_t | fileModificationTime (std::string const &path) |
Get the modification time for a file. More... | |
std::string | realpath (std::string const &path) |
Get canonical absolute path name. More... | |
template<typename ElType > | |
void | delAnySeqContainer (std::vector< ElType * > &l) throw () |
Run "delete" on all vector elements, and clear the vector. *>. More... | |
template<typename ElType > | |
void | freeAnySeqContainer (std::vector< ElType * > &l) throw () |
Run "std::free" on all vector elements, and clear the vector. *>. More... | |
template<typename ElType > | |
void | delStringMap (std::map< std::string, ElType * > &l) throw () |
Utility to delete any map<string, anytype>. More... | |
template<typename K > | |
std::list< K >::iterator | reverse_lfind (std::list< K > &l, K const &key) |
Reverse "find" for lists. More... | |
std::string | strVec2Str (StrVec const &strVec, std::string const &sep) |
std::string | strerror (int const &errNo=errno) |
Save wrapper for strerror. Always use this instead of strerror directly. | |
std::string | getlineCRLF (std::istream &s) |
Like std::getline, but also rips of trailing "CR" when line break was CRLF. | |
std::string | asciiCAPS (std::string const &in, bool const upper=true) |
ASCII CAPS converter for strings (using std::tolower|upper). | |
std::string & | str2Ascii (std::string &s) |
Replace all non-ASCII characters to '?' in string. | |
char * | strdup (char const *s) |
BSD style "strdup" implementation (is not C standard). See strdup(3). | |
StrVec | strtok (std::string const &s, std::string const &delim=",", std::string const &prefix="", std::string const &postfix="") |
Generate any STL container of strings from a token string. More... | |
StrVec | strtoks (std::string const &s, std::string const &delims=",", std::string const &prefix="", std::string const &postfix="") |
Like strtok, but you can use a list of one-char delimiters (delims in strtoks) instead of a fixed delimiter string (delim in strtok). | |
std::string | istream2String (std::istream &f, int const blockSize=1024) |
Istream-to-string converter. More... | |
std::string | md5sum (std::string const &data) |
template<typename T > | |
T | Default () |
Defaults values for some types via template specialization. | |
template<> | |
int | Default< int > () |
Default-Specialising. | |
template<> | |
float | Default< float > () |
Default-Specialising. | |
template<> | |
double | Default< double > () |
Default-Specialising. | |
template<> | |
long int | Default< long int > () |
Default-Specialising. | |
template<> | |
bool | Default< bool > () |
Default-Specialising. | |
template<> | |
std::string | Default< std::string > () |
Default-Specialising. | |
template<typename out_type > | |
std::pair< out_type, bool > | eato (std::string const &t, StreamModifier const m=0) |
String-to-anything converter with error handling. More... | |
template<typename out_type > | |
out_type | ato (std::string const &t, StreamModifier const m=0) |
String-to-anything converter with default values on error. More... | |
template<typename in_type > | |
std::pair< std::string, bool > | etos (in_type const &t, StreamModifier const m=0, int w=0, char f=' ') |
Anything-to-string converter with error handling. More... | |
template<typename C > | |
std::string | join (std::string const &expr, C const &list) |
join a list,vector,set, ... with the connector string More... | |
template<typename Byte > | |
std::vector< Byte > | istream2Vector (std::istream &f, int const blockSize=1024) |
Read any stream into any byte vector. More... | |
void | fd2DevNull (int const &fd, mode_t const &mode) |
Close fd and reopen on "/dev/null" using mode. | |
void | daemonize (bool closeStdFds=true, bool changeToRootdir=true, bool resetUMask=true) |
Use fork(2) to daemonize current program in a new session id. More... | |
long int | getTimeValSec () |
Get "sec"-part from gettimeofday(2). | |
long int | getTimeValUSec () |
Get "usec"-part from gettimeofday(2). | |
unsigned int | nanosleep (unsigned int seconds, long int nanoseconds) |
No Signal Sleep: Using POSIX nanosleep(2). More... | |
unsigned int | nssleep (unsigned int seconds) |
No Signal Seconds Sleep: Using POSIX nanosleep(2). More... | |
unsigned int | nsnsleep (long int nanoseconds) |
No Signal Nano Sleep. More... | |
std::ostream & | operator<< (std::ostream &os, RealTimeStamp const &rt) |
Streaming operator for RealTimeStamp. | |
Check whether token is in tokens. | |
bool | isToken (std::string const &token, StrVec const &tokensVec, int const match) |
bool | isToken (std::string const &token, std::string const &tokens, std::string const &delim, int const match) |
Mass string replace. | |
std::string & | strrpl (std::string &source, std::string const &token, std::string const &reptoken) |
std::string | strrpl (std::string const &source, std::string const &token, std::string const &reptoken) |
Anything-to-string converter with empty string on error. @see etos. | |
template<typename in_type > | |
std::string | tos (in_type const &t, StreamModifier const m=0, int w=0, char f=' ') |
template<typename in_type > | |
std::string | tos (in_type const &t, int w, char f=' ') |
Generate arbitrary length pseudo random keys with alphanumeric ASCII characters. | |
std::string | genAlphaNumericKey (int len=8) |
For compatibility only. | |
Namespace for ui-utilcpp.
out_type UI::Util::ato | ( | std::string const & | t, |
StreamModifier const | m = 0 |
||
) |
String-to-anything converter with default values on error.
void UI::Util::daemonize | ( | bool | closeStdFds = true , |
bool | changeToRootdir = true , |
||
bool | resetUMask = true |
||
) |
Use fork(2) to daemonize current program in a new session id.
closeStdFds | Whether to close fd 0,1 and 2 (and re-open them to /dev/null). This is recommended for all production daemons. |
changeToRootdir | Will do a chdir(2) to "/". This is to avoid all errors due to a later remove/change of the cwd. |
resetUMask | Resets umask to "0". |
References fd2DevNull().
void UI::Util::delAnySeqContainer | ( | std::vector< ElType * > & | l | ) | |
throw | ( | ||||
) |
Run "delete" on all vector elements, and clear the vector. *>.
I.e. empty whole vector && call destructor for each ElType * - element.
Referenced by UI::Util::CmdLine::CmdLine::CmdLine().
void UI::Util::delStringMap | ( | std::map< std::string, ElType * > & | l | ) | |
throw | ( | ||||
) |
Utility to delete any map<string, anytype>.
I.e. empty whole map && call destuctor for each ElType * - element.
Referenced by UI::Util::Recoder::Recoder().
std::pair<out_type, bool> UI::Util::eato | ( | std::string const & | t, |
StreamModifier const | m = 0 |
||
) |
String-to-anything converter with error handling.
t | String to convert. |
m | Optional stream modifier like std::hex. |
std::pair<std::string, bool> UI::Util::etos | ( | in_type const & | t, |
StreamModifier const | m = 0 , |
||
int | w = 0 , |
||
char | f = ' ' |
||
) |
Anything-to-string converter with error handling.
t | Value to convert. |
m | Optional stream modifier like std::hex. |
w | Argument for std::setw() modifier. |
f | Argument for std::setfill() modifier. |
bool UI::Util::fileExists | ( | std::string const & | fName | ) |
Check if a file exists using stat(2).
fName | File name to check. |
Referenced by UI::Util::PIDFile::guess().
time_t UI::Util::fileModificationTime | ( | std::string const & | path | ) |
Get the modification time for a file.
path | File to check. |
void UI::Util::freeAnySeqContainer | ( | std::vector< ElType * > & | l | ) | |
throw | ( | ||||
) |
Run "std::free" on all vector elements, and clear the vector. *>.
I.e. empty whole vector && call destructor for each ElType * - element.
std::string UI::Util::istream2String | ( | std::istream & | f, |
int const | blockSize = 1024 |
||
) |
Istream-to-string converter.
Referenced by istream2Vector().
std::vector<Byte> UI::Util::istream2Vector | ( | std::istream & | f, |
int const | blockSize = 1024 |
||
) |
Read any stream into any byte vector.
References istream2String().
std::string UI::Util::join | ( | std::string const & | expr, |
C const & | list | ||
) |
join a list,vector,set, ... with the connector string
e.g. the string list 'a', 'b', 'c', 'd' joined with ',' will return 'a,b,c,d'
As C needs to supply a C::const_iterator C.begin() C.end() and ++opertator e.g. std::vector<std::string>
Referenced by UI::Util::XConversion::base64Decode().
unsigned int UI::Util::nanosleep | ( | unsigned int | seconds, |
long int | nanoseconds | ||
) |
No Signal Sleep: Using POSIX nanosleep(2).
Referenced by nsnsleep(), and nssleep().
unsigned int UI::Util::nsnsleep | ( | long int | nanoseconds | ) |
unsigned int UI::Util::nssleep | ( | unsigned int | seconds | ) |
No Signal Seconds Sleep: Using POSIX nanosleep(2).
You may use this as drop-in replacement for sleep(3) if you do not want any signals to be raised.
References nanosleep().
std::string UI::Util::realpath | ( | std::string const & | path | ) |
Get canonical absolute path name.
This effectively works like realpath(3), wrapped up for C++, w/ exception error handling.
References UI_THROW_CODE.
Referenced by reverse_lfind().
std::list<K>::iterator UI::Util::reverse_lfind | ( | std::list< K > & | l, |
K const & | key | ||
) |
Reverse "find" for lists.
l | The list to search. |
key | The key to find. |
References realpath().
StrVec UI::Util::strtok | ( | std::string const & | s, |
std::string const & | delim, | ||
std::string const & | prefix, | ||
std::string const & | postfix | ||
) |