#include "functions.h"
#include <cstdlib>
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <string.h>
#include <iostream>
Go to the source code of this file.
Functions | |
double | diffTimes (timeval *t1, timeval *t2) |
Calculates the difference between two given moments in time. | |
int | extractValue (const string &s, unsigned offset, const string &confFilename, int line) throw (ConfigSemanticException) |
Reads an integral value from the offset position of the string s and ensures there is no further input in s. | |
std::string | removeBlanks (string s) |
Trims given string from left and right side and throwing out the comment (starting in #). | |
bool | safe_strtoull (const char *str, uint64_t *out) |
Checks whether the given string begins with a valid unsigned value and writes the value to the out parameter. | |
std::string | pend_spaces_2_numb (unsigned long long val, unsigned count, bool append) |
Deprecated ;). | |
template<typename T, typename L> | |
ostream & | operator<< (ostream &out, pair< T, L > &p) |
Writes the given pair of objects to the out output. | |
ostream & | operator<< (ostream &out, map< int, char > &mymap) |
Writes the given map to the out output. | |
string | configurationDirectory (char *directory) |
Returns the configuration directory read from the config.h created during configure - default: '/etc/dreamcache'. | |
string | getPackageName () |
Returns the package name from the config.h created during . |
Definition in file functions.cpp.
string configurationDirectory | ( | char * | directory = NULL |
) |
Returns the configuration directory read from the config.h created during configure - default: '/etc/dreamcache'.
Pass argc and argv from the main() function to let user overwrite it.
directory | pass configuration directory path to override the default |
Definition at line 139 of file functions.cpp.
double diffTimes | ( | timeval * | t1, | |
timeval * | t2 | |||
) |
Calculates the difference between two given moments in time.
Definition at line 15 of file functions.cpp.
int extractValue | ( | const string & | s, | |
unsigned | offset, | |||
const string & | confFilename, | |||
int | line | |||
) | throw (ConfigSemanticException) |
Reads an integral value from the offset position of the string s and ensures there is no further input in s.
Extract numeric value from the given string.
s | Read string | |
offset | position of the value to be read | |
confFilename | Configuration file currently parsed | |
line | Line of the configuration file currently parsed |
ConfigSemanticException | When there is no integer at given position. |
Definition at line 19 of file functions.cpp.
string getPackageName | ( | ) |
Returns the package name from the config.h created during .
/configure - default: 'dreamcache'
Definition at line 154 of file functions.cpp.
ostream& operator<< | ( | ostream & | out, | |
map< int, char > & | mymap | |||
) |
Writes the given map to the out output.
out | the output | |
mymap | the map |
Definition at line 128 of file functions.cpp.
ostream& operator<< | ( | ostream & | out, | |
pair< T, L > & | p | |||
) | [inline] |
Writes the given pair of objects to the out output.
out | the output | |
p | the pair |
Definition at line 124 of file functions.cpp.
std::string removeBlanks | ( | string | s | ) |
Trims given string from left and right side and throwing out the comment (starting in #).
s | Input string |
Definition at line 38 of file functions.cpp.
bool safe_strtoull | ( | const char * | str, | |
uint64_t * | out | |||
) |
Checks whether the given string begins with a valid unsigned value and writes the value to the out parameter.
str | string to extract the value from | |
out | 64-bit variable pointer where the value will be written |
Definition at line 75 of file functions.cpp.