Molassembler  1.0.0
Molecule graph and conformer library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Serialization.h
Go to the documentation of this file.
1 
8 #ifndef INCLUDE_MOLASSEMBLER_SERIALIZATION_H
9 #define INCLUDE_MOLASSEMBLER_SERIALIZATION_H
10 
11 #include <vector>
12 #include <string>
13 #include <memory>
14 
15 #include "Molassembler/Export.h"
16 
17 namespace Scine {
18 namespace Molassembler {
19 
20 // Forward-declarations
21 class Molecule;
22 
77 class MASM_EXPORT JsonSerialization {
78 public:
82  using BinaryType = std::vector<std::uint8_t>;
83 
85  enum class BinaryFormat {
86  CBOR,
87  BSON,
88  MsgPack,
89  UBJSON
90  };
92 
95  static std::string base64Encode(const BinaryType& binary);
96  static BinaryType base64Decode(const std::string& base64String);
98 
101  JsonSerialization(JsonSerialization&& other) noexcept;
102  JsonSerialization& operator = (JsonSerialization&& other) noexcept;
103  JsonSerialization(const JsonSerialization& other);
104  JsonSerialization& operator = (const JsonSerialization& other);
107 
110  JsonSerialization() = delete;
112  explicit JsonSerialization(const std::string& jsonString);
114  explicit JsonSerialization(const Molecule& molecule);
116  JsonSerialization(const BinaryType& binary, BinaryFormat format);
118 
122  operator std::string() const;
124  operator Molecule() const;
126  BinaryType toBinary(BinaryFormat format) const;
128 
131 
149  JsonSerialization& standardize();
151 
152 private:
153  struct Impl;
154  std::unique_ptr<Impl> pImpl_;
155 };
156 
157 } // namespace Molassembler
158 } // namespace Scine
159 
160 #endif
Models a molecule as a graph (connectivity of atoms) and a list of stereopermutators.
Definition: Molecule.h:73
BinaryFormat
Binary formats that JSON can be encoded into and decoded from.
Definition: Serialization.h:85
Class representing a compact JSON serialization of a molecule.
Definition: Serialization.h:77
std::vector< std::uint8_t > BinaryType
Type used to represent binary JSON formats.
Definition: Serialization.h:82