Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
MiscUtilities.h
1 #pragma once
2 #include <vector>
3 #include <string>
4 
8 namespace StringUtils
9 {
13  std::vector<std::string> split(const std::string& s, char delimiter, bool removeEmpty = false, unsigned int limit = 0);
17  std::string trim(std::string const& str);
21  long long int parseAsInt(std::string const& str);
35  std::vector<char*> makeArgv(std::vector<std::string>& strings);
36 }
37 
41 namespace IoUtils
42 {
43  typedef enum {
46  } Mode;
50  bool pathExists(const std::string& path);
54  std::ofstream openOutput(const std::string& path, Mode mode = TRUNCATE);
58  int writeTextFile(const std::string& path, const std::string& content, Mode mode = TRUNCATE);
62  std::string readTextFile(const std::string& path);
63 }
64 
68 namespace ConfigFileUtils {
76  std::string readValue(const std::string& path, const std::string& key);
84  std::string readValueFromString(const std::string& str, const std::string& key);
94  int writeValue(const std::string& file, const std::string& key, const std::string& value, IoUtils::Mode mode = IoUtils::TRUNCATE);
95 }
96 
100 namespace PinmuxUtils
101 {
105  bool check(const std::string& pin, const std::string& desiredState);
109  std::string get(const std::string& pin);
113  void set(const std::string& pin, const std::string& desiredState);
114 }
bool check(const std::string &pin, const std::string &desiredState)
std::string trim(std::string const &str)
std::vector< std::string > split(const std::string &s, char delimiter, bool removeEmpty=false, unsigned int limit=0)
void set(const std::string &pin, const std::string &desiredState)
std::vector< char * > makeArgv(std::vector< std::string > &strings)
long long int parseAsInt(std::string const &str)
Mode
Definition: MiscUtilities.h:43
std::ofstream openOutput(const std::string &path, Mode mode=TRUNCATE)
bool pathExists(const std::string &path)
When opening a file for writing, truncate the existing content of the file.
Definition: MiscUtilities.h:45
When opening a file for writing, append to the existing content of the file.
Definition: MiscUtilities.h:44
std::string readValue(const std::string &path, const std::string &key)
int writeTextFile(const std::string &path, const std::string &content, Mode mode=TRUNCATE)
std::string readValueFromString(const std::string &str, const std::string &key)
int writeValue(const std::string &file, const std::string &key, const std::string &value, IoUtils::Mode mode=IoUtils::TRUNCATE)
std::string readTextFile(const std::string &path)