file#

Namespaces#

Classes#

FileSystemItem#

class FileSystemItem#

Item on the filesystem.

Subclassed by ioh::common::file::UniqueFolder

Public Functions

inline FileSystemItem()#
inline FileSystemItem(fs::path root, const std::string &name)#

Construct a new File System Item object.

Parameters:
  • root – the directory containing the item

  • name – name of the item

inline void path(const fs::path &path)#

Set the path of the item.

inline fs::path path() const#

Accessor for path_

inline fs::path root() const#

Accessor for root_

inline std::string name() const#

Accessor for name_

inline void remove() const#

Remove the item on the filesystem.

inline fs::path operator/(const std::string &p) const#

Join the path.

inline fs::path operator/(const fs::path &p) const#

Join the path.

Protected Attributes

fs::path root_#

the directory containing the item

std::string name_#

name of the item

fs::path path_#

The full path of the file.

UniqueFolder#

class UniqueFolder : public ioh::common::file::FileSystemItem#

Creates a new folder with a unique name.

Public Functions

inline explicit UniqueFolder(fs::path root, const std::string &name)#

Construct a new Unique Folder object.

Parameters:
  • root – the directory containing the item

  • name – name of the folder

inline explicit UniqueFolder(const std::string &name)#

Construct a new Unique Folder object.

inline explicit UniqueFolder()#

Construct a new Unique Folder object.

Functions#

as_numeric_vector#

template<typename T, typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type>
inline std::vector<T> ioh::common::file::as_numeric_vector(const fs::path &path)#

Extracts all numbers from a file and converts them to a given numeric type T.

Template Parameters:
  • T – the numeric type

  • std::enable_if<std::is_arithmetic<T>::value, T>::type

Parameters:

path – The path of the

Returns:

std::vector<T> all the numbers in the file given by path

as_string#

inline std::string ioh::common::file::as_string(const fs::path &path)#

Get the file contents as string object.

Parameters:

path – the path of the file

Returns:

std::string the contents of the file

as_text_vector#

template<typename T = std::string, typename std::enable_if<std::is_constructible<T, std::string>::value, T>::type* = nullptr>
std::vector<T> ioh::common::file::as_text_vector(const fs::path &path)#

Get the file contents as a string vector per line example usage:

struct Person{
     std::string name;
     Person(const std::string& name): name(name) {}
};
std::vector<Person> persons = as_text_vector<Person>(file_with_names);

Template Parameters:

T – the type of the output vector, should be instantiatable from a std::string

Parameters:

path – the path of the file

Returns:

std::vector<T> the contents of the file

merge_dat_file#

inline void ioh::common::file::merge_dat_file(const std::string &tmp_dat_file_path, const std::string &tar_dat_file_path)#

Merge the tmp_dat_file_path to tar_dat_file_path.

Parameters:
  • tmp_dat_file_path

  • tar_dat_file_path