A toolkit for working with phylogenetic data.
v0.22.1
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-2018 Lucas Czech and HITS gGmbH
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 
35 
36 #include <iosfwd>
37 #include <memory>
38 #include <string>
39 
40 namespace genesis {
41 namespace utils {
42 
43 // =================================================================================================
44 // Forward declarations
45 // =================================================================================================
46 
47 class InputStream;
48 class JsonDocument;
49 
50 // =================================================================================================
51 // Json Reader
52 // =================================================================================================
53 
63 {
64 public:
65 
66  // ---------------------------------------------------------------------
67  // Constructor and Rule of Five
68  // ---------------------------------------------------------------------
69 
70  JsonReader() = default;
71  ~JsonReader() = default;
72 
73  JsonReader( JsonReader const& ) = default;
74  JsonReader( JsonReader&& ) = default;
75 
76  JsonReader& operator= ( JsonReader const& ) = default;
77  JsonReader& operator= ( JsonReader&& ) = default;
78 
79  // ---------------------------------------------------------------------
80  // Reading
81  // ---------------------------------------------------------------------
82 
90  JsonDocument read( std::shared_ptr<BaseInputSource> source ) const;
91 
92  // ---------------------------------------------------------------------
93  // Parsing Functions
94  // ---------------------------------------------------------------------
95 
96  JsonDocument parse( InputStream& input_stream ) const;
97  JsonDocument parse_value( InputStream& input_stream ) const;
98  JsonDocument parse_array( InputStream& input_stream ) const;
99  JsonDocument parse_object( InputStream& input_stream ) const;
100  JsonDocument parse_number( InputStream& input_stream ) const;
101 
102 };
103 
104 } // namespace utils
105 } // namespace genesis
106 
107 #endif // include guard
JsonDocument parse_object(InputStream &input_stream) const
Read Json data into a JsonDocument.
Container namespace for all symbols of genesis in order to keep them separate when used as a library...
JsonReader & operator=(JsonReader const &)=default
JsonDocument parse_number(InputStream &input_stream) const
JsonDocument parse(InputStream &input_stream) const
Store a Json value of any kind.
JsonDocument read(std::shared_ptr< BaseInputSource > source) const
Read from a source containing a JSON document and parse its contents into a JsonDocument.
JsonDocument parse_array(InputStream &input_stream) const
JsonDocument parse_value(InputStream &input_stream) const
Stream interface for reading data from an InputSource, that keeps track of line and column counters...