ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/rpc/json/iterator.C
Revision: 1.2
Committed: Tue Aug 28 17:08:12 2007 UTC (19 years, 1 month ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.1: +9 -0 lines
Log Message:
- changed name
- updated the example config to the new system
- added more documentation
- enhanced documentation generators
- added a link to the pdf to the website
- added an RSS feed generator
- transitioned hooks to c++ callbacks
- did various merges with upstream along the way
- added const where appropriate
- removed the old block allocator
- fixed most memory leaks
- transitioned some dictionaries to std::map
- transitioned some lists to std::vector
- made some free functions members where appropriate
- renamed string to dynstr and added a static string ststr
- use NOW instead of time (NULL) if possible
- completely reworked database backends, crypto handlers and protocol handlers
  to use an object factory
- removed the old module system. ermyth does not do any dynamic loading anymore
- fixed most of the build system
- reworked how protocol commands work

File Contents

# User Rev Content
1 pippijn 1.2 /*
2     * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team
3     * Rights to this code are as documented in doc/pod/gplicense.pod.
4     *
5     * JSON-RPC for Ermyth
6     *
7     * $Id: jsonrpc.C,v 1.4 2007-07-25 00:03:21 pippijn Exp $
8     */
9    
10 pippijn 1.1 //>>>>>>>>>>> iterator.C <<<<<<<<<<<//
11    
12     #include <json/value.h>
13    
14     namespace json
15     {
16     // class ValueIteratorBase
17     ValueIteratorBase::ValueIteratorBase ()
18     {
19     }
20    
21    
22     ValueIteratorBase::ValueIteratorBase (const Value::ObjectValues::iterator &current)
23     : current_ (current)
24     {
25     }
26    
27     Value &
28     ValueIteratorBase::deref () const
29     {
30     return current_->second;
31     }
32    
33    
34     void
35     ValueIteratorBase::increment ()
36     {
37     ++current_;
38     }
39    
40    
41     void
42     ValueIteratorBase::decrement ()
43     {
44     --current_;
45     }
46    
47    
48     ValueIteratorBase::difference_type
49     ValueIteratorBase::computeDistance (const SelfType &other) const
50     {
51     return difference_type (std::distance (current_, other.current_));
52     }
53    
54    
55     bool
56     ValueIteratorBase::isEqual (const SelfType &other) const
57     {
58     return current_ == other.current_;
59     }
60    
61    
62     void
63     ValueIteratorBase::copy (const SelfType &other)
64     {
65     current_ = other.current_;
66     }
67    
68    
69     Value
70     ValueIteratorBase::key () const
71     {
72     const Value::CZString czstring = (*current_).first;
73     if (czstring.c_str ())
74     {
75     if (czstring.isStaticString ())
76     return Value (StaticString (czstring.c_str ()));
77     return Value (czstring.c_str ());
78     }
79     return Value (czstring.index ());
80     }
81    
82    
83     unsigned
84     ValueIteratorBase::index () const
85     {
86     const Value::CZString czstring = (*current_).first;
87     if (!czstring.c_str ())
88     return czstring.index ();
89     return unsigned (-1);
90     }
91    
92    
93     char const *
94     ValueIteratorBase::memberName () const
95     {
96     char const *name = (*current_).first.c_str ();
97     return name ? name : "";
98     }
99    
100    
101     // class ValueConstIterator
102     ValueConstIterator::ValueConstIterator ()
103     {
104     }
105    
106    
107     ValueConstIterator::ValueConstIterator (const Value::ObjectValues::iterator &current)
108     : ValueIteratorBase (current)
109     {
110     }
111    
112     ValueConstIterator &
113     ValueConstIterator::operator = (const ValueIteratorBase &other)
114     {
115     copy (other);
116     return *this;
117     }
118    
119    
120     // class ValueIterator
121     ValueIterator::ValueIterator ()
122     {
123     }
124    
125    
126     ValueIterator::ValueIterator (const Value::ObjectValues::iterator &current)
127     : ValueIteratorBase (current)
128     {
129     }
130    
131     ValueIterator::ValueIterator (const ValueConstIterator &other)
132     : ValueIteratorBase (other)
133     {
134     }
135    
136     ValueIterator::ValueIterator (const ValueIterator &other)
137     : ValueIteratorBase (other)
138     {
139     }
140    
141     ValueIterator &
142     ValueIterator::operator = (const SelfType &other)
143     {
144     copy (other);
145     return *this;
146     }
147     }