BuildCache
direct_mode_manifest.hpp
1 //--------------------------------------------------------------------------------------------------
2 // Copyright (c) 2021 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_DIRECT_MODE_MANIFEST_HPP_
21 #define BUILDCACHE_DIRECT_MODE_MANIFEST_HPP_
22 
23 #include <map>
24 #include <string>
25 
26 namespace bcache {
29 public:
32 
36  direct_mode_manifest_t(const std::string& hash,
37  const std::map<std::string, std::string>& files_with_hashes);
38 
41  operator bool() const {
42  return m_valid;
43  }
44 
47  std::string serialize() const;
48 
52  static direct_mode_manifest_t deserialize(const std::string& data);
53 
55  const std::string& hash() const {
56  return m_hash;
57  }
58 
60  const std::map<std::string, std::string>& files_width_hashes() const {
61  return m_files_width_hashes;
62  }
63 
64 private:
65  std::string m_hash;
66  std::map<std::string, std::string> m_files_width_hashes;
67  bool m_valid = false; // true if this is a valid manifest.
68 };
69 } // namespace bcache
70 
71 #endif // BUILDCACHE_DIRECT_MODE_MANIFEST_HPP_
bcache::direct_mode_manifest_t::direct_mode_manifest_t
direct_mode_manifest_t()
Construct an empty/invalid manifest.
Definition: direct_mode_manifest.cpp:34
bcache
The top level namespace.
Definition: compressor.cpp:34
bcache::direct_mode_manifest_t
A direct mode cache manifest.
Definition: direct_mode_manifest.hpp:28
bcache::direct_mode_manifest_t::hash
const std::string & hash() const
Definition: direct_mode_manifest.hpp:55
bcache::direct_mode_manifest_t::deserialize
static direct_mode_manifest_t deserialize(const std::string &data)
Deserialize a manifest.
Definition: direct_mode_manifest.cpp:64
bcache::direct_mode_manifest_t::files_width_hashes
const std::map< std::string, std::string > & files_width_hashes() const
Definition: direct_mode_manifest.hpp:60
bcache::direct_mode_manifest_t::serialize
std::string serialize() const
Serialize a manifest.
Definition: direct_mode_manifest.cpp:43