MRPT  1.9.9
io/include/mrpt/io/vector_loadsave.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <string>
12 #include <vector>
13 
14 namespace mrpt::io
15 {
16 /** @defgroup vector_loadsave Load and save vectors to files (in #include
17  * <mrpt/io/vector_loadsave.h>)
18  * \ingroup mrpt_io_grp
19  * @{ */
20 
21 /** Saves a vector directly as a binary dump to a file:
22  * \return Returns false on any error, true on everything OK.
23  * \sa loadBinaryFile
24  */
26  const std::vector<uint8_t>& vec, const std::string& fileName);
27 
28 /** Loads a entire file as a vector of bytes.
29  * \return Returns false on any error, true on everything OK.
30  * \sa vectorToBinaryFile
31  */
32 bool loadBinaryFile(
33  std::vector<uint8_t>& out_data, const std::string& fileName);
34 
35 /** Loads a text file as a vector of string lines.
36  * \return Returns false on any error, true on everything OK.
37  * \sa file_get_contents()
38  */
39 bool loadTextFile(std::vector<std::string>& o, const std::string& fileName);
40 
41 /** Loads an entire text file and return its contents as a single std::string.
42  * \exception std::runtime_error On any read error.
43  * \sa loadBinaryFile(), loadTextFile()
44  * \note Relying on C++17 RVO to return a string without worring on
45  * return-by-value of big objects.
46  */
48 
49 /** @} */
50 
51 } // namespace mrpt::io
bool vectorToBinaryFile(const std::vector< uint8_t > &vec, const std::string &fileName)
Saves a vector directly as a binary dump to a file:
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.
GLsizei const GLchar ** string
Definition: glext.h:4116
std::string file_get_contents(const std::string &fileName)
Loads an entire text file and return its contents as a single std::string.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: cb8dd5fc8 Sat Dec 7 21:55:39 2019 +0100 at sáb dic 7 22:00:13 CET 2019