ex

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Committer:
TMBOY
Date:
Tue Jul 18 16:54:45 2017 +0800
Revision:
47:9e361da97763
?

Who changed what in which revision?

UserRevisionLine numberNew contents of line
TMBOY 47:9e361da97763 1 // Copyright 2017 Baidu Inc. All Rights Reserved.
TMBOY 47:9e361da97763 2 // Author: Su Hao (suhao@baidu.com)
TMBOY 47:9e361da97763 3 //
TMBOY 47:9e361da97763 4 // Description: Object
TMBOY 47:9e361da97763 5
TMBOY 47:9e361da97763 6 #ifndef BAIDU_IOT_TINYDU_IOT_OS_SRC_IOT_BAIDU_CA_SCHEDULER_BAIDU_CA_OBJECT_H
TMBOY 47:9e361da97763 7 #define BAIDU_IOT_TINYDU_IOT_OS_SRC_IOT_BAIDU_CA_SCHEDULER_BAIDU_CA_OBJECT_H
TMBOY 47:9e361da97763 8
TMBOY 47:9e361da97763 9 #include <stddef.h>
TMBOY 47:9e361da97763 10
TMBOY 47:9e361da97763 11 struct baidu_json;
TMBOY 47:9e361da97763 12
TMBOY 47:9e361da97763 13 namespace duer {
TMBOY 47:9e361da97763 14
TMBOY 47:9e361da97763 15 class Object {
TMBOY 47:9e361da97763 16 public:
TMBOY 47:9e361da97763 17
TMBOY 47:9e361da97763 18 Object();
TMBOY 47:9e361da97763 19
TMBOY 47:9e361da97763 20 ~Object();
TMBOY 47:9e361da97763 21
TMBOY 47:9e361da97763 22 void reset();
TMBOY 47:9e361da97763 23
TMBOY 47:9e361da97763 24 void putInt(const char* key, int value);
TMBOY 47:9e361da97763 25
TMBOY 47:9e361da97763 26 void putDouble(const char* key, double value);
TMBOY 47:9e361da97763 27
TMBOY 47:9e361da97763 28 void putString(const char* key, const char* value);
TMBOY 47:9e361da97763 29
TMBOY 47:9e361da97763 30 // Note: the life time of value should be longer or equal this
TMBOY 47:9e361da97763 31 void putObject(const char* key, const Object& value);
TMBOY 47:9e361da97763 32
TMBOY 47:9e361da97763 33 void putIntArray(const char* key, int value[], size_t length);
TMBOY 47:9e361da97763 34
TMBOY 47:9e361da97763 35 void putDoubleArray(const char* key, double value[], size_t length);
TMBOY 47:9e361da97763 36
TMBOY 47:9e361da97763 37 void putStringArray(const char* key, const char* value[], size_t length);
TMBOY 47:9e361da97763 38
TMBOY 47:9e361da97763 39 void putObjectArray(const char* key, Object value[], size_t length);
TMBOY 47:9e361da97763 40
TMBOY 47:9e361da97763 41 // the owner of object will be transfered to this.
TMBOY 47:9e361da97763 42 // there should no other Object control the life of object
TMBOY 47:9e361da97763 43 void receiveObject(const char* key, baidu_json* object);
TMBOY 47:9e361da97763 44
TMBOY 47:9e361da97763 45 // give up the ownership of _data, and reset _data to a new one
TMBOY 47:9e361da97763 46 baidu_json* releaseObject();
TMBOY 47:9e361da97763 47
TMBOY 47:9e361da97763 48 const char* toString();
TMBOY 47:9e361da97763 49
TMBOY 47:9e361da97763 50 private:
TMBOY 47:9e361da97763 51
TMBOY 47:9e361da97763 52 Object(const Object& other);
TMBOY 47:9e361da97763 53
TMBOY 47:9e361da97763 54 Object& operator =(const Object& other);
TMBOY 47:9e361da97763 55
TMBOY 47:9e361da97763 56 baidu_json* _data;
TMBOY 47:9e361da97763 57 char* _string;
TMBOY 47:9e361da97763 58 };
TMBOY 47:9e361da97763 59
TMBOY 47:9e361da97763 60 } // namespace duer
TMBOY 47:9e361da97763 61
TMBOY 47:9e361da97763 62 #endif // BAIDU_IOT_TINYDU_IOT_OS_SRC_IOT_BAIDU_CA_SCHEDULER_BAIDU_CA_OBJECT_H