22 std::vector<uint8_t>& out_data,
const std::string& fileName)
27 size_t N = fi.getTotalBytesCount();
32 size_t NN = fi.Read(&out_data[0], N);
45 const std::vector<uint8_t>& vec,
const std::string& fileName)
50 if (!vec.empty()) of.Write(&vec[0],
sizeof(vec[0]) * vec.size());
60 std::vector<std::string>& o,
const std::string& fileName)
63 std::ifstream f(fileName);
64 if (!f.is_open())
return false;
66 while (std::getline(f, s)) o.emplace_back(std::move(s));
75 std::ifstream t(fileName, ios::binary);
78 "file_get_contents(): Error opening for read file `%s`",
82 std::size_t
size = t.tellg();
83 std::string buffer(
size,
' ');
85 t.read(&buffer[0],
size);
bool vectorToBinaryFile(const std::vector< uint8_t > &vec, const std::string &fileName)
Saves a vector directly as a binary dump to a file:
size_t size(const MATRIXLIKE &m, const int dim)
bool loadBinaryFile(std::vector< uint8_t > &out_data, const std::string &fileName)
Loads a entire file as a vector of bytes.
bool loadTextFile(std::vector< std::string > &o, const std::string &fileName)
Loads a text file as a vector of string lines.
This CStream derived class allow using a file as a write-only, binary stream.
const_iterator end() const
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::string file_get_contents(const std::string &fileName)
Loads an entire text file and return its contents as a single std::string.
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)