src/main/functions.cpp File Reference

Helping functions implementation. More...

#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 .


Detailed Description

Helping functions implementation.

Definition in file functions.cpp.


Function Documentation

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.

Parameters:
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.

Returns:
the difference in seconds

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.

Parameters:
s Read string
offset position of the value to be read
confFilename Configuration file currently parsed
line Line of the configuration file currently parsed
Returns:
Parsed integer
Exceptions:
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.

Parameters:
out the output
mymap the map

Definition at line 128 of file functions.cpp.

template<typename T, typename L>
ostream& operator<< ( ostream &  out,
pair< T, L > &  p 
) [inline]

Writes the given pair of objects to the out output.

Parameters:
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 #).

Parameters:
s Input string
Returns:
string without a comment and whitespaces at both ends

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.

Parameters:
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.


Generated on Fri Jan 8 10:38:13 2010 for dreamcache by  doxygen 1.5.5