aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
Diffstat (limited to 'backends')
-rw-r--r--backends/cloud/cloudthread.cpp101
-rw-r--r--backends/cloud/cloudthread.h5
2 files changed, 42 insertions, 64 deletions
diff --git a/backends/cloud/cloudthread.cpp b/backends/cloud/cloudthread.cpp
index ac405e0fd7..e375d6fb2b 100644
--- a/backends/cloud/cloudthread.cpp
+++ b/backends/cloud/cloudthread.cpp
@@ -12,14 +12,13 @@ void cloudThread(void *thread) {
};
void CloudThread::work() {
- if(firstTime) {
- firstTime = false;
+ if (_firstTime) {
+ _firstTime = false;
example1();
example2();
example3();
- } else {
- }
+ } else { }
}
/// SimpleJSON examples:
@@ -30,7 +29,7 @@ using Common::JSONArray;
using Common::JSONObject;
// Just some sample JSON text, feel free to change but could break demo
-const char* EXAMPLE = "\
+const char *EXAMPLE = "\
{ \
\"string_name\" : \"string\tvalue and a \\\"quote\\\" and a unicode char \\u00BE and a c:\\\\path\\\\ or a \\/unix\\/path\\/ :D\", \
\"bool_name\" : true, \
@@ -46,66 +45,54 @@ const char* EXAMPLE = "\
} ";
// Example 1
-void example1()
-{
+void example1() {
// Parse example data
- JSONValue *value = JSON::Parse(EXAMPLE);
+ JSONValue *value = JSON::parse(EXAMPLE);
// Did it go wrong?
- if (value == NULL)
- {
+ if (value == NULL) {
debug("Example code failed to parse, did you change it?\r\n");
- }
- else
- {
+ } else {
// Retrieve the main object
JSONObject root;
- if (value->IsObject() == false)
- {
+ if (value->isObject() == false) {
debug("The root element is not an object, did you change the example?\r\n");
- }
- else
- {
- root = value->AsObject();
+ } else {
+ root = value->asObject();
// Retrieving a string
- if (root.find("string_name") != root.end() && root["string_name"]->IsString())
- {
+ if (root.find("string_name") != root.end() && root["string_name"]->isString()) {
debug("string_name:\r\n");
debug("------------\r\n");
- debug(root["string_name"]->AsString().c_str());
+ debug(root["string_name"]->asString().c_str());
debug("\r\n\r\n");
}
// Retrieving a boolean
- if (root.find("bool_second") != root.end() && root["bool_second"]->IsBool())
- {
+ if (root.find("bool_second") != root.end() && root["bool_second"]->isBool()) {
debug("bool_second:\r\n");
debug("------------\r\n");
- debug(root["bool_second"]->AsBool() ? "it's true!" : "it's false!");
+ debug(root["bool_second"]->asBool() ? "it's true!" : "it's false!");
debug("\r\n\r\n");
}
// Retrieving an array
- if (root.find("array_letters") != root.end() && root["array_letters"]->IsArray())
- {
- JSONArray array = root["array_letters"]->AsArray();
+ if (root.find("array_letters") != root.end() && root["array_letters"]->isArray()) {
+ JSONArray array = root["array_letters"]->asArray();
debug("array_letters:\r\n");
debug("--------------\r\n");
- for (unsigned int i = 0; i < array.size(); i++)
- {
+ for (unsigned int i = 0; i < array.size(); i++) {
//wstringstream output;
- debug("[%d] => %s\r\n", i, array[i]->Stringify().c_str());
+ debug("[%d] => %s\r\n", i, array[i]->stringify().c_str());
}
debug("\r\n");
}
// Retrieving nested object
- if (root.find("sub_object") != root.end() && root["sub_object"]->IsObject())
- {
+ if (root.find("sub_object") != root.end() && root["sub_object"]->isObject()) {
debug("sub_object:\r\n");
debug("-----------\r\n");
- debug(root["sub_object"]->Stringify().c_str());
+ debug(root["sub_object"]->stringify().c_str());
debug("\r\n\r\n");
}
}
@@ -115,10 +102,9 @@ void example1()
}
// Example 3 : compact vs. prettyprint
-void example2()
-{
- const char* EXAMPLE3 =
- "{\
+void example2() {
+ const char *EXAMPLE3 =
+ "{\
\"SelectedTab\":\"Math\",\
\"Widgets\":[\
{\"WidgetPosition\":[0,369,800,582],\"WidgetIndex\":1,\"WidgetType\":\"WidgetCheckbox.1\"},\
@@ -133,14 +119,13 @@ void example2()
}";
// Parse example data
- JSONValue *value = JSON::Parse(EXAMPLE3);
- if (value)
- {
+ JSONValue *value = JSON::parse(EXAMPLE3);
+ if (value) {
debug("-----------\r\n");
- debug(value->Stringify().c_str());
+ debug(value->stringify().c_str());
debug("\r\n");
debug("-----------\r\n");
- debug(value->Stringify(true).c_str());
+ debug(value->stringify(true).c_str());
debug("\r\n");
debug("-----------\r\n");
}
@@ -150,42 +135,34 @@ void example2()
}
// Example 4 : List keys in an object.
-void example3()
-{
+void example3() {
// Parse the example.
- JSONValue *main_object = JSON::Parse(EXAMPLE);
- if (main_object == NULL)
- {
+ JSONValue *main_object = JSON::parse(EXAMPLE);
+ if (main_object == NULL) {
debug("Example code failed to parse, did you change it?\r\n");
- }
- else if (!main_object->IsObject())
- {
+ } else if (!main_object->isObject()) {
debug("Example code is not an object, did you change it?\r\n");
delete main_object;
- }
- else
- {
+ } else {
// Print the main object.
debug("Main object:\r\n");
- debug(main_object->Stringify(true).c_str());
+ debug(main_object->stringify(true).c_str());
debug("-----------\r\n");
// Fetch the keys and print them out.
- Common::Array<Common::String> keys = main_object->ObjectKeys();
+ Common::Array<Common::String> keys = main_object->objectKeys();
Common::Array<Common::String>::iterator iter = keys.begin();
- while (iter != keys.end())
- {
+ while (iter != keys.end()) {
debug("Key: ");
debug((*iter).c_str());
debug("\r\n");
// Get the key's value.
- JSONValue *key_value = main_object->Child((*iter).c_str());
- if (key_value)
- {
+ JSONValue *key_value = main_object->child((*iter).c_str());
+ if (key_value) {
debug("Value: ");
- debug(key_value->Stringify().c_str());
+ debug(key_value->stringify().c_str());
debug("\r\n");
debug("-----------\r\n");
}
diff --git a/backends/cloud/cloudthread.h b/backends/cloud/cloudthread.h
index dcab42f6ae..ce448b7274 100644
--- a/backends/cloud/cloudthread.h
+++ b/backends/cloud/cloudthread.h
@@ -26,9 +26,10 @@
void cloudThread(void *thread); //this one is passed to TimerManager in main()
class CloudThread {
- bool firstTime;
+ bool _firstTime;
public:
- CloudThread(): firstTime(true) {};
+ CloudThread(): _firstTime(true) {};
+
void work();
};