BuildCache
serializer_utils.hpp
1 //--------------------------------------------------------------------------------------------------
2 // Copyright (c) 2018 Marcus Geelnard
3 //
4 // This software is provided 'as-is', without any express or implied warranty. In no event will the
5 // authors be held liable for any damages arising from the use of this software.
6 //
7 // Permission is granted to anyone to use this software for any purpose, including commercial
8 // applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 //
10 // 1. The origin of this software must not be misrepresented; you must not claim that you wrote
11 // the original software. If you use this software in a product, an acknowledgment in the
12 // product documentation would be appreciated but is not required.
13 //
14 // 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
15 // being the original software.
16 //
17 // 3. This notice may not be removed or altered from any source distribution.
18 //--------------------------------------------------------------------------------------------------
19 
20 #ifndef BUILDCACHE_SERIALIZER_UTILS_HPP_
21 #define BUILDCACHE_SERIALIZER_UTILS_HPP_
22 
23 #include <cstdint>
24 #include <map>
25 #include <string>
26 #include <vector>
27 
28 namespace bcache {
29 namespace serialize {
30 std::string from_bool(const bool x);
31 std::string from_int(const int32_t x);
32 std::string from_string(const std::string& x);
33 std::string from_vector(const std::vector<std::string>& x);
34 std::string from_map(const std::map<std::string, std::string>& x);
35 
36 bool to_bool(const std::string& data, std::string::size_type& pos);
37 int32_t to_int(const std::string& data, std::string::size_type& pos);
38 std::string to_string(const std::string& data, std::string::size_type& pos);
39 std::vector<std::string> to_vector(const std::string& data, std::string::size_type& pos);
40 std::map<std::string, std::string> to_map(const std::string& data, std::string::size_type& pos);
41 } // namespace serialize
42 } // namespace bcache
43 
44 #endif // BUILDCACHE_SERIALIZER_UTILS_HPP_
bcache
The top level namespace.
Definition: compressor.cpp:34