/afs/in2p3.fr/throng/virgo/virgoDev/SoftFlorent/GWOLLUM/v2r2/src/Utils/CUtils.h File Reference

#include <iostream>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <stdio.h>
#include <sstream>
#include <fstream>
#include <regex.h>
#include <dirent.h>
#include <glob.h>
#include <fnmatch.h>
Include dependency graph for CUtils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define LN10   2.30258509299404590109361379290930926799774169921875
 log(10)
#define LN2   0.6931471805599453094172321214581766
 log_e 2

Functions

string GetFileName (const string filepath)
 Extract and return the file name from file path.
string GetFileNameFromPath (const string filepathname)
 Returns the file name given the file path.
vector< string > Glob (const char *pattern)
 c utility to extract a list of files.
bool IsBinaryFile (const string filename)
 Check if a file exists and is a binary file.
bool IsBinaryFile (const char *filename)
 Check if a file exists and is a binary file.
bool IsDirectory (const string dirname)
 Check if a directory exists.
bool IsDirectory (const char *dirname)
 Check if a directory exists.
bool IsPowerOfTwo (unsigned int x)
 Is this integer a power of 2.
bool IsTextFile (const string filename)
 Check if a file exists and is a txt file.
bool IsTextFile (const char *filename)
 Check if a file exists and is a txt file.
bool ListDirectories (const string maindir, vector< string > &subdir)
 Returns list of subdirectories.
double medianbiasfactor (const int nn)
 Returns the bias factor when computing a median with nn samples.
int NextPowerOfTwo (double x)
 Returns the next power of 2.
string ReplaceAll (string str, const string &from, const string &to)
 Replace all occurences of a sub-string.
vector< string > SplitString (const string stringtodivide, const char separator)
 Splits a string.
string StringToUpper (string stringtoconvert)
 Convert a string to uppercase.

Define Documentation

#define LN10   2.30258509299404590109361379290930926799774169921875

log(10)

#define LN2   0.6931471805599453094172321214581766

log_e 2


Function Documentation

string GetFileName ( const string  filepath  ) 

Extract and return the file name from file path.

Parameters:
filepath file path
string GetFileNameFromPath ( const string  filepathname  )  [inline]

Returns the file name given the file path.

For example "myprog.exe" is returned from:

  • the full path "/usr/bin/myprog.exe"
  • the relative path "./bin/myprog.exe"
    Parameters:
    filepathname file path
vector<string> Glob ( const char *  pattern  ) 

c utility to extract a list of files.

Returns a list of files matching a pattern.

Parameters:
pattern file pattern
bool IsBinaryFile ( const string  filename  )  [inline]

Check if a file exists and is a binary file.

Returns true if 'filename' is an existing binary file.

Parameters:
filename path to file to test
bool IsBinaryFile ( const char *  filename  ) 

Check if a file exists and is a binary file.

Returns true if 'filename' is an existing binary file.

Parameters:
filename path to file to test
bool IsDirectory ( const string  dirname  )  [inline]

Check if a directory exists.

Returns true if 'dirname' is an existing directory.

Parameters:
dirname path to directory to test
bool IsDirectory ( const char *  dirname  ) 

Check if a directory exists.

Returns true if 'dirname' is an existing directory.

Parameters:
dirname path to directory to test
bool IsPowerOfTwo ( unsigned int  x  )  [inline]

Is this integer a power of 2.

true is returned if this is the case.

Parameters:
x integer to test.
bool IsTextFile ( const string  filename  )  [inline]

Check if a file exists and is a txt file.

Returns true if 'filename' is an existing text file.

Parameters:
filename path to file to test
bool IsTextFile ( const char *  filename  ) 

Check if a file exists and is a txt file.

Returns true if 'filename' is an existing text file.

Parameters:
filename path to file to test
bool ListDirectories ( const string  maindir,
vector< string > &  subdir 
)

Returns list of subdirectories.

The vector 'subdir' is filled with directories contained in 'maindir' Returns true if success

Parameters:
maindir path to main directory
double medianbiasfactor ( const int  nn  ) 

Returns the bias factor when computing a median with nn samples.

Parameters:
nn number of samples
int NextPowerOfTwo ( double  x  )  [inline]

Returns the next power of 2.

Parameters:
x to get the next power of 2 of
string ReplaceAll ( string  str,
const string &  from,
const string &  to 
)

Replace all occurences of a sub-string.

All occurences of substring 'from' are replaced by 'to'. The modified string is returned.

Parameters:
str string to modify
from substring to replace from
from substring to replace to
vector<string> SplitString ( const string  stringtodivide,
const char  separator 
)

Splits a string.

A string is divided into an array of words. The separator defines where to break the string. The separator should be a single character. A vector of string is returned.

Parameters:
stringtodivide string to divide
separator separator
string StringToUpper ( string  stringtoconvert  ) 

Convert a string to uppercase.

Parameters:
stringtoconvert string to convert
 All Classes Files Functions Variables Friends Defines

Generated on 29 Sep 2016 by  doxygen 1.6.1