Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 60 lines (57 sloc) 2.379 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
17
94baac2 @pibara Initial commit
authored
18 #include "json-me.hpp"
19
20 namespace jsonme {
7bf4398 @pibara Added LGPL comments to the code, added comment and made a few robustn…
authored
21 //This implements the NullObject design pattern for the AbstractScalar interface.
bdf02c4 @pibara Further cleanup of the API.
authored
22 class NullScalar: public AbstractScalar {
23 public:
24 jsonme::scalartype scalartype() const { return NULLVAL;}
25 operator long double() const { return 0;}
26 operator long long() const { return 0;}
27 operator std::string() const { return "";}
7bf4398 @pibara Added LGPL comments to the code, added comment and made a few robustn…
authored
28 operator bool() const { return false;}
bdf02c4 @pibara Further cleanup of the API.
authored
29 bool isNull() const { return true;}
30 };
7bf4398 @pibara Added LGPL comments to the code, added comment and made a few robustn…
authored
31 //The default constructor wraps a NullScalar.
977dec3 @pibara Fixed a bug in nodetype(), made things more robust by adding more tests.
authored
32 Scalar::Scalar():mScalar(new NullScalar()){}
7bf4398 @pibara Added LGPL comments to the code, added comment and made a few robustn…
authored
33 //Alternative constructor wraps a dynamically allocated implementation of the AbstractScalar interface.
94baac2 @pibara Initial commit
authored
34 Scalar::Scalar(AbstractScalar *scalar):mScalar(scalar){}
7bf4398 @pibara Added LGPL comments to the code, added comment and made a few robustn…
authored
35 //Simple method forwarding.
26ffa58 @pibara Addressed constness issues in the API.
authored
36 jsonme::scalartype Scalar::scalartype() const {
94baac2 @pibara Initial commit
authored
37 return mScalar->scalartype();
38 }
7bf4398 @pibara Added LGPL comments to the code, added comment and made a few robustn…
authored
39 //Simple forwarding of the real cast.
26ffa58 @pibara Addressed constness issues in the API.
authored
40 Scalar::operator long double() const {
94baac2 @pibara Initial commit
authored
41 return (*mScalar);
42 }
7bf4398 @pibara Added LGPL comments to the code, added comment and made a few robustn…
authored
43 //Simple forwarding of the real cast.
26ffa58 @pibara Addressed constness issues in the API.
authored
44 Scalar::operator long long() const {
94baac2 @pibara Initial commit
authored
45 return (*mScalar);
46 }
7bf4398 @pibara Added LGPL comments to the code, added comment and made a few robustn…
authored
47 //Simple forwarding of the real cast.
26ffa58 @pibara Addressed constness issues in the API.
authored
48 Scalar::operator std::string() const {
94baac2 @pibara Initial commit
authored
49 return (*mScalar);
50 }
7bf4398 @pibara Added LGPL comments to the code, added comment and made a few robustn…
authored
51 //Simple forwarding of the real cast.
26ffa58 @pibara Addressed constness issues in the API.
authored
52 Scalar::operator bool() const {
94baac2 @pibara Initial commit
authored
53 return (*mScalar);
54 }
7bf4398 @pibara Added LGPL comments to the code, added comment and made a few robustn…
authored
55 //Simple forwarding of the real cast.
26ffa58 @pibara Addressed constness issues in the API.
authored
56 bool Scalar::isNull() const {
94baac2 @pibara Initial commit
authored
57 return mScalar->isNull();
58 }
59 }
Something went wrong with that request. Please try again.