A toolkit for working with phylogenetic data.
v0.19.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
utils/formats/json/reader.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_UTILS_FORMATS_JSON_READER_H_
2 #define GENESIS_UTILS_FORMATS_JSON_READER_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2017 Lucas Czech
7 
8  This program is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 
21  Contact:
22  Lucas Czech <lucas.czech@h-its.org>
23  Exelixis Lab, Heidelberg Institute for Theoretical Studies
24  Schloss-Wolfsbrunnenweg 35, D-69118 Heidelberg, Germany
25 */
26 
34 #include <iosfwd>
35 #include <string>
36 
37 namespace genesis {
38 namespace utils {
39 
40 // =================================================================================================
41 // Forward declarations
42 // =================================================================================================
43 
44 class InputStream;
45 class JsonDocument;
46 
47 // =================================================================================================
48 // Json Reader
49 // =================================================================================================
50 
60 {
61 public:
62 
63  // ---------------------------------------------------------------------
64  // Constructor and Rule of Five
65  // ---------------------------------------------------------------------
66 
67  JsonReader() = default;
68  ~JsonReader() = default;
69 
70  JsonReader( JsonReader const& ) = default;
71  JsonReader( JsonReader&& ) = default;
72 
73  JsonReader& operator= ( JsonReader const& ) = default;
74  JsonReader& operator= ( JsonReader&& ) = default;
75 
76  // ---------------------------------------------------------------------
77  // Reading
78  // ---------------------------------------------------------------------
79 
83  JsonDocument from_stream( std::istream& input_stream ) const;
84 
90  JsonDocument from_file (const std::string& filename ) const;
91 
95  JsonDocument from_string (const std::string& json ) const;
96 
97  // ---------------------------------------------------------------------
98  // Parsing Functions
99  // ---------------------------------------------------------------------
100 
101  JsonDocument parse( InputStream& input_stream ) const;
102  JsonDocument parse_value( InputStream& input_stream ) const;
103  JsonDocument parse_array( InputStream& input_stream ) const;
104  JsonDocument parse_object( InputStream& input_stream ) const;
105  JsonDocument parse_number( InputStream& input_stream ) const;
106 
107 };
108 
109 } // namespace utils
110 } // namespace genesis
111 
112 #endif // include guard
JsonDocument from_file(const std::string &filename) const
Take a JSON document file path and parse its contents into a JsonDocument.
Read Json data into a JsonDocument.
JsonDocument parse_array(InputStream &input_stream) const
JsonDocument parse_value(InputStream &input_stream) const
JsonReader & operator=(JsonReader const &)=default
JsonDocument parse_number(InputStream &input_stream) const
JsonDocument from_string(const std::string &json) const
Take a string containing a JSON document and parse its contents into a JsonDocument.
Store a Json value of any kind.
JsonDocument parse_object(InputStream &input_stream) const
JsonDocument parse(InputStream &input_stream) const
JsonDocument from_stream(std::istream &input_stream) const
Read from a stream containing a JSON document and parse its contents into a JsonDocument.
Stream interface for reading data from an InputSource, that keeps track of line and column counters...