Skip to content

Commit 8392544

Browse files
committed
minor improvements to documentation and style
Conflicts: JSON/include/Poco/JSON/Stringifier.h JSON/src/PrintHandler.cpp JSON/src/Stringifier.cpp
1 parent 83bc36c commit 8392544

21 files changed

Lines changed: 373 additions & 307 deletions

‎JSON/include/Poco/JSON/Array.h‎

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ class Object;
3535

3636

3737
class JSON_API Array
38-
/// Represents a JSON array. JSON array provides a representation
38+
/// Represents a JSON array. Array provides a representation
3939
/// based on shared pointers and optimized for performance. It is possible to
40-
/// convert object to Poco::Dynamic::Array. Conversion requires copying and therefore
40+
/// convert Array to Poco::Dynamic::Array. Conversion requires copying and therefore
4141
/// has performance penalty; the benefit is in improved syntax, eg:
4242
///
4343
/// // use pointers to avoid copying
@@ -57,7 +57,7 @@ class JSON_API Array
5757
/// i = da[0]["test"]; // i == 0
5858
/// i = da[1]["test1"][1]; // i == 2
5959
/// i = da[1]["test2"]; // i == 4
60-
///
60+
/// ----
6161
{
6262
public:
6363
typedef std::vector<Dynamic::Var> ValueVec;
@@ -66,27 +66,27 @@ class JSON_API Array
6666
typedef SharedPtr<Array> Ptr;
6767

6868
Array();
69-
/// Default constructor
69+
/// Creates an empty Array.
7070

7171
Array(const Array& copy);
72-
/// Copy Constructor
72+
/// Creates an Array by copying another one.
7373

7474
virtual ~Array();
75-
/// Destructor
75+
/// Destroys the Array.
7676

7777
ValueVec::const_iterator begin() const;
78-
/// Returns iterator
78+
/// Returns the begin iterator for values.
7979

8080
ValueVec::const_iterator end() const;
81-
/// Returns iterator
81+
/// Returns the end iterator for values.
8282

8383
Dynamic::Var get(unsigned int index) const;
84-
/// Retrieves an element. Will return an empty value
85-
/// when the element doesn't exist.
84+
/// Retrieves the element at the given index.
85+
/// Will return an empty value when the element doesn't exist.
8686

8787
Array::Ptr getArray(unsigned int index) const;
8888
/// Retrieves an array. When the element is not
89-
/// an array or doesn't exist, an empty SharedPtr is returned.
89+
/// an Array or doesn't exist, an empty SharedPtr is returned.
9090

9191
template<typename T>
9292
T getElement(unsigned int index) const
@@ -104,30 +104,30 @@ class JSON_API Array
104104
/// Retrieves an object. When the element is not
105105
/// an object or doesn't exist, an empty SharedPtr is returned.
106106

107-
std::size_t size() const;
108-
/// Returns the size of the array
107+
std::size_t size() const;
108+
/// Returns the size of the array.
109109

110110
bool isArray(unsigned int index) const;
111-
/// Returns true when the element is an array
111+
/// Returns true when the element is an array.
112112

113113
bool isArray(const Dynamic::Var& value) const;
114-
/// Returns true when the element is an array
114+
/// Returns true when the element is an array.
115115

116116
bool isArray(ConstIterator& value) const;
117-
/// Returns true when the element is an array
117+
/// Returns true when the element is an array.
118118

119119
bool isNull(unsigned int index) const;
120120
/// Returns true when the element is null or
121121
/// when the element doesn't exist.
122122

123123
bool isObject(unsigned int index) const;
124-
/// Returns true when the element is an object
124+
/// Returns true when the element is an object.
125125

126126
bool isObject(const Dynamic::Var& value) const;
127-
/// Returns true when the element is an object
127+
/// Returns true when the element is an object.
128128

129129
bool isObject(ConstIterator& value) const;
130-
/// Returns true when the element is an object
130+
/// Returns true when the element is an object.
131131

132132
template<typename T>
133133
T optElement(unsigned int index, const T& def) const
@@ -137,13 +137,13 @@ class JSON_API Array
137137
/// value will be returned
138138
{
139139
T value = def;
140-
if ( index < _values.size() )
140+
if (index < _values.size())
141141
{
142142
try
143143
{
144144
value = _values[index].convert<T>();
145145
}
146-
catch(...)
146+
catch (...)
147147
{
148148
// Default value is returned.
149149
}
@@ -180,6 +180,9 @@ class JSON_API Array
180180
};
181181

182182

183+
//
184+
// inlines
185+
//
183186
inline Array::ValueVec::const_iterator Array::begin() const
184187
{
185188
return _values.begin();
@@ -236,7 +239,8 @@ inline void Array::remove(unsigned int index)
236239
_values.erase(_values.begin() + index);
237240
}
238241

239-
}} // Namespace Poco::JSON
242+
243+
} } // namespace Poco::JSON
240244

241245

242246
namespace Poco {
@@ -521,7 +525,7 @@ class VarHolderImpl<JSON::Array>: public VarHolder
521525
};
522526

523527

524-
}} // namespace Poco::JSON
528+
} } // namespace Poco::Dynamic
525529

526530

527531
#endif // JSON_Array_INCLUDED

‎JSON/include/Poco/JSON/Handler.h‎

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,47 +31,52 @@ namespace JSON {
3131

3232

3333
class JSON_API Handler
34+
/// Interface for handling parsing events generated by the JSON Parser.
35+
///
36+
/// An application can implement a subclass of Handler to implement
37+
/// callback-based parsing of a JSON document, similar to how a SAX
38+
/// parser would handle XML.
3439
{
3540
public:
3641
typedef SharedPtr<Handler> Ptr;
3742

3843
Handler();
39-
/// Constructor;
44+
/// Creates an empty Handler.
4045

4146
virtual ~Handler();
42-
/// Destructor
47+
/// Destroys the Handler.
4348

4449
virtual void reset() = 0;
4550
/// Resets the handler state.
4651

4752
virtual void startObject() = 0;
48-
/// The parser has read a {, meaning a new object will be read
53+
/// The parser has read a {, meaning a new object will be read.
4954

5055
virtual void endObject() = 0;
51-
/// The parser has read a }, meaning the object is read
56+
/// The parser has read a }, meaning the object is read.
5257

5358
virtual void startArray() = 0;
54-
/// The parser has read a [, meaning a new array will be read
59+
/// The parser has read a [, meaning a new array will be read.
5560

5661
virtual void endArray() = 0;
57-
/// The parser has read a ], meaning the array is read
62+
/// The parser has read a ], meaning the array is read.
5863

5964
virtual void key(const std::string& k) = 0;
60-
/// A key of an object is read
65+
/// A key of an object is read.
6166

6267
virtual void null() = 0;
63-
/// A null value is read
68+
/// A null value is read.
6469

6570
virtual void value(int v) = 0;
66-
/// An integer value is read
71+
/// An integer value is read.
6772

6873
virtual void value(unsigned v) = 0;
6974
/// An unsigned value is read. This will only be triggered if the
7075
/// value cannot fit into a signed int.
7176

7277
#if defined(POCO_HAVE_INT64)
7378
virtual void value(Int64 v) = 0;
74-
/// A 64-bit integer value is read
79+
/// A 64-bit integer value is read.
7580

7681
virtual void value(UInt64 v) = 0;
7782
/// An unsigned 64-bit integer value is read. This will only be
@@ -82,10 +87,10 @@ class JSON_API Handler
8287
/// A string value is read.
8388

8489
virtual void value(double d) = 0;
85-
/// A double value is read
90+
/// A double value is read.
8691

8792
virtual void value(bool b) = 0;
88-
/// A boolean value is read
93+
/// A boolean value is read.
8994

9095
virtual Poco::Dynamic::Var asVar() const;
9196
/// Returns the result of the parser (an object, array or string),
@@ -97,7 +102,7 @@ class JSON_API Handler
97102
};
98103

99104

100-
}} // namespace Poco::JSON
105+
} } // namespace Poco::JSON
101106

102107

103108
#endif // JSON_Handler_INCLUDED

‎JSON/include/Poco/JSON/JSONException.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace JSON {
3131
POCO_DECLARE_EXCEPTION(JSON_API, JSONException, Poco::Exception)
3232

3333

34-
}} // namespace Poco::JSON
34+
} } // namespace Poco::JSON
3535

3636

37-
#endif //JSON_JSONException_INCLUDED
37+
#endif // JSON_JSONException_INCLUDED

0 commit comments

Comments
 (0)