10 #include <boost/filesystem.hpp>
23 #define STRINGIFY(s) STRINGIFY_(s)
24 #define STRINGIFY_(s) #s
42 void FileCopy(
const std::string& src_path,
43 const std::string& dst_path,
66 std::string
GetRelativePath(
const std::string& from,
const std::string& to);
69 template <
typename... T>
101 template <
typename T>
102 std::vector<T>
CSVToVector(
const std::string& csv);
105 template <
typename T>
106 std::string
VectorToCSV(
const std::vector<T>& values);
109 template <
typename T>
113 template <
typename T>
127 template <
typename... T>
131 static_cast<void>(unpack);
135 template <
typename T>
137 return std::find_if(vector.begin(), vector.end(), [value](
const T element) {
138 return element == value;
142 template <
typename T>
144 std::vector<T> unique_vector = vector;
145 return std::unique(unique_vector.begin(), unique_vector.end()) !=
149 template <
typename T>
152 for (
const T value : values) {
155 return string.substr(0,
string.length() - 2);
158 template <
typename T>
160 std::ifstream file(
path, std::ios::binary | std::ios::ate);
161 CHECK(file.is_open()) <<
path;
162 file.seekg(0, std::ios::end);
163 const size_t num_bytes = file.tellg();
164 CHECK_EQ(num_bytes %
sizeof(T), 0);
165 data->resize(num_bytes /
sizeof(T));
166 file.seekg(0, std::ios::beg);
167 ReadBinaryLittleEndian<T>(&file,
data);
170 template <
typename T>
172 std::ofstream file(
path, std::ios::binary);
173 CHECK(file.is_open()) <<
path;
174 WriteBinaryLittleEndian<T>(&file,
data);
static const std::string path
void ReadBinaryBlob(const std::string &path, std::vector< T > *data)
size_t GetFileSize(const std::string &path)
void PrintHeading2(const std::string &heading)
bool ExistsPath(const std::string &path)
bool VectorContainsDuplicateValues(const std::vector< T > &vector)
bool HasFileExtension(const std::string &file_name, const std::string &ext)
std::vector< std::string > GetRecursiveFileList(const std::string &path)
std::vector< std::string > CSVToVector(const std::string &csv)
std::string GetPathBaseName(const std::string &path)
std::string GetRelativePath(const std::string &from, const std::string &to)
void SplitFileExtension(const std::string &path, std::string *root, std::string *ext)
void WriteBinaryBlob(const std::string &path, const std::vector< T > &data)
std::vector< std::string > ReadTextFileLines(const std::string &path)
bool ExistsDir(const std::string &path)
bool ExistsFile(const std::string &path)
void CreateDirIfNotExists(const std::string &path)
std::string JoinPaths(T const &... paths)
std::string EnsureTrailingSlash(const std::string &str)
void PrintHeading1(const std::string &heading)
std::string VectorToCSV(const std::vector< T > &values)
std::vector< std::string > GetRecursiveDirList(const std::string &path)
bool VectorContainsValue(const std::vector< T > &vector, const T value)
std::vector< std::string > GetFileList(const std::string &path)
std::string GetParentDir(const std::string &path)
void RemoveCommandLineArgument(const std::string &arg, int *argc, char **argv)
std::vector< std::string > GetDirList(const std::string &path)
void FileCopy(const std::string &src_path, const std::string &dst_path, CopyType type)
std::string to_string(const T &n)