tools.h File Reference

#include "mmstools/mmstypes.h"
#include <vector>
#include <stdarg.h>
#include <pthread.h>
#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>

Include dependency graph for tools.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


Defines

#define DEBUGMSG(ident, msg...)
#define DEBUGMSG_OUTSTR(ident, msg...)   printf("%s\n", ((string)(msg)).c_str())
#define DEBUGOUT(msg...)
#define DEBUGERR(msg...)
#define TRACEOUT(ident, msg...)
#define MSG2OUT(ident, msg...)   writeMessage2Stdout(ident, __FILE__, __LINE__, msg)
#define WRITE_MSG(ident, msg...)
#define WRITE_MSGI(msg...)
#define WRITE_ERR(ident, msg...)   fprintf(stderr, "%s: ", ident);fprintf(stderr, msg);printf("\n");
#define WRITE_ERRI(msg...)   fprintf(stderr, "%s: ", identity.c_str());fprintf(stderr, msg);printf("\n");

Functions

string substituteEnvVars (string input)
 substitutes environment variables in a string
string maskChars (string str)
string * strToUpr (string *src)
string strToUpr (string src)
string * strToLwr (string *src)
string strToLwr (string src)
int hexToInt (const char *in)
string ucharToHex (unsigned char in)
bool getCurrentTimeBuffer (char *dtbuf, char *datebuf=NULL, char *timebuf=NULL, time_t *clock=NULL)
bool getCurrentTimeString (string *dtstr, string *datestr=NULL, string *timestr=NULL, time_t *clock=NULL)
string getDayOfWeek (time_t *clock=NULL)
void initLogging (char *Iam, char *logfile)
string getSimpleTimeString ()
void writeMessage (const char *ctrl,...)
int strToInt (string s)
unsigned int strToUInt (string s)
string iToStr (int i)
string fToStr (double i)
string cpToStr (char *)
string cToStr (char)
char * scanForString (char *buf, char *toFind, char **ret=NULL, int offset=0, unsigned int length=0)
char * scanForString (char *buf, char *toFind, string *ret=NULL, int offset=0, unsigned int length=0)
string scanForString (string buf, string toFind, string *ret=NULL, int offset=0, unsigned int length=0)
void split (string str, string delim, vector< string > &results, bool allowEmpty=false)
void msleep (unsigned long msec)
bool scanString (string toscan, string frontkey, string backkey, unsigned int offset, unsigned int length, string *result, unsigned int *nextpos)
void trim (string &str)
bool strToBool (string s)
void fixPathStr (string &path)
 Removes double slashes from strings containing filesystem paths.
void executeCmd (string cmd, pid_t *cpid=NULL)
bool file_exist (string filename)
void writeDebugMessage (const char *identity, const char *filename, const int lineno, const char *msg,...)
void writeDebugMessage (const char *identity, const char *filename, const int lineno, const string &msg)
void writeMessage2Stdout (const char *identity, const char *filename, const int lineno, const char *msg,...)
void writeMessage2Stdout (const char *identity, const char *filename, const int lineno, const string &msg)
unsigned int getMTimeStamp ()
unsigned int getMDiff (unsigned int start_ts, unsigned int end_ts)
int64_t timespecDiff (struct timespec *timeA, struct timespec *timeB)
void rotateUCharBuffer180 (unsigned char *buffer, int pitch, int w, int h)
void rotateUShortIntBuffer180 (unsigned short int *buffer, int pitch, int w, int h)
void rotateUIntBuffer180 (unsigned int *buffer, int pitch, int w, int h)
bool convBidiString (const string &in_str, string &out_str, bool bArabic=false)
 Convert a bidirectional string.
string XMLencode (const string &Source)

Define Documentation

#define DEBUGERR ( msg...   ) 

Definition at line 61 of file tools.h.

#define DEBUGMSG ( ident,
msg...   ) 

Definition at line 52 of file tools.h.

#define DEBUGMSG_OUTSTR ( ident,
msg...   )     printf("%s\n", ((string)(msg)).c_str())

Definition at line 53 of file tools.h.

#define DEBUGOUT ( msg...   ) 

Definition at line 60 of file tools.h.

#define MSG2OUT ( ident,
msg...   )     writeMessage2Stdout(ident, __FILE__, __LINE__, msg)

Definition at line 70 of file tools.h.

#define TRACEOUT ( ident,
msg...   ) 

Definition at line 67 of file tools.h.

#define WRITE_ERR ( ident,
msg...   )     fprintf(stderr, "%s: ", ident);fprintf(stderr, msg);printf("\n");

Definition at line 81 of file tools.h.

#define WRITE_ERRI ( msg...   )     fprintf(stderr, "%s: ", identity.c_str());fprintf(stderr, msg);printf("\n");

Definition at line 82 of file tools.h.

#define WRITE_MSG ( ident,
msg...   ) 

Definition at line 77 of file tools.h.

#define WRITE_MSGI ( msg...   ) 

Definition at line 78 of file tools.h.


Function Documentation

bool convBidiString ( const string &  in_str,
string &  out_str,
bool  bArabic = false 
)

Convert a bidirectional string.

Parameters:
in_str source string (UTF-8)
out_str destination string (UTF-8)
Returns:
true if successfully converted
Note:
in_str and out_str can be the same

Definition at line 853 of file tools.cpp.

string cpToStr ( char *   ) 

Definition at line 518 of file tools.cpp.

string cToStr ( char   ) 

Definition at line 524 of file tools.cpp.

void executeCmd ( string  cmd,
pid_t *  cpid = NULL 
)

Definition at line 561 of file tools.cpp.

bool file_exist ( string  filename  ) 

Definition at line 639 of file tools.cpp.

void fixPathStr ( string &  path  ) 

Removes double slashes from strings containing filesystem paths.

Parameters:
path string to fix

Definition at line 556 of file tools.cpp.

string fToStr ( double  i  ) 

Definition at line 360 of file tools.cpp.

bool getCurrentTimeBuffer ( char *  dtbuf,
char *  datebuf = NULL,
char *  timebuf = NULL,
time_t *  clock = NULL 
)

Definition at line 176 of file tools.cpp.

bool getCurrentTimeString ( string *  dtstr,
string *  datestr = NULL,
string *  timestr = NULL,
time_t *  clock = NULL 
)

Definition at line 217 of file tools.cpp.

string getDayOfWeek ( time_t *  clock = NULL  ) 

Definition at line 235 of file tools.cpp.

unsigned int getMDiff ( unsigned int  start_ts,
unsigned int  end_ts 
)

Definition at line 762 of file tools.cpp.

unsigned int getMTimeStamp (  ) 

Definition at line 752 of file tools.cpp.

string getSimpleTimeString (  ) 

Definition at line 168 of file tools.cpp.

int hexToInt ( const char *  in  ) 

Definition at line 135 of file tools.cpp.

void initLogging ( char *  Iam,
char *  logfile 
)

Definition at line 278 of file tools.cpp.

string iToStr ( int  i  ) 

Definition at line 350 of file tools.cpp.

string maskChars ( string  str  ) 

Definition at line 90 of file tools.cpp.

void msleep ( unsigned long  msec  ) 

Definition at line 461 of file tools.cpp.

void rotateUCharBuffer180 ( unsigned char *  buffer,
int  pitch,
int  w,
int  h 
)

Definition at line 781 of file tools.cpp.

void rotateUIntBuffer180 ( unsigned int *  buffer,
int  pitch,
int  w,
int  h 
)

Definition at line 815 of file tools.cpp.

void rotateUShortIntBuffer180 ( unsigned short int *  buffer,
int  pitch,
int  w,
int  h 
)

Definition at line 798 of file tools.cpp.

string scanForString ( string  buf,
string  toFind,
string *  ret = NULL,
int  offset = 0,
unsigned int  length = 0 
)

Definition at line 417 of file tools.cpp.

char* scanForString ( char *  buf,
char *  toFind,
string *  ret = NULL,
int  offset = 0,
unsigned int  length = 0 
)

Definition at line 401 of file tools.cpp.

char* scanForString ( char *  buf,
char *  toFind,
char **  ret = NULL,
int  offset = 0,
unsigned int  length = 0 
)

Definition at line 370 of file tools.cpp.

bool scanString ( string  toscan,
string  frontkey,
string  backkey,
unsigned int  offset,
unsigned int  length,
string *  result,
unsigned int *  nextpos 
)

Definition at line 467 of file tools.cpp.

void split ( string  str,
string  delim,
vector< string > &  results,
bool  allowEmpty = false 
)

Definition at line 448 of file tools.cpp.

bool strToBool ( string  s  ) 

Definition at line 545 of file tools.cpp.

int strToInt ( string  s  ) 

Definition at line 341 of file tools.cpp.

string strToLwr ( string  src  ) 

Definition at line 128 of file tools.cpp.

string* strToLwr ( string *  src  ) 

Definition at line 118 of file tools.cpp.

unsigned int strToUInt ( string  s  ) 

Definition at line 345 of file tools.cpp.

string strToUpr ( string  src  ) 

Definition at line 111 of file tools.cpp.

string* strToUpr ( string *  src  ) 

Definition at line 101 of file tools.cpp.

string substituteEnvVars ( string  input  ) 

substitutes environment variables in a string

Parameters:
input string containing the variable components
Returns:
the string with the replaced components
Note:
this will only work if the libc supports _XOPEN_SOURCE

Definition at line 68 of file tools.cpp.

int64_t timespecDiff ( struct timespec *  timeA,
struct timespec *  timeB 
)

Definition at line 772 of file tools.cpp.

void trim ( string &  str  ) 

Definition at line 534 of file tools.cpp.

string ucharToHex ( unsigned char  in  ) 

Definition at line 162 of file tools.cpp.

void writeDebugMessage ( const char *  identity,
const char *  filename,
const int  lineno,
const string &  msg 
)

Definition at line 683 of file tools.cpp.

void writeDebugMessage ( const char *  identity,
const char *  filename,
const int  lineno,
const char *  msg,
  ... 
)

Definition at line 648 of file tools.cpp.

void writeMessage ( const char *  ctrl,
  ... 
)

Definition at line 300 of file tools.cpp.

void writeMessage2Stdout ( const char *  identity,
const char *  filename,
const int  lineno,
const string &  msg 
)

Definition at line 735 of file tools.cpp.

void writeMessage2Stdout ( const char *  identity,
const char *  filename,
const int  lineno,
const char *  msg,
  ... 
)

Definition at line 711 of file tools.cpp.

string XMLencode ( const string &  Source  ) 

Definition at line 953 of file tools.cpp.