Main MRPT website > C++ reference for MRPT 1.9.9
system/include/mrpt/system/vector_loadsave.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <string>
12 #include <vector>
13 
14 namespace mrpt
15 {
16 namespace system
17 {
18 /** @defgroup vector_loadsave Load and save vectors to files (in #include
19  * <mrpt/system/vector_loadsave.h>)
20  * \ingroup mrpt_system_grp
21  * @{ */
22 
23 /** A useful function for debugging, which saves a std::vector into a text file
24 * (compat. with MATLAB)
25 * \return Returns false on any error, true on everything OK.
26 */
27 bool vectorToTextFile(
28  const std::vector<float>& vec, const std::string& fileName,
29  bool append = false, bool byRows = false);
30 //! \overload
31 bool vectorToTextFile(
32  const std::vector<double>& vec, const std::string& fileName,
33  bool append = false, bool byRows = false);
34 //! \overload
35 bool vectorToTextFile(
36  const std::vector<int>& vec, const std::string& fileName,
37  bool append = false, bool byRows = false);
38 //! \overload
39 bool vectorToTextFile(
40  const std::vector<size_t>& vec, const std::string& fileName,
41  bool append = false, bool byRows = false);
42 //! \overload
43 template <class EIGEN_MATRIX>
44 bool vectorToTextFile(const EIGEN_MATRIX& vec, const std::string& fileName)
45 {
46  try
47  {
48  vec.saveToTextFile(fileName);
49  return true;
50  }
51  catch (...)
52  {
53  return false;
54  }
55 }
56 
57 /** Load a std::vector from a text file (compat. with MATLAB)
58 * \return Returns false on any error, true on everything OK.
59 * \sa loadBinaryFile
60 */
62  std::vector<double>& vec, const std::string& fileName,
63  const bool byRows = false);
64 
65 /** @} */
66 
67 } // End of namespace
68 } // End of namespace
GLsizei const GLchar ** string
Definition: glext.h:4101
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.
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.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019