deltaFlow
Utilities Namespace Reference

Collection of utility functions. More...

Functions

bool isCommonDataFormat (const std::string &filePath)
 Check if filepath is IEEE Common Data Format.
 
bool isRawFormat (const std::string &filePath)
 Check if filepath is PSS/E Raw format.
 
std::string strip (const std::string &s)
 Strip leading and trailing whitespace from a string.
 
std::string stripQuotes (const std::string &s)
 Strip surrounding single quotes and whitespace from a string.
 

Detailed Description

Collection of utility functions.

Function Documentation

◆ isCommonDataFormat()

bool Utilities::isCommonDataFormat ( const std::string &  filePath)
inline

Check if filepath is IEEE Common Data Format.

Parameters
filePathThe filepath.
Returns
True if extension is .cdf or .txt, false otherwise.

Definition at line 43 of file Utils.H.

43 {
44 auto ext = std::filesystem::path(filePath).extension();
45 return ext == ".cdf" || ext == ".txt";
46 }
Here is the caller graph for this function:

◆ isRawFormat()

bool Utilities::isRawFormat ( const std::string &  filePath)
inline

Check if filepath is PSS/E Raw format.

Parameters
filePathThe filepath.
Returns
True if extension is .raw, false otherwise.

Definition at line 53 of file Utils.H.

53 {
54 return std::filesystem::path(filePath).extension() == ".raw";
55 }
Here is the caller graph for this function:

◆ strip()

std::string Utilities::strip ( const std::string &  s)
inline

Strip leading and trailing whitespace from a string.

Parameters
sThe input string.
Returns
Trimmed string.

Definition at line 62 of file Utils.H.

62 {
63 auto start = s.find_first_not_of(" \t\r\n");
64 if (start == std::string::npos) return "";
65 auto end = s.find_last_not_of(" \t\r\n");
66 return s.substr(start, end - start + 1);
67 }

References strip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stripQuotes()

std::string Utilities::stripQuotes ( const std::string &  s)
inline

Strip surrounding single quotes and whitespace from a string.

Parameters
sThe input string.
Returns
String with quotes removed.

Definition at line 74 of file Utils.H.

74 {
75 std::string t = strip(s);
76 if (t.size() >= 2 && t.front() == '\'' && t.back() == '\'')
77 return strip(t.substr(1, t.size() - 2));
78 return t;
79 }
std::string strip(const std::string &s)
Strip leading and trailing whitespace from a string.
Definition Utils.H:62

References strip(), and stripQuotes().

Here is the call graph for this function:
Here is the caller graph for this function: