gz-cpp-util 1.3
A c++20 library containing various utilities
file_io.hpp File Reference

Contains file reading/writing utility. More...

#include "string/utility.hpp"
#include <map>
#include <unordered_map>
#include <vector>

Go to the source code of this file.

Functions

template<typename Hash , typename Pred >
void gz::writeKeyValueFile (const std::string &filepath, const std::unordered_map< std::string, std::string, Hash, Pred > &content)
 Write a file that contains key = value pairs. More...
 
template<ReadKeyValueFileImplemented T>
gz::readKeyValueFile (const std::string &filepath, bool removeSpaces=false)
 Read a file that contains key = value pairs. More...
 
std::vector< char > gz::readBinaryFile (const std::string &filepath)
 Read a binary file and return the 8-bit words in a vector. More...
 

Detailed Description

Contains file reading/writing utility.

Function Documentation

◆ readBinaryFile()

std::vector< char > gz::readBinaryFile ( const std::string &  filepath)

Read a binary file and return the 8-bit words in a vector.

Exceptions
FileIOErrorif the file can not be opened

◆ readKeyValueFile()

template<ReadKeyValueFileImplemented T>
T gz::readKeyValueFile ( const std::string &  filepath,
bool  removeSpaces = false 
)

Read a file that contains key = value pairs.

Exceptions
FileIOErrorif the file can not be opened
See also
Key-Value filetype

◆ writeKeyValueFile()

template<typename Hash , typename Pred >
void gz::writeKeyValueFile ( const std::string &  filepath,
const std::unordered_map< std::string, std::string, Hash, Pred > &  content 
)

Write a file that contains key = value pairs.

This template function is instantiated for the default unordered_map<string, string> and the util::string_map from util/string.hpp

Exceptions
FileIOError
See also
Key-Value filetype