guts
Loading...
Searching...
No Matches
gutilities.cc
Go to the documentation of this file.
1// gutilities
2#include "gutilities.h"
3#include "gutsConventions.h"
4
5// Numbers / strings with units / io interface to CLHEP units
6#include "CLHEP/Units/PhysicalConstants.h"
7
8// geant4
9#include "G4UImanager.hh"
10
11
12// c++
13// algorithm for 'transform'
14#include <algorithm>
15#include <sstream>
16#include <unordered_map>
17#include <iostream>
18#include <fstream>
19#include <vector>
20#include <charconv>
21#include <filesystem>
22
23namespace gutilities {
24/*
25 * Trim leading/trailing spaces and tabs from an owning std::string.
26 *
27 * Notes:
28 * - Whitespace considered here is strictly ' ' and '\t' (tab).
29 * - If the input is all whitespace (or empty), returns an empty string.
30 *
31 * See the API documentation in gutilities.h for full Doxygen docs.
32 */
33string removeLeadingAndTrailingSpacesFromString(const std::string& input) {
34 size_t startPos = input.find_first_not_of(" \t"); // Find the first non-whitespace character
35 size_t endPos = input.find_last_not_of(" \t"); // Find the last non-whitespace character
36
37 // If all spaces or empty, return an empty string
38 if (startPos == std::string::npos || endPos == std::string::npos) { return ""; }
39
40 // Return the substring between startPos and endPos
41 return input.substr(startPos, endPos - startPos + 1);
42}
43
44/*
45 * Fast trim for std::string_view.
46 *
47 * Notes:
48 * - No allocations: adjusts the view by removing prefix/suffix.
49 * - Uses std::isspace (locale-sensitive) to classify whitespace.
50 *
51 * See the API documentation in gutilities.h for full Doxygen docs.
52 */
53std::string_view removeLeadingAndTrailingSpacesFromString(std::string_view s) {
54 while (!s.empty() && std::isspace(static_cast<unsigned char>(s.front()))) s.remove_prefix(1);
55 while (!s.empty() && std::isspace(static_cast<unsigned char>(s.back()))) s.remove_suffix(1);
56 return s;
57}
58
59/*
60 * Remove all literal spaces ' ' from a string.
61 *
62 * See the API documentation in gutilities.h for full Doxygen docs.
63 */
64string removeAllSpacesFromString(const std::string& str) {
65 string result = str;
66 result.erase(std::remove(result.begin(), result.end(), ' '), result.end());
67 return result;
68}
69
70/*
71 * Extract the filename component from a POSIX-style path (splitting on '/').
72 *
73 * See the API documentation in gutilities.h for full Doxygen docs.
74 */
75string getFileFromPath(const std::string& path) {
76 std::size_t lastSlashPos = path.find_last_of('/');
77 if (lastSlashPos == std::string::npos) {
78 // No slashes found, return the entire path
79 return path;
80 }
81 return path.substr(lastSlashPos + 1);
82}
83
84/*
85 * Extract the directory component from a POSIX-style path (splitting on '/').
86 *
87 * See the API documentation in gutilities.h for full Doxygen docs.
88 */
89string getDirFromPath(const std::string& path) {
90 auto lastSlash = path.find_last_of('/');
91 if (lastSlash == std::string::npos) return ".";
92 return path.substr(0, lastSlash);
93}
94
95namespace fs = std::filesystem;
96
97
98/*
99 * Tokenize a string on whitespace into a vector.
100 *
101 * See the API documentation in gutilities.h for full Doxygen docs.
102 */
103vector<std::string> getStringVectorFromString(const std::string& input) {
104 std::vector<std::string> pvalues;
105 std::stringstream plist(input);
106 string tmp;
107 while (plist >> tmp) {
108 string trimmed = removeLeadingAndTrailingSpacesFromString(tmp);
109 if (!trimmed.empty()) { pvalues.push_back(trimmed); }
110 }
111 return pvalues;
112}
113
114/*
115 * Replace any character found in 'toReplace' with the string 'replacement'.
116 *
117 * See the API documentation in gutilities.h for full Doxygen docs.
118 */
119string replaceCharInStringWithChars(const std::string& input, const std::string& toReplace,
120 const std::string& replacement) {
121 string output;
122 for (const char& ch : input) {
123 if (toReplace.find(ch) != std::string::npos) { output.append(replacement); }
124 else { output.push_back(ch); }
125 }
126 return output;
127}
128
129/*
130 * Replace all occurrences of substring 'from' with substring 'to'.
131 *
132 * See the API documentation in gutilities.h for full Doxygen docs.
133 */
134string replaceAllStringsWithString(const string& source, const string& from, const string& to) {
135 if (from.empty()) return source; // Avoid infinite loop
136
137 string newString;
138 size_t lastPos = 0;
139 size_t findPos = source.find(from, lastPos);
140
141 while (findPos != string::npos) {
142 // Append part before the match and the replacement string
143 newString.append(source, lastPos, findPos - lastPos);
144 newString += to;
145 lastPos = findPos + from.length();
146 findPos = source.find(from, lastPos);
147 }
148
149 // Append the remaining part of the string after the last occurrence
150 newString += source.substr(lastPos);
151
152 return newString;
153}
154
155
156/*
157 * Left-pad a string using the first character of 'c' until length reaches ndigits.
158 *
159 * See the API documentation in gutilities.h for full Doxygen docs.
160 */
161string fillDigits(const string& word, const string& c, int ndigits) {
162 if (c.empty() || ndigits <= static_cast<int>(word.size())) return word; // Return original if no padding needed
163
164 string filled;
165
166 int toFill = ndigits - static_cast<int>(word.size());
167 filled.reserve(ndigits);
168
169 filled.append(toFill, c[0]); // Use the first character of the string 'c'
170 filled += word;
171
172 return filled;
173}
174
175// add near your includes:
176#include <locale.h> // strtod_l / _strtod_l
177
195static bool parse_double_clocale(std::string_view sv, double& out) {
196 std::string tmp(sv); // strtod_l needs a 0-terminated buffer
197#if defined(_WIN32)
198 _locale_t loc = _create_locale(LC_NUMERIC, "C");
199 char* end = nullptr;
200 out = _strtod_l(tmp.c_str(), &end, loc);
201 _free_locale(loc);
202 return end == tmp.c_str() + tmp.size();
203#else
204 locale_t loc = newlocale(LC_NUMERIC_MASK, "C", (locale_t)0);
205 char* end = nullptr;
206 out = strtod_l(tmp.c_str(), &end, loc);
207 freelocale(loc);
208 return end == tmp.c_str() + tmp.size();
209#endif
210}
211
212
213// --- strict, locale-independent getG4Number: only accepts '*' as unit sep ---
214double getG4Number(const string& v, bool warnIfNotUnit) {
216 if (value.empty()) {
217 std::cerr << FATALERRORL << "empty numeric string.\n";
218 exit(EC__G4NUMBERERROR);
219 }
220
221 // Normalize a single decimal comma to dot when no dot is present
222 if (value.find('.') == string::npos) {
223 size_t firstComma = value.find(',');
224 if (firstComma != string::npos && value.find(',', firstComma + 1) == string::npos) {
225 value = replaceAllStringsWithString(value, ",", ".");
226 }
227 }
228
229 const size_t starCount = static_cast<size_t>(std::count(value.begin(), value.end(), '*'));
230
231 // --- Case 1: no '*' → pure number (strictly no trailing garbage) ---
232 if (value.find('*') == string::npos) {
233 double out = 0.0;
234 // normalize a single decimal comma to dot if needed
235 if (value.find('.') == string::npos) {
236 auto firstComma = value.find(',');
237 if (firstComma != string::npos && value.find(',', firstComma + 1) == string::npos)
238 value = replaceAllStringsWithString(value, ",", ".");
239 }
240 if (!parse_double_clocale(value, out)) {
241 std::cerr << FATALERRORL << "missing '*' before unit or invalid number in <" << v << ">.\n";
242 exit(EC__G4NUMBERERROR);
243 }
244 if (warnIfNotUnit && out != 0.0) {
245 std::cerr << " ! Warning: value " << v << " does not contain units." << std::endl;
246 }
247 return out;
248 }
249
250
251 // --- Case 2: must be exactly one '*' ---
252 if (starCount > 1) {
253 std::cerr << FATALERRORL << "multiple '*' separators are not allowed in <" << v << ">.\n";
254 exit(EC__G4NUMBERERROR);
255 }
256
257 // --- Exactly one '*' → split "<number>*<unit>" ---
258 const size_t pos = value.find('*');
259 string left = removeLeadingAndTrailingSpacesFromString(value.substr(0, pos));
260 string right = removeLeadingAndTrailingSpacesFromString(value.substr(pos + 1));
261 if (left.empty() || right.empty()) {
262 std::cerr << FATALERRORL << "expected '<number>*<unit>', got <" << v << ">.\n";
263 exit(EC__G4NUMBERERROR);
264 }
265
266 // normalize a single decimal comma in the numeric part
267 if (left.find('.') == string::npos) {
268 auto c = left.find(',');
269 if (c != string::npos && left.find(',', c + 1) == string::npos)
270 left = replaceAllStringsWithString(left, ",", ".");
271 }
272
273 double numeric = 0.0;
274 if (!parse_double_clocale(left, numeric)) {
275 std::cerr << FATALERRORL << "invalid numeric part before '*' in <" << v << ">.\n";
276 exit(EC__G4NUMBERERROR);
277 }
278
279 // sanitize unit and proceed with your existing unit table logic...
280 right = replaceAllStringsWithString(right, "µ", "u");
281 string unit = convertToLowercase(right);
282
283 // (keep your unitConversion map and SI prefix handling as-is)
284
285
286 // Unit table (lowercase keys)
287 static const std::unordered_map<string, double> unitConversion = {
288 // length
289 {"m", CLHEP::m}, {"cm", CLHEP::cm}, {"mm", CLHEP::mm},
290 {"um", 1E-6 * CLHEP::m}, {"fm", 1E-15 * CLHEP::m},
291 {"inch", 2.54 * CLHEP::cm}, {"inches", 2.54 * CLHEP::cm},
292 // angle
293 {"deg", CLHEP::deg}, {"degrees", CLHEP::deg}, {"arcmin", CLHEP::deg / 60.0},
294 {"rad", CLHEP::rad}, {"mrad", CLHEP::mrad},
295 // energy
296 {"ev", CLHEP::eV}, {"kev", 1e3 * CLHEP::eV}, {"mev", CLHEP::MeV}, {"gev", CLHEP::GeV},
297 // magnetic field
298 {"t", CLHEP::tesla}, {"tesla", CLHEP::tesla}, {"t/m", CLHEP::tesla / CLHEP::m},
299 {"gauss", CLHEP::gauss}, {"kilogauss", 1000.0 * CLHEP::gauss},
300 // time
301 {"s", CLHEP::s}, {"ns", CLHEP::ns}, {"ms", CLHEP::ms}, {"us", CLHEP::us},
302 // dimensionless
303 {"counts", 1.0}
304 };
305
306 // Exact unit match
307 if (auto it = unitConversion.find(unit); it != unitConversion.end()) {
308 return numeric * it->second;
309 }
310
311 // SI prefix handling: mT, uT, mm, um, etc.
312 auto si_prefix_factor = [](char p) -> double {
313 switch (p) {
314 case 'Y': return 1e24;
315 case 'Z': return 1e21;
316 case 'E': return 1e18;
317 case 'P': return 1e15;
318 case 'T': return 1e12;
319 case 'G': return 1e9;
320 case 'M': return 1e6;
321 case 'k': return 1e3;
322 case 'h': return 1e2;
323 case 'd': return 1e-1;
324 case 'c': return 1e-2;
325 case 'm': return 1e-3;
326 case 'u': return 1e-6;
327 case 'n': return 1e-9;
328 case 'p': return 1e-12;
329 case 'f': return 1e-15;
330 case 'a': return 1e-18;
331 case 'z': return 1e-21;
332 case 'y': return 1e-24;
333 default: return 0.0;
334 }
335 };
336
337 if (unit.size() >= 2) {
338 const double pf = si_prefix_factor(unit.front());
339 if (pf != 0.0) {
340 const string base = unit.substr(1);
341 if (auto it2 = unitConversion.find(base); it2 != unitConversion.end()) {
342 return numeric * pf * it2->second;
343 }
344 }
345 }
346
347 // Unknown unit: warn & return numeric part (keep your legacy behavior)
348 std::cerr << GWARNING << ">" << right << "<: unit not recognized for string <" << v << ">" << std::endl;
349 return numeric;
350}
351
352
353double getG4Number(double input, const string& unit) {
354 string gnumber = std::to_string(input) + "*" + unit;
355 return getG4Number(gnumber, true);
356}
357
358vector<double> getG4NumbersFromStringVector(const vector<string>& vstring, bool warnIfNotUnit) {
359 vector<double> output;
360 output.reserve(vstring.size());
361
362 for (const auto& s : vstring) { output.push_back(getG4Number(s, warnIfNotUnit)); }
363
364 return output;
365}
366
367vector<double> getG4NumbersFromString(const string& vstring, bool warnIfNotUnit) {
368 return getG4NumbersFromStringVector(getStringVectorFromStringWithDelimiter(vstring, ","), warnIfNotUnit);
369}
370
371
372string parseFileAndRemoveComments(const string& filename, const string& commentChars, int verbosity) {
373 // Reading file
374 std::ifstream in(filename);
375 if (!in) {
376 std::cerr << FATALERRORL << "can't open input file " << filename << ". Check your spelling. " << std::endl;
377 exit(EC__FILENOTFOUND);
378 }
379
380 std::stringstream strStream;
381 if (verbosity > 0) { std::cout << std::endl << CIRCLEITEM << " Loading string from " << filename << std::endl; }
382 strStream << in.rdbuf(); // Read the file
383 in.close();
384
385 string parsedString = strStream.str();
386
387 // Removing all occurrences of commentChars
388 size_t nFPos;
389 while ((nFPos = parsedString.find(commentChars)) != string::npos) {
390 size_t firstNL = parsedString.rfind('\n', nFPos);
391 size_t secondNL = parsedString.find('\n', nFPos);
392 parsedString.erase(firstNL, secondNL - firstNL);
393 }
394
395 return parsedString;
396}
397
398string retrieveStringBetweenChars(const string& input, const string& firstDelimiter, const string& secondDelimiter) {
399 size_t firstpos = input.find(firstDelimiter);
400 size_t secondpos = input.find(secondDelimiter);
401
402 if (firstpos == string::npos || secondpos == string::npos) { return ""; }
403 return input.substr(firstpos + firstDelimiter.length(), secondpos - firstpos - firstDelimiter.length());
404}
405
406vector<string> getStringVectorFromStringWithDelimiter(const string& input, const string& x) {
407 vector<string> pvalues;
408 string tmp;
409
410 for (char ch : input) {
411 if (ch != x[0]) { tmp += ch; }
412 else {
413 if (!tmp.empty()) {
414 pvalues.push_back(removeLeadingAndTrailingSpacesFromString(tmp));
415 tmp.clear();
416 }
417 }
418 }
419
420 if (!tmp.empty()) { pvalues.push_back(removeLeadingAndTrailingSpacesFromString(tmp)); }
421
422 return pvalues;
423}
424
425
426// string search for a path with <name> from a possible list of absolute paths
427// returns UNINITIALIZEDSTRINGQUANTITY if not found
428// the filesystem solution does not work on linux systems.
429// TODO: periodically try this?
430//#include <filesystem>
431//
432// string searchForDirInLocations(string dirName, vector <string> possibleLocations) {
433//
434// for (auto trialLocation: possibleLocations) {
435// string possibleDir = trialLocation + "/" + dirName;
436// if (std::filesystem::exists(possibleDir)) {
437// return possibleDir;
438// }
439// }
440// return UNINITIALIZEDSTRINGQUANTITY;
441// }
442//
443// vector <string> getListOfFilesInDirectory(string dirName, vector <string> extensions) {
444//
445// vector <string> fileList;
446//
447// for (const auto &entry: std::filesystem::directory_iterator(dirName)) {
448// for (auto &extension: extensions) {
449// if (entry.path().extension() == extension) {
450// fileList.push_back(entry.path().filename());
451// }
452// }
453// }
454//
455// return fileList;
456// }
457// end of TODO
458
459#include <dirent.h>
460#include <sys/stat.h>
461
462bool directoryExists(const std::string& path) {
463 struct stat info{};
464 if (stat(path.c_str(), &info) != 0) {
465 return false; // Path does not exist
466 }
467 return (info.st_mode & S_IFDIR) != 0; // Check if it's a directory
468}
469
470string searchForDirInLocations(const string& dirName, const vector<string>& possibleLocations) {
471 for (const auto& trialLocation : possibleLocations) {
472 string possibleDir = trialLocation + "/" + dirName;
473 if (directoryExists(possibleDir)) { return possibleDir; }
474 }
475 return "UNINITIALIZEDSTRINGQUANTITY";
476}
477
478
479bool hasExtension(const std::string& filename, const std::vector<std::string>& extensions) {
480 for (const auto& ext : extensions) {
481 if (filename.size() >= ext.size() &&
482 filename.compare(filename.size() - ext.size(), ext.size(), ext) == 0) { return true; }
483 }
484 return false;
485}
486
487vector<string> getListOfFilesInDirectory(const string& dirName, const vector<string>& extensions) {
488 vector<string> fileList;
489
490 DIR* dir = opendir(dirName.c_str());
491 if (dir) {
492 struct dirent* entry;
493 while ((entry = readdir(dir)) != nullptr) {
494 struct stat info{};
495 string filepath = dirName + "/" + entry->d_name;
496 if (stat(filepath.c_str(), &info) == 0 && S_ISREG(info.st_mode)) {
497 string filename = entry->d_name;
498 if (hasExtension(filename, extensions)) { fileList.push_back(filename); }
499 }
500 }
501 closedir(dir);
502 }
503
504 return fileList;
505}
506
507string convertToLowercase(const string& str) {
508 string lower = str;
509 transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
510 return lower;
511}
512
513
514template <class KEY, class VALUE>
515vector<KEY> getKeys(const map<KEY, VALUE>& map) {
516 vector<KEY> keys;
517 keys.reserve(map.size()); // Reserve space for efficiency
518
519 for (const auto& it : map) { keys.push_back(it.first); }
520
521 return keys;
522}
523
524randomModel stringToRandomModel(const std::string& str) {
525 static const std::unordered_map<std::string, randomModel> strToEnum = {
526 {"uniform", uniform},
527 {"gaussian", gaussian},
528 {"cosine", cosine},
529 {"sphere", sphere}
530 };
531
532 auto it = strToEnum.find(str);
533 if (it != strToEnum.end()) { return it->second; }
534 else { throw std::invalid_argument("Invalid string for randomModel: " + str); }
535}
536
537
538G4Colour makeG4Colour(std::string_view code, double opacity) {
539 if (code.empty()) throw std::invalid_argument("empty colour string");
540 if (code.front() == '#') code.remove_prefix(1);
541 if (code.size() != 6)
542 throw std::invalid_argument("colour must have 6 or 7 hex digits");
543
544 auto hexNibble = [](char c) -> unsigned {
545 if ('0' <= c && c <= '9') return c - '0';
546 c = static_cast<char>(std::toupper(static_cast<unsigned char>(c)));
547 if ('A' <= c && c <= 'F') return c - 'A' + 10;
548 throw std::invalid_argument("invalid hex digit");
549 };
550
551 // ---- parse RRGGBB ----
552 unsigned rgb = 0;
553 for (int i = 0; i < 6; ++i)
554 rgb = (rgb << 4) | hexNibble(code[i]);
555
556 auto byteToDouble = [](unsigned byte) { return byte / 255.0; };
557 double r = byteToDouble((rgb >> 16) & 0xFF);
558 double g = byteToDouble((rgb >> 8) & 0xFF);
559 double b = byteToDouble(rgb & 0xFF);
560
561 return {r, g, b, opacity}; // G4Colour
562}
563
564std::optional<std::string> searchForFileInLocations(
565 const std::vector<std::string>& locations,
566 std::string_view filename) {
567 namespace fs = std::filesystem;
568
569 for (const auto& loc : locations) {
570 if (loc.empty()) continue;
571
572 fs::path p(loc);
573 fs::path candidate = (!filename.empty() && fs::is_directory(p))
574 ? (p / filename)
575 : p;
576
577 std::error_code ec;
578 const bool ok = fs::exists(candidate, ec) && fs::is_regular_file(candidate, ec);
579 if (ok) return candidate.string();
580 }
581 return std::nullopt;
582}
583
584bool is_unset(std::string_view s) {
586 if (s.empty()) return true;
587 // match your sentinel and YAML nully spellings
588 auto eq = [](std::string_view a, std::string_view b) {
589 if (a.size() != b.size()) return false;
590 for (size_t i = 0; i < a.size(); ++i)
591 if (std::tolower(static_cast<unsigned char>(a[i])) != std::tolower(static_cast<unsigned char>(b[i])))
592 return false;
593 return true;
594 };
595 return eq(s, UNINITIALIZEDSTRINGQUANTITY) || eq(s, "null") || eq(s, "~");
596}
597
598void apply_uimanager_commands(const std::string& command) {
599 G4UImanager* g4uim = G4UImanager::GetUIpointer();
600 if (g4uim == nullptr) { return; }
601 g4uim->ApplyCommand(command);
602}
603}
Public API for the gutilities namespace.
Common constants and console-formatting macros used across gutilities and related code.
#define GWARNING
Standardized warning label prefix (bold yellow).
#define EC__FILENOTFOUND
Process exit code used when an expected file cannot be opened or found.
#define CIRCLEITEM
Hollow bullet glyph used for list formatting in console logs.
#define EC__G4NUMBERERROR
Process exit code used when parsing a Geant4-style numeric string fails.
#define UNINITIALIZEDSTRINGQUANTITY
Sentinel string representing an uninitialized string quantity.
#define FATALERRORL
Standardized fatal error label prefix (bold red).
string replaceAllStringsWithString(const string &source, const string &from, const string &to)
Replaces all occurrences of a substring with another string.
double getG4Number(const string &v, bool warnIfNotUnit)
Converts a string representation of a number with optional units to a double.
bool hasExtension(const std::string &filename, const std::vector< std::string > &extensions)
Checks if a filename has one of the specified extensions.
vector< double > getG4NumbersFromString(const string &vstring, bool warnIfNotUnit)
Converts a comma-separated string of numbers with units to a vector of doubles.
string removeAllSpacesFromString(const std::string &str)
Removes all spaces from a string.
Definition gutilities.cc:64
vector< string > getStringVectorFromStringWithDelimiter(const string &input, const string &x)
Splits a string into a vector of substrings using a specified delimiter.
G4Colour makeG4Colour(std::string_view code, double opacity)
Convert a hex colour string to G4Colour.
randomModel stringToRandomModel(const std::string &str)
Converts a string to a corresponding randomModel enum value.
vector< string > getListOfFilesInDirectory(const string &dirName, const vector< string > &extensions)
Retrieves a list of files with specific extensions from a directory.
vector< double > getG4NumbersFromStringVector(const vector< string > &vstring, bool warnIfNotUnit)
Converts a vector of strings representing numbers with units to a vector of doubles.
string retrieveStringBetweenChars(const string &input, const string &firstDelimiter, const string &secondDelimiter)
Retrieves a substring between two specified delimiters in a string.
string replaceCharInStringWithChars(const std::string &input, const std::string &toReplace, const std::string &replacement)
Replaces all occurrences of specified characters in a string with another string.
string fillDigits(const string &word, const string &c, int ndigits)
Pads a string with a specified character until it reaches a desired length.
bool is_unset(std::string_view s)
Determine whether a string should be treated as "unset".
randomModel
Enumeration of random models.
Definition gutilities.h:409
@ gaussian
Gaussian distribution.
Definition gutilities.h:411
@ uniform
Uniform distribution.
Definition gutilities.h:410
@ sphere
Sphere distribution.
Definition gutilities.h:413
@ cosine
Cosine distribution.
Definition gutilities.h:412
string getDirFromPath(const std::string &path)
Extracts the directory path from a given file path.
Definition gutilities.cc:89
string convertToLowercase(const string &str)
Converts a string to lowercase.
bool directoryExists(const std::string &path)
Checks if a directory exists at the given path.
vector< KEY > getKeys(const map< KEY, VALUE > &map)
Retrieves all keys from a map.
string removeLeadingAndTrailingSpacesFromString(const std::string &input)
Removes leading and trailing spaces and tabs from a string.
Definition gutilities.cc:33
std::optional< std::string > searchForFileInLocations(const std::vector< std::string > &locations, std::string_view filename)
Search for a regular file across candidate locations.
void apply_uimanager_commands(const std::string &command)
Apply a single Geant4 UI command if a UI manager is available.
string searchForDirInLocations(const string &dirName, const vector< string > &possibleLocations)
Searches for a directory within a list of possible locations.
string parseFileAndRemoveComments(const string &filename, const string &commentChars, int verbosity)
Parses a file and removes all lines containing specified comment characters.
string getFileFromPath(const std::string &path)
Extracts the filename from a given file path.
Definition gutilities.cc:75
vector< std::string > getStringVectorFromString(const std::string &input)
Splits a string into a vector of strings using whitespace as delimiters.