Some random tools to ease the project. More...
#include <algorithm>#include <cassert>#include <cstdio>#include <dirent.h>#include <iostream>#include <regex>#include <sstream>#include <string>#include <sys/stat.h>#include <sys/types.h>#include <vector>Go to the source code of this file.
Namespaces | |
| utils | |
Functions | |
| template<typename T > | |
| std::ostream & | operator<< (std::ostream &os, const std::vector< T > &v) |
Display an std::vector object. More... | |
| bool | contains (const std::vector< std::string > &v, const std::string &other) |
| Check if a vector contains an item. More... | |
| bool | utils::file_exists (const std::string &name) |
| Check if a file exists regardless of types. More... | |
| bool | utils::folder_exists (std::string foldername) |
| Checks if a folder exists. More... | |
| int | utils::_mkdir (const char *path) |
| Portable wrapper for mkdir. More... | |
| int | utils::mkdir (const char *path) |
| Recursive, portable wrapper for mkdir. More... | |
| std::vector< std::string > | list_dir (const std::string &path, const std::string &pattern=".*") |
| Return the list of files matching a pattern from a given directory. More... | |
| std::vector< std::string > | split_string (const std::string &text, const std::string &delimiter) |
| Split string into bits according to a given delimiter. More... | |
| std::string | toupper (std::string s) |
| Returns the upper case of a string. More... | |
| std::string | tolower (std::string s) |
| Returns the lower case of a string. More... | |
| template<typename... Args> | |
| std::string | string_sprintf (const char *format, Args... args) |
| Helper to make a string with formatting options. More... | |
| template<typename T > | |
| T | parseString (const char *txt) |
| Parse a char* into a numeric value. More... | |
| template<typename T > | |
| T | parseString (const std::string &txt) |
| Parse a std::string into a numeric value. More... | |
| bool contains | ( | const std::vector< std::string > & | v, |
| const std::string & | other | ||
| ) |
Check if a vector contains an item.
Definition at line 45 of file helpers.hpp.
| std::vector<std::string> list_dir | ( | const std::string & | path, |
| const std::string & | pattern = ".*" |
||
| ) |
Return the list of files matching a pattern from a given directory.
| path | where to look for files |
| pattern | which pattern to match (regex needed) |
Definition at line 132 of file helpers.hpp.
| std::ostream& operator<< | ( | std::ostream & | os, |
| const std::vector< T > & | v | ||
| ) |
Display an std::vector object.
Definition at line 32 of file helpers.hpp.
| T parseString | ( | const char * | txt | ) |
Parse a char* into a numeric value.
| T | the output type |
| txt | the string to parse |
Definition at line 227 of file helpers.hpp.
| T parseString | ( | const std::string & | txt | ) |
Parse a std::string into a numeric value.
| T | the output type |
| txt | the string to parse |
Definition at line 240 of file helpers.hpp.
| std::vector<std::string> split_string | ( | const std::string & | text, |
| const std::string & | delimiter | ||
| ) |
Split string into bits according to a given delimiter.
| text | original string |
| delimiter | string to cut on |
Definition at line 161 of file helpers.hpp.
| std::string string_sprintf | ( | const char * | format, |
| Args... | args | ||
| ) |
Helper to make a string with formatting options.
Note that c++20 has std::format in the <format> library
| format | formatting string similar to printf |
| args | formatting arguments |
Definition at line 207 of file helpers.hpp.
| std::string tolower | ( | std::string | s | ) |
Returns the lower case of a string.
Definition at line 190 of file helpers.hpp.
| std::string toupper | ( | std::string | s | ) |
Returns the upper case of a string.
Definition at line 180 of file helpers.hpp.