Debian Codegraph @

avogadro/io/cjsonformat.h

raw
1 /******************************************************************************
2 This source file is part of the Avogadro project.
3 This source code is released under the 3-Clause BSD License, (see "LICENSE").
4 ******************************************************************************/
5
6 #ifndef AVOGADRO_IO_CJSONFORMAT_H
7 #define AVOGADRO_IO_CJSONFORMAT_H
8
9 #include "fileformat.h"
10
11 namespace Avogadro {
12 namespace Core {
13 class GaussianSet;
14 }
15 namespace Io {
16
17 /**
18 * @class CjsonFormat cjsonformat.h <avogadro/io/cjsonformat.h>
19 * @brief Implementation of the Chemical JSON format.
20 */
21
22 class AVOGADROIO_EXPORT CjsonFormat : public FileFormat
23 {
24 public:
25 CjsonFormat() = default;
26 ~CjsonFormat() override = default;
27
28 Operations supportedOperations() const override
29 {
30 return ReadWrite | File | Stream | String;
31 }
32
33 FileFormat* newInstance() const override { return new CjsonFormat; }
34 std::string identifier() const override { return "Avogadro: CJSON"; }
35 std::string name() const override { return "Chemical JSON"; }
36 std::string description() const override
37 {
38 return "CJSON format is a lightweight intermediate format used to exchange "
39 "information between Avogadro and other data parsing applications";
40 }
41
42 std::string specificationUrl() const override
43 {
44 return "https://github.com/openchemistry/chemicaljson";
45 }
46
47 std::vector<std::string> fileExtensions() const override;
48 std::vector<std::string> mimeTypes() const override;
49
50 [[nodiscard]] bool read(std::istream& in, Core::Molecule& molecule) override;
51 [[nodiscard]] bool write(std::ostream& out,
52 const Core::Molecule& molecule) override;
53
54 // internal - to allow JSON or MsgPack to be written
55 bool deserialize(std::istream& in, Core::Molecule& molecule, bool json);
56 bool serialize(std::ostream& out, const Core::Molecule& molecule, bool json);
57 };
58
59 } // namespace Io
60 } // namespace Avogadro
61
62 #endif // AVOGADRO_IO_CJSONFORMAT_H