Gemmi C++ API
Loading...
Searching...
No Matches
include
gemmi
to_json.hpp
Go to the documentation of this file.
1
// Copyright 2017 Global Phasing Ltd.
2
3
// Writing cif::Document or its parts as JSON (mmJSON, CIF-JSON, etc).
4
5
#ifndef GEMMI_TO_JSON_HPP_
6
#define GEMMI_TO_JSON_HPP_
7
#include <ostream>
// for ostream
8
#include "
cifdoc.hpp
"
9
10
namespace
gemmi
{
11
namespace
cif {
12
13
struct
JsonWriteOptions
{
14
bool
as_comcifs
=
false
;
// conform to the COMCIFS CIF-JSON draft
15
bool
group_ddl2_categories
=
false
;
// for mmJSON
16
bool
with_data_keyword
=
false
;
// for mmJSON
17
bool
bare_tags
=
false
;
// "tag" instead of "_tag"
18
bool
values_as_arrays
=
false
;
// "_tag": ["value"]
19
bool
lowercase_names
=
true
;
// write case-insensitive names as lower case
20
int
quote_numbers
= 1;
// 0=never (no s.u.), 1=mix, 2=always
21
std::string
cif_dot
=
"null"
;
// how to convert '.' from CIF
22
23
static
JsonWriteOptions
comcifs
() {
24
JsonWriteOptions
opt;
25
opt.
as_comcifs
=
true
;
26
opt.
values_as_arrays
=
true
;
27
opt.
quote_numbers
= 2;
28
opt.
cif_dot
=
"false"
;
29
return
opt;
30
}
31
32
static
JsonWriteOptions
mmjson
() {
33
JsonWriteOptions
opt;
34
opt.
group_ddl2_categories
=
true
;
35
opt.
with_data_keyword
=
true
;
36
opt.
bare_tags
=
true
;
37
opt.
values_as_arrays
=
true
;
38
opt.
lowercase_names
=
false
;
39
opt.
quote_numbers
= 0;
40
return
opt;
41
}
42
};
43
44
GEMMI_DLL
void
write_json_to_stream
(std::ostream& os,
const
Document
&
doc
,
45
const
JsonWriteOptions
&
options
);
46
47
inline
void
write_mmjson_to_stream
(std::ostream& os,
const
Document
&
doc
) {
48
write_json_to_stream
(os,
doc
,
JsonWriteOptions::mmjson
());
49
}
50
51
}
// namespace cif
52
}
// namespace gemmi
53
#endif
cifdoc.hpp
struct Document that represents the CIF file (but can also be read from a different representation,...
GEMMI_DLL
#define GEMMI_DLL
Definition
fail.hpp:53
gemmi::cif::write_mmjson_to_stream
void write_mmjson_to_stream(std::ostream &os, const Document &doc)
Definition
to_json.hpp:47
gemmi::cif::write_json_to_stream
GEMMI_DLL void write_json_to_stream(std::ostream &os, const Document &doc, const JsonWriteOptions &options)
gemmi
Definition
addends.hpp:12
gemmi::HklValue
Definition
asudata.hpp:98
gemmi::cif::Document
Definition
cifdoc.hpp:1061
gemmi::cif::JsonWriteOptions
Definition
to_json.hpp:13
gemmi::cif::JsonWriteOptions::with_data_keyword
bool with_data_keyword
Definition
to_json.hpp:16
gemmi::cif::JsonWriteOptions::lowercase_names
bool lowercase_names
Definition
to_json.hpp:19
gemmi::cif::JsonWriteOptions::comcifs
static JsonWriteOptions comcifs()
Definition
to_json.hpp:23
gemmi::cif::JsonWriteOptions::values_as_arrays
bool values_as_arrays
Definition
to_json.hpp:18
gemmi::cif::JsonWriteOptions::quote_numbers
int quote_numbers
Definition
to_json.hpp:20
gemmi::cif::JsonWriteOptions::bare_tags
bool bare_tags
Definition
to_json.hpp:17
gemmi::cif::JsonWriteOptions::cif_dot
std::string cif_dot
Definition
to_json.hpp:21
gemmi::cif::JsonWriteOptions::as_comcifs
bool as_comcifs
Definition
to_json.hpp:14
gemmi::cif::JsonWriteOptions::group_ddl2_categories
bool group_ddl2_categories
Definition
to_json.hpp:15
gemmi::cif::JsonWriteOptions::mmjson
static JsonWriteOptions mmjson()
Definition
to_json.hpp:32
Generated by
1.9.8