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);
17  std::string trim(std::string const& str);
31  std::vector<char*> makeArgv(std::vector<std::string>& strings);
32 }
33 
37 namespace IoUtils
38 {
39  typedef enum {
42  } Mode;
46  std::ofstream openOutput(const std::string& path, Mode mode = TRUNCATE);
50  int writeTextFile(const std::string& path, const std::string& content, Mode mode = TRUNCATE);
54  std::string readTextFile(const std::string& path);
55 }
56 
60 namespace ConfigFileUtils {
68  std::string readValue(const std::string& path, const std::string& key);
76  std::string readValueFromString(const std::string& str, const std::string& key);
86  int writeValue(const std::string& file, const std::string& key, const std::string& value, IoUtils::Mode mode = IoUtils::TRUNCATE);
87 }
std::string trim(std::string const &str)
std::vector< char * > makeArgv(std::vector< std::string > &strings)
std::vector< std::string > split(const std::string &s, char delimiter, bool removeEmpty=false)
Mode
Definition: MiscUtilities.h:39
std::ofstream openOutput(const std::string &path, Mode mode=TRUNCATE)
When opening a file for writing, truncate the existing content of the file.
Definition: MiscUtilities.h:41
When opening a file for writing, append to the existing content of the file.
Definition: MiscUtilities.h:40
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)