Replace #include <stdio.h> with #include <cstdio> to solve gcc4mbed compiler problem
Fork of MbedJSONValue by
Revision 2:e39bfa3e917d, committed 2011-09-22
- Comitter:
- samux
- Date:
- Thu Sep 22 10:54:29 2011 +0000
- Parent:
- 1:effaca3e3f84
- Child:
- 3:f2ffae08b963
- Commit message:
Changed in this revision
| MbedJSONValue.cpp | Show annotated file Show diff for this revision Revisions of this file |
| MbedJSONValue.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/MbedJSONValue.cpp Thu Sep 22 10:40:57 2011 +0000
+++ b/MbedJSONValue.cpp Thu Sep 22 10:54:29 2011 +0000
@@ -80,6 +80,7 @@
case TypeNull:
return "null";
case TypeBoolean:
+ printf("boolean\r\n");
return _value.asBool ? "true" : "false";
case TypeInt: {
char buf[10];
--- a/MbedJSONValue.h Thu Sep 22 10:40:57 2011 +0000
+++ b/MbedJSONValue.h Thu Sep 22 10:54:29 2011 +0000
@@ -24,7 +24,7 @@
* THE SOFTWARE.
*
* @section DESCRIPTION
-* Types Abstraction. JSON serializer and parser. (inspired by picojson). Is used by MbedJSONRpc.
+* Types Abstraction. Minimalist JSON serializer and parser (inspired by picojson). Is used by MbedJSONRpc.
*
*/
@@ -47,17 +47,24 @@
* -a boolean identified by "my_boolean"
* - serialization in JSON format of this object
* @code
- * MbedJSONValue demo;
- * std::string s;
+ * #include "mbed.h"
+ * #include "MbedJSONValue.h"
+ * #include <string>
+ *
+ * int main() {
+ *
+ * MbedJSONValue demo;
+ * std::string s;
*
- * //fill the object
- * demo["my_array"][0] = "demo_string";
- * demo["my_array"][1] = 10;
- * demo["my_boolean"] = true;
+ * //fill the object
+ * demo["my_array"][0] = "demo_string";
+ * demo["my_array"][1] = 10;
+ * demo["my_boolean"] = false;
*
- * //serialize it into a JSON string
- * s = demo.serialize();
- *
+ * //serialize it into a JSON string
+ * s = demo.serialize();
+ * printf("json: %s\r\n", s.c_str());
+ * }
*
* @endcode
*
@@ -65,22 +72,30 @@
* - creation of an MbedJSONValue from a JSON string
* - extraction of different values from this existing MbedJSONValue
* @code
- *
- * MbedJSONValue demo;
+ * #include "mbed.h"
+ * #include "MbedJSONValue.h"
+ * #include <string>
*
- * const char * json = "{\"my_array\": [\"demo_string\", 10], \"my_boolean\": true}";
+ * int main() {
+ * MbedJSONValue demo;
*
- * //parse the previous string and fill the object demo
- * parse(demo, json);
+ * const char * json = "{\"my_array\": [\"demo_string\", 10], \"my_boolean\": true}";
+ *
+ * //parse the previous string and fill the object demo
+ * parse(demo, json);
*
- * std::string my_str;
- * int my_int;
- * bool my_bool;
+ * std::string my_str;
+ * int my_int;
+ * bool my_bool;
*
- * my_str = demo["my_array"][0].get<std::string>();
- * my_int = demo["my_array"][1].get<int>();
- * my_bool = demo["my_boolean"].get<bool>();
- *
+ * my_str = demo["my_array"][0].get<std::string>();
+ * my_int = demo["my_array"][1].get<int>();
+ * my_bool = demo["my_boolean"].get<bool>();
+ *
+ * printf("my_str: %s\r\n", my_str.c_str());
+ * printf("my_int: %d\r\n", my_int);
+ * printf("my_bool: %s\r\n", my_bool ? "true" : "false");
+ * }
* @endcode
*/
class MbedJSONValue {
@@ -111,6 +126,7 @@
* @param value the object created will be initialized with this boolean
*/
MbedJSONValue(bool value) : _type(TypeBoolean), index_array(0), index_token(0) {
+ printf("bool created\r\n");
_value.asBool = value;
}
@@ -179,6 +195,14 @@
MbedJSONValue& operator=(int const& rhs) { return operator=(MbedJSONValue(rhs)); }
/**
+ * = Operator overloading for an MbedJSONValue from a boolean
+ *
+ * @param rhs boolean
+ * @return a reference on the MbedJSONValue affected
+ */
+ MbedJSONValue& operator=(bool const& rhs) { return operator=(MbedJSONValue(rhs)); }
+
+ /**
* = Operator overloading for an MbedJSONValue from a double
*
* @param rhs double
