Gemmi C++ API
Loading...
Searching...
No Matches
read_cif.hpp
Go to the documentation of this file.
1// Copyright 2021 Global Phasing Ltd.
2//
3// Functions for reading possibly gzipped CIF files.
4
5#ifndef GEMMI_READ_CIF_HPP_
6#define GEMMI_READ_CIF_HPP_
7
8#include "cifdoc.hpp" // for Document
9#include "fileutil.hpp" // for CharArray
10
11namespace gemmi {
12
13GEMMI_DLL cif::Document read_cif_gz(const std::string& path, int check_level=1);
14GEMMI_DLL bool check_cif_syntax_gz(const std::string& path, std::string* msg);
15GEMMI_DLL cif::Document read_mmjson_gz(const std::string& path);
16GEMMI_DLL CharArray read_into_buffer_gz(const std::string& path);
17GEMMI_DLL cif::Document read_cif_from_memory(const char* data, size_t size, const char* name,
18 int check_level=1);
19GEMMI_DLL cif::Document read_first_block_gz(const std::string& path, size_t limit);
20
21// cif::read_string() was moved here from cif.hpp to speed up compilation
22namespace cif {
23inline Document read_string(const std::string& data, int check_level=1) {
24 return read_cif_from_memory(data.data(), data.size(), "string", check_level);
25}
26} // namespace cif
27
28inline cif::Document read_cif_or_mmjson_gz(const std::string& path) {
29 if (giends_with(path, "json") || giends_with(path, "js"))
30 return read_mmjson_gz(path);
31 return read_cif_gz(path);
32}
33
34} // namespace gemmi
35
36#endif
struct Document that represents the CIF file (but can also be read from a different representation,...
#define GEMMI_DLL
Definition fail.hpp:53
File-related utilities.
Document read_string(const std::string &data, int check_level=1)
Definition read_cif.hpp:23
GEMMI_DLL cif::Document read_first_block_gz(const std::string &path, size_t limit)
GEMMI_DLL cif::Document read_cif_from_memory(const char *data, size_t size, const char *name, int check_level=1)
GEMMI_DLL cif::Document read_mmjson_gz(const std::string &path)
GEMMI_DLL bool check_cif_syntax_gz(const std::string &path, std::string *msg)
bool giends_with(const std::string &str, const std::string &suffix)
Definition util.hpp:106
GEMMI_DLL CharArray read_into_buffer_gz(const std::string &path)
cif::Document read_cif_or_mmjson_gz(const std::string &path)
Definition read_cif.hpp:28
GEMMI_DLL cif::Document read_cif_gz(const std::string &path, int check_level=1)