rippled
Loading...
Searching...
No Matches
JsonPropertyStream.cpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#include <xrpl/json/JsonPropertyStream.h>
21#include <xrpl/json/json_value.h>
22
23#include <string>
24
25namespace ripple {
26
32
33Json::Value const&
35{
36 return m_top;
37}
38
39void
47
48void
50{
51 // top is a map
54 m_stack.push_back(&map);
55}
56
57void
62
63void
65{
66 (*m_stack.back())[key] = v;
67}
68
69void
70JsonPropertyStream::add(std::string const& key, unsigned short v)
71{
72 (*m_stack.back())[key] = v;
73}
74
75void
77{
78 (*m_stack.back())[key] = v;
79}
80
81void
82JsonPropertyStream::add(std::string const& key, unsigned int v)
83{
84 (*m_stack.back())[key] = v;
85}
86
87void
89{
90 (*m_stack.back())[key] = int(v);
91}
92
93void
95{
96 (*m_stack.back())[key] = v;
97}
98
99void
101{
102 (*m_stack.back())[key] = v;
103}
104
105void
107{
108 (*m_stack.back())[key] = v;
109}
110
111void
113{
114 // top is array
117 m_stack.push_back(&vec);
118}
119
120void
122{
123 // top is a map
125 Json::Value& vec(top[key] = Json::arrayValue);
126 m_stack.push_back(&vec);
127}
128
129void
134
135void
137{
138 m_stack.back()->append(v);
139}
140
141void
142JsonPropertyStream::add(unsigned short v)
143{
144 m_stack.back()->append(v);
145}
146
147void
149{
150 m_stack.back()->append(v);
151}
152
153void
155{
156 m_stack.back()->append(v);
157}
158
159void
161{
162 m_stack.back()->append(int(v));
163}
164
165void
167{
168 m_stack.back()->append(v);
169}
170
171void
173{
174 m_stack.back()->append(v);
175}
176
177void
182
183} // namespace ripple
T back(T... args)
Represents a JSON value.
Definition json_value.h:149
Value & append(Value const &value)
Append value to array at the end.
Json::Value const & top() const
void add(std::string const &key, short value) override
std::vector< Json::Value * > m_stack
JSON (JavaScript Object Notation).
Definition json_errors.h:25
@ arrayValue
array value (ordered list)
Definition json_value.h:44
@ objectValue
object value (collection of name/value pairs).
Definition json_value.h:45
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
T pop_back(T... args)
T push_back(T... args)
T reserve(T... args)