SatAndLight  2.2.2-hubble
Simulation toolkit for space telescopes
CUtils.cc File Reference

See CUtils.h. More...

#include "CUtils.h"
Include dependency graph for CUtils.cc:

Functions

string GetDirectoryFromFilePath (const string aFilePath)
 Returns the directory from 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...
 
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...
 

Detailed Description

See CUtils.h.

Function Documentation

◆ GetDirectoryFromFilePath()

string GetDirectoryFromFilePath ( const string  aFilePath)

Returns the directory from the file path.

Parameters
[in]aFilePathFile path.

◆ GetGcd()

unsigned int GetGcd ( unsigned int  aN1,
unsigned int  aN2 
)

Returns the greater common divisor between 2 numbers.

Parameters
[in]aN1First number.
[in]aN2Second 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]aPatternFile pattern to match.

◆ IsDirectory()

bool IsDirectory ( const string  aDirPath)

Checks if a directory exists.

Returns
true if the directory path exists.
Parameters
[in]aDirPathPath 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]aFileNamePath to the file to test.

◆ 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
aStrString to modify.
aFromSubstring to replace from.
aToSubstring 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]aStringToSplitString to divide.
[in]aSeparatorSeparator.