This module offers C++ utility functions.
More...
#include "Config.h"
Go to the source code of this file.
|
#define | CMSQ2MMSQ 1.0e2 |
| cm^2 -> mm^2 More...
|
|
#define | ERG2KEV 6.242e8 |
| erg -> keV More...
|
|
#define | KEV2J 1.602176634e-16 |
| keV -> J (SI) More...
|
|
#define | LN10 2.30258509299404590109361379290930926799774169921875 |
| log(10) More...
|
|
#define | LN2 0.6931471805599453094172321214581766 |
| log_e 2 More...
|
|
#define | MM2M 1.0e-3 |
| mm -> m More...
|
|
#define | PI 3.141592653589793115997963468544185161590576171875 |
| pi
More...
|
|
#define | PIOVERTWO 1.5707963267948965579989817342720925807952880859375 |
| pi/2
More...
|
|
#define | S2MS 1.0e3 |
| s -> ms More...
|
|
#define | SQRT2 1.4142135623730951454746218587388284504413604736328125 |
| sqrt(2) More...
|
|
#define | SQRT2PI 2.506628274631000241612355239340104162693023681640625 |
| sqrt(2pi) More...
|
|
#define | TWOPI 6.28318530717958623199592693708837032318115234375 |
| 2pi
More...
|
|
|
string | GetDirectoryFromFilePath (const string aFilePath) |
| Returns the directory from the file path. More...
|
|
string | GetFileNameFromPath (const string aFilePath) |
| Returns the file name given the file path. More...
|
|
unsigned int | GetGcd (unsigned int aN1, unsigned int aN2) |
| Returns the greater common divisor between 2 numbers. More...
|
|
vector< string > | Glob (const char *aPattern) |
| C utility to extract a list of files from a given file pattern. More...
|
|
bool | IsDirectory (const string aDirPath) |
| Checks if a directory exists. More...
|
|
bool | IsFile (const string aFileName) |
| Checks if a file exists. More...
|
|
bool | IsPowerOfTwo (const unsigned int aN) |
| Tests whether an integer is a power of 2. More...
|
|
int | NextPowerOfTwo (const double aX) |
| Returns the next power of 2. More...
|
|
string | ReplaceAll (string aStr, const string &aFrom, const string &aTo) |
| Replaces all occurences of a sub-string by another sub-string. More...
|
|
vector< string > | SplitString (const string aStringToSplit, const char aSeparator) |
| Splits a string. More...
|
|
◆ CMSQ2MMSQ
◆ ERG2KEV
◆ KEV2J
#define KEV2J 1.602176634e-16 |
◆ LN10
#define LN10 2.30258509299404590109361379290930926799774169921875 |
◆ LN2
#define LN2 0.6931471805599453094172321214581766 |
◆ MM2M
◆ PI
#define PI 3.141592653589793115997963468544185161590576171875 |
◆ PIOVERTWO
#define PIOVERTWO 1.5707963267948965579989817342720925807952880859375 |
◆ S2MS
◆ SQRT2
#define SQRT2 1.4142135623730951454746218587388284504413604736328125 |
◆ SQRT2PI
#define SQRT2PI 2.506628274631000241612355239340104162693023681640625 |
◆ TWOPI
#define TWOPI 6.28318530717958623199592693708837032318115234375 |
◆ GetDirectoryFromFilePath()
string GetDirectoryFromFilePath |
( |
const string |
aFilePath | ) |
|
Returns the directory from the file path.
- Parameters
-
◆ GetFileNameFromPath()
string GetFileNameFromPath |
( |
const string |
aFilePath | ) |
|
|
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
-
- Returns
- The file name with path.
◆ GetGcd()
unsigned int GetGcd |
( |
unsigned int |
aN1, |
|
|
unsigned int |
aN2 |
|
) |
| |
Returns the greater common divisor between 2 numbers.
- Parameters
-
[in] | aN1 | First number. |
[in] | aN2 | Second number. |
◆ Glob()
vector<string> Glob |
( |
const char * |
aPattern | ) |
|
C utility to extract a list of files from a given file pattern.
- Returns
- a list of files matching a pattern.
- Parameters
-
[in] | aPattern | File pattern to match. |
◆ IsDirectory()
bool IsDirectory |
( |
const string |
aDirPath | ) |
|
Checks if a directory exists.
- Returns
- true if the directory path exists.
- Parameters
-
[in] | aDirPath | Path to the directory to test. |
◆ IsFile()
bool IsFile |
( |
const string |
aFileName | ) |
|
Checks if a file exists.
- Returns
- true if the input file exists, false otherwise.
- Parameters
-
[in] | aFileName | Path to the file to test. |
◆ IsPowerOfTwo()
bool IsPowerOfTwo |
( |
const unsigned int |
aN | ) |
|
|
inline |
Tests whether an integer is a power of 2.
- Parameters
-
- Returns
- true if the integer is a power of 2, false otherwise.
◆ NextPowerOfTwo()
int NextPowerOfTwo |
( |
const double |
aX | ) |
|
|
inline |
Returns the next power of 2.
- Parameters
-
[in] | aX | number to consider. |
- Returns
- The power of 2 next to the given number.
◆ ReplaceAll()
string ReplaceAll |
( |
string |
aStr, |
|
|
const string & |
aFrom, |
|
|
const string & |
aTo |
|
) |
| |
Replaces all occurences of a sub-string by another sub-string.
All occurences of sub-string 'aFrom' are replaced by 'aTo'.
- Returns
- The modified string.
- Parameters
-
aStr | String to modify. |
aFrom | Substring to replace from. |
aTo | Substring to replace to. |
◆ SplitString()
vector<string> SplitString |
( |
const string |
aStringToSplit, |
|
|
const char |
aSeparator |
|
) |
| |
Splits a string.
A string is divided into a vector of sub-strings. The separator defines where to break the input string. The separator must be a single character.
- Returns
- A vector of string, excluding the separator
- Parameters
-
[in] | aStringToSplit | String to divide. |
[in] | aSeparator | Separator. |