MRPT  2.0.4
Functions
Load and save vectors to files (in #include <mrpt/io/vector_loadsave.h>)

Detailed Description

Collaboration diagram for Load and save vectors to files (in #include <mrpt/io/vector_loadsave.h>):

Functions

bool mrpt::io::vectorToBinaryFile (const std::vector< uint8_t > &vec, const std::string &fileName)
 Saves a vector directly as a binary dump to a file: More...
 
bool mrpt::io::loadBinaryFile (std::vector< uint8_t > &out_data, const std::string &fileName)
 Loads a entire file as a vector of bytes. More...
 
bool mrpt::io::loadTextFile (std::vector< std::string > &o, const std::string &fileName)
 Loads a text file as a vector of string lines. More...
 
std::string mrpt::io::file_get_contents (const std::string &fileName)
 Loads an entire text file and return its contents as a single std::string. More...
 
bool mrpt::io::vectorToTextFile (const std::vector< float > &vec, const std::string &fileName, bool append=false, bool byRows=false)
 A useful function for debugging, which saves a numeric std::vector as a plain-text file compatible with MATLAB. More...
 
bool mrpt::io::vectorToTextFile (const std::vector< double > &vec, const std::string &fileName, bool append=false, bool byRows=false)
 
bool mrpt::io::vectorToTextFile (const std::vector< int > &vec, const std::string &fileName, bool append=false, bool byRows=false)
 
bool mrpt::io::vectorToTextFile (const std::vector< size_t > &vec, const std::string &fileName, bool append=false, bool byRows=false)
 
template<class EIGEN_MATRIX >
bool mrpt::io::vectorToTextFile (const EIGEN_MATRIX &vec, const std::string &fileName)
 
bool mrpt::io::vectorNumericFromTextFile (std::vector< double > &vec, const std::string &fileName, const bool byRows=false)
 Load a numeric std::vector<double> from a text file (compat. More...
 

Function Documentation

◆ file_get_contents()

std::string mrpt::io::file_get_contents ( const std::string &  fileName)

Loads an entire text file and return its contents as a single std::string.

Exceptions
std::runtime_errorOn any read error.
See also
loadBinaryFile(), loadTextFile()
Note
Relying on C++17 RVO to return a string without worring on return-by-value of big objects.

Definition at line 72 of file vector_loadsave.cpp.

References mrpt::containers::end(), mrpt::math::size(), and THROW_EXCEPTION_FMT.

Referenced by mrpt::apps::KFSLAMApp::initialize(), mrpt::apps::RawlogGrabberApp::initialize(), mrpt::apps::RBPF_SLAM_App_Base::initialize(), mrpt::apps::ICP_SLAM_App_Base::initialize(), mrpt::apps::MonteCarloLocalization_Base::initialize(), and TEST().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadBinaryFile()

bool mrpt::io::loadBinaryFile ( std::vector< uint8_t > &  out_data,
const std::string &  fileName 
)

Loads a entire file as a vector of bytes.

Returns
Returns false on any error, true on everything OK.
See also
vectorToBinaryFile

Definition at line 23 of file vector_loadsave.cpp.

References mrpt::io::CFileInputStream::getTotalBytesCount(), and mrpt::io::CFileInputStream::Read().

Here is the call graph for this function:

◆ loadTextFile()

bool mrpt::io::loadTextFile ( std::vector< std::string > &  o,
const std::string &  fileName 
)

Loads a text file as a vector of string lines.

Returns
Returns false on any error, true on everything OK.
See also
file_get_contents()

Definition at line 61 of file vector_loadsave.cpp.

◆ vectorNumericFromTextFile()

bool mrpt::io::vectorNumericFromTextFile ( std::vector< double > &  vec,
const std::string &  fileName,
const bool  byRows = false 
)

Load a numeric std::vector<double> from a text file (compat.

with MATLAB)

Returns
Returns false on any error, true on everything OK.
See also
loadBinaryFile

Definition at line 148 of file vector_loadsave.cpp.

References mrpt::system::os::fopen().

Here is the call graph for this function:

◆ vectorToBinaryFile()

bool mrpt::io::vectorToBinaryFile ( const std::vector< uint8_t > &  vec,
const std::string &  fileName 
)

Saves a vector directly as a binary dump to a file:

Returns
Returns false on any error, true on everything OK.
See also
loadBinaryFile

Definition at line 46 of file vector_loadsave.cpp.

References mrpt::io::CFileOutputStream::Write().

Referenced by mrpt::io::zip::decompress_gz_data_block().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vectorToTextFile() [1/5]

bool mrpt::io::vectorToTextFile ( const std::vector< float > &  vec,
const std::string &  fileName,
bool  append = false,
bool  byRows = false 
)

A useful function for debugging, which saves a numeric std::vector as a plain-text file compatible with MATLAB.

Returns
Returns false on any error, true on everything OK.

Definition at line 91 of file vector_loadsave.cpp.

References mrpt::system::os::fclose(), mrpt::system::os::fopen(), and mrpt::system::os::fprintf().

Referenced by mrpt::apps::CGridMapAlignerApp::run(), and mrpt::bayes::CKalmanFilterCapable< 7, 3, 3, 7 >::runOneKalmanIteration().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vectorToTextFile() [2/5]

bool mrpt::io::vectorToTextFile ( const std::vector< double > &  vec,
const std::string &  fileName,
bool  append = false,
bool  byRows = false 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 105 of file vector_loadsave.cpp.

References mrpt::system::os::fclose(), mrpt::system::os::fopen(), and mrpt::system::os::fprintf().

Here is the call graph for this function:

◆ vectorToTextFile() [3/5]

bool mrpt::io::vectorToTextFile ( const std::vector< int > &  vec,
const std::string &  fileName,
bool  append = false,
bool  byRows = false 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 119 of file vector_loadsave.cpp.

References mrpt::system::os::fclose(), mrpt::system::os::fopen(), and mrpt::system::os::fprintf().

Here is the call graph for this function:

◆ vectorToTextFile() [4/5]

bool mrpt::io::vectorToTextFile ( const std::vector< size_t > &  vec,
const std::string &  fileName,
bool  append = false,
bool  byRows = false 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 133 of file vector_loadsave.cpp.

References mrpt::system::os::fclose(), mrpt::system::os::fopen(), and mrpt::system::os::fprintf().

Here is the call graph for this function:

◆ vectorToTextFile() [5/5]

template<class EIGEN_MATRIX >
bool mrpt::io::vectorToTextFile ( const EIGEN_MATRIX &  vec,
const std::string &  fileName 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 71 of file vector_loadsave.h.




Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020