Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 62 lines (61 sloc) 2.416 kB
7bf4398 @pibara Added LGPL comments to the code, added comment and made a few robustn…
authored
1 //JsonMe++ C++ JSON parsing (wrapper) library.
2 //Copyright (C) Rob J Meijer 2011 <jsonme@polacanthus.net>
3 //
4 //This library is free software; you can redistribute it and/or
5 //modify it under the terms of the GNU Lesser General Public
6 //License as published by the Free Software Foundation; either
7 //version 2.1 of the License, or (at your option) any later version.
8 //
9 //This library is distributed in the hope that it will be useful,
10 //but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 //Lesser General Public License for more details.
13 //
14 //You should have received a copy of the GNU Lesser General Public
15 //License along with this library; if not, write to the Free Software
16 //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
94baac2 @pibara Initial commit
authored
17 #include "GobjectImplFsTopNode.hpp"
18 #include "GobjectImplError.hpp"
19 #include "GobjectImplNode.hpp"
20 #include "GobjectImplScalar.hpp"
21 namespace jsonme {
22 namespace impl {
7bf4398 @pibara Added LGPL comments to the code, added comment and made a few robustn…
authored
23 //Constructor.
8e7dc2b @pibara Made things compile with compiler flags set.
authored
24 GobjectImplFsTopNode::GobjectImplFsTopNode(std::string const & path):mParser(),mRoot(0) {
7bf4398 @pibara Added LGPL comments to the code, added comment and made a few robustn…
authored
25 GobjectImplError lerror; //Use a RAII like object for holding our error state.
94baac2 @pibara Initial commit
authored
26 json_parser_load_from_file (mParser,path.c_str(), lerror.errorp());
27 if (lerror.error()) {
28 throw jsonme::ParseError(lerror.error()->message);
29 }
7bf4398 @pibara Added LGPL comments to the code, added comment and made a few robustn…
authored
30 mRoot=new GobjectImplNode(json_parser_get_root(mParser)); // Wrap the root node from the file.
94baac2 @pibara Initial commit
authored
31 }
7bf4398 @pibara Added LGPL comments to the code, added comment and made a few robustn…
authored
32 //Destructor, destroy the node that we wrap.
bdf02c4 @pibara Further cleanup of the API.
authored
33 GobjectImplFsTopNode::~GobjectImplFsTopNode() throw() {
7bf4398 @pibara Added LGPL comments to the code, added comment and made a few robustn…
authored
34 delete mRoot;
94baac2 @pibara Initial commit
authored
35 }
7bf4398 @pibara Added LGPL comments to the code, added comment and made a few robustn…
authored
36 //Simple method forwarding.
26ffa58 @pibara Addressed constness issues in the API.
authored
37 jsonme::nodetype GobjectImplFsTopNode::nodetype() const {
94baac2 @pibara Initial commit
authored
38 return mRoot->nodetype();
39 }
7bf4398 @pibara Added LGPL comments to the code, added comment and made a few robustn…
authored
40 //Simple method forwarding.
26ffa58 @pibara Addressed constness issues in the API.
authored
41 Node GobjectImplFsTopNode::operator[](std::string const & name) const {
94baac2 @pibara Initial commit
authored
42 return (*mRoot)[name];
43 }
7bf4398 @pibara Added LGPL comments to the code, added comment and made a few robustn…
authored
44 //Simple method forwarding.
26ffa58 @pibara Addressed constness issues in the API.
authored
45 size_t GobjectImplFsTopNode::size() const {
94baac2 @pibara Initial commit
authored
46 return mRoot->size();
47 }
7bf4398 @pibara Added LGPL comments to the code, added comment and made a few robustn…
authored
48 //Simple method forwarding.
26ffa58 @pibara Addressed constness issues in the API.
authored
49 Node GobjectImplFsTopNode::operator[](size_t index) const {
94baac2 @pibara Initial commit
authored
50 return (*mRoot)[index];
51 }
7bf4398 @pibara Added LGPL comments to the code, added comment and made a few robustn…
authored
52 //Simple method forwarding.
26ffa58 @pibara Addressed constness issues in the API.
authored
53 GobjectImplFsTopNode::operator Scalar() const {
94baac2 @pibara Initial commit
authored
54 return (*mRoot);
55 }
7bf4398 @pibara Added LGPL comments to the code, added comment and made a few robustn…
authored
56 //Simple method forwarding.
c4fcc91 @pibara Fixed memleak and added keys functionality.
authored
57 AbstractKeys &GobjectImplFsTopNode::keys() {
58 return mRoot->keys();
59 }
94baac2 @pibara Initial commit
authored
60 }
61 }
Something went wrong with that request. Please try again.