20 const vector<float>& vec,
const string& fileName,
bool append,
bool byRows)
22 FILE* f =
os::fopen(fileName.c_str(), append ?
"at" :
"wt");
35 const vector<double>& vec,
const string& fileName,
bool append,
bool byRows)
37 FILE* f =
os::fopen(fileName.c_str(), append ?
"at" :
"wt");
50 const vector<int>& vec,
const string& fileName,
bool append,
bool byRows)
52 FILE* f =
os::fopen(fileName.c_str(), append ?
"at" :
"wt");
65 const vector<size_t>& vec,
const string& fileName,
bool append,
bool byRows)
67 FILE* f =
os::fopen(fileName.c_str(), append ?
"at" :
"wt");
71 os::fprintf(f, byRows ?
"%u " :
"%u\n", static_cast<unsigned int>(*it));
80 std::vector<double>& vec,
const std::string& fileName,
bool byRows)
82 FILE* f =
os::fopen(fileName.c_str(),
"r");
89 size_t readed = fscanf(f, byRows ?
"%lf" :
"%lf\n", &number);
90 if ((!byRows) || (readed == 1)) vec.push_back(number);
int void fclose(FILE *f)
An OS-independent version of fclose.
GLsizei const GLchar ** string
int fprintf(FILE *fil, const char *format,...) noexcept MRPT_printf_format_check(2
An OS-independent version of fprintf.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
bool vectorFromTextFile(std::vector< double > &vec, const std::string &fileName, const bool byRows=false)
Load a std::vector from a text file (compat.
FILE * fopen(const char *fileName, const char *mode) noexcept
An OS-independent version of fopen.
bool vectorToTextFile(const std::vector< float > &vec, const std::string &fileName, bool append=false, bool byRows=false)
A useful function for debugging, which saves a std::vector into a text file (compat.
const Scalar * const_iterator