|
AppDynamics IoT C++ SDK
AppDynamics IoT C++ library contains code that facilitates capturing availability, usage, network performance and errors of an IoT Application.
|
#include <stdlib.h>#include <string>#include <inttypes.h>#include "json_serializer.hpp"#include "log.hpp"Macros | |
| #define | __STDC_FORMAT_MACROS |
| #define | INITIAL_JSON_SIZE 1024 |
| #define | START_OBJECT_CHAR '{' |
| #define | START_ARRAY_CHAR '[' |
| #define | END_OBJECT_CHAR '}' |
| #define | END_ARRAY_CHAR ']' |
| #define | JSON_DELIMITER ',' |
Functions | |
| static appd_iot_error_code_t | appd_iot_check_and_expand_json_buf_size (json_t *json, size_t len) |
| Checks and expands the size of json buf allocated. More... | |
| static appd_iot_error_code_t | appd_iot_json_start (json_t *json, char begin, const char *name) |
| starts json blob by adding the begin character. Typically it could be json object '{' or json array '['. If a name is given it will be "name":{ or "name":[ More... | |
| static appd_iot_error_code_t | appd_iot_json_end (json_t *json, char end) |
| ends json object with end character. Typically it is either '}' or ']'. More... | |
| static appd_iot_error_code_t | appd_iot_json_add_key_value (json_t *json, const char *key, const void *value, appd_iot_data_types_t type) |
| adds key:value pair to json object More... | |
| static appd_iot_error_code_t | appd_iot_json_add_value (json_t *json, const void *value, appd_iot_data_types_t type) |
| adds value to json object. This function is typically used to add string, integer, double, boolean values to JSON arrays More... | |
| json_t * | appd_iot_json_init () |
| Creates, Initializes and returns a new json struct. More... | |
| appd_iot_error_code_t | appd_iot_json_start_array (json_t *json, const char *array_name) |
| starts json array by adding char '[' to json buf. If a name is given it will be "name":[ More... | |
| appd_iot_error_code_t | appd_iot_json_start_object (json_t *json, const char *object_name) |
| starts json object by adding char '{' to json buf. If a name is given it will be "name":{ More... | |
| appd_iot_error_code_t | appd_iot_json_end_object (json_t *json) |
| ends json object by adding char '}' to json buf. More... | |
| appd_iot_error_code_t | appd_iot_json_end_array (json_t *json) |
| ends json object by adding char ']' to json buf. More... | |
| std::string | appd_iot_add_escape_char (const void *value) |
| adds escape character to the string if applicable. Unicode characters are currently not handled. More... | |
| appd_iot_error_code_t | appd_iot_convert_to_string (char *buf, size_t bufsize, const void *value, appd_iot_data_types_t type) |
| convert integer, double and boolean to string More... | |
| appd_iot_error_code_t | appd_iot_json_add_string_key_value (json_t *json, const char *key, const char *strval) |
| adds key:value pair to json object with value as string More... | |
| appd_iot_error_code_t | appd_iot_json_add_integer_key_value (json_t *json, const char *key, int64_t intval) |
| adds key:value pair to json object with value as 64 bit integer More... | |
| appd_iot_error_code_t | appd_iot_json_add_double_key_value (json_t *json, const char *key, double doubleval) |
| adds double value to json object More... | |
| appd_iot_error_code_t | appd_iot_json_add_boolean_key_value (json_t *json, const char *key, bool boolval) |
| adds key:value pair to json object with value as boolean More... | |
| appd_iot_error_code_t | appd_iot_json_add_string_value (json_t *json, const char *value) |
| adds value to json object. This function is typically used to add string values to JSON arrays More... | |
| appd_iot_error_code_t | appd_iot_json_add_integer_value (json_t *json, int64_t intval) |
| adds value to json object. This function is typically used to add integer values to JSON arrays More... | |
| appd_iot_error_code_t | appd_iot_json_add_double_value (json_t *json, double doubleval) |
| adds value to json object. This function is typically used to add double values to JSON arrays More... | |
| appd_iot_error_code_t | appd_iot_json_add_boolean_value (json_t *json, bool boolval) |
| adds value to json object. This function is typically used to add boolean values to JSON arrays More... | |
| const char * | appd_iot_json_get_string (json_t *json) |
| returns the json string constructed so far. More... | |
| const char * | appd_iot_json_pretty_print (json_t *json) |
| format and returns json string with line breaks, indentiation at start/end of objects/arrays More... | |
| void | appd_iot_json_free (json_t *json) |
| frees json structure More... | |
Variables | |
| static const char * | comma = "," |
| #define __STDC_FORMAT_MACROS |
| #define INITIAL_JSON_SIZE 1024 |
| #define START_OBJECT_CHAR '{' |
| #define START_ARRAY_CHAR '[' |
| #define END_OBJECT_CHAR '}' |
| #define END_ARRAY_CHAR ']' |
| #define JSON_DELIMITER ',' |
|
static |
Checks and expands the size of json buf allocated.
| json | struct which contains the json buf |
| len | indicates size of new bytes to be added |
|
static |
starts json blob by adding the begin character. Typically it could be json object '{' or json array '['. If a name is given it will be "name":{ or "name":[
| begin | contains the opening character |
| name | contains the key to json object or array |
| json | struct which contains the json buf |
|
static |
ends json object with end character. Typically it is either '}' or ']'.
| json | contains the json struct to which object end is added |
|
static |
adds key:value pair to json object
| json | struct which contains the json buf |
| key | to be added |
| value | to be added |
| type | indicates if the value is string, integer, double or boolean data type |
|
static |
adds value to json object. This function is typically used to add string, integer, double, boolean values to JSON arrays
| json | struct which contains the json buf |
| value | to be added |
| type | indicates if the value is string, integer, double or boolean data type |
| json_t* appd_iot_json_init | ( | void | ) |
Creates, Initializes and returns a new json struct.
| appd_iot_error_code_t appd_iot_json_start_array | ( | json_t * | json, |
| const char * | array_name | ||
| ) |
starts json array by adding char '[' to json buf. If a name is given it will be "name":[
| json | struct which contains the json buf |
| array_name | has the string for the key to json array |
| appd_iot_error_code_t appd_iot_json_start_object | ( | json_t * | json, |
| const char * | object_name | ||
| ) |
starts json object by adding char '{' to json buf. If a name is given it will be "name":{
| json | struct which contains the json buf |
| object_name | has the string for the key to json object |
| appd_iot_error_code_t appd_iot_json_end_object | ( | json_t * | json | ) |
ends json object by adding char '}' to json buf.
| json | struct which contains the json buf |
| appd_iot_error_code_t appd_iot_json_end_array | ( | json_t * | json | ) |
ends json object by adding char ']' to json buf.
| json | struct which contains the json buf |
| std::string appd_iot_add_escape_char | ( | const void * | value | ) |
adds escape character to the string if applicable. Unicode characters are currently not handled.
| value | is the string which is to be escaped. |
| appd_iot_error_code_t appd_iot_convert_to_string | ( | char * | buf, |
| size_t | bufsize, | ||
| const void * | value, | ||
| appd_iot_data_types_t | type | ||
| ) |
convert integer, double and boolean to string
| buf | to which the converted string is to be written |
| bufsize | indicates the size allocated for the string |
| value | is the data to be converted to string |
| type | indicates if the value is string, integer, double or boolean data type |
| appd_iot_error_code_t appd_iot_json_add_string_key_value | ( | json_t * | json, |
| const char * | key, | ||
| const char * | strval | ||
| ) |
adds key:value pair to json object with value as string
| json | struct which contains the json buf |
| key | contains string representing key |
| strval | contains string representing value |
| appd_iot_error_code_t appd_iot_json_add_integer_key_value | ( | json_t * | json, |
| const char * | key, | ||
| int64_t | intval | ||
| ) |
adds key:value pair to json object with value as 64 bit integer
| json | struct which contains the json buf |
| key | contains string representing key |
| intval | contains integer representing value |
| appd_iot_error_code_t appd_iot_json_add_double_key_value | ( | json_t * | json, |
| const char * | key, | ||
| double | doubleval | ||
| ) |
adds double value to json object
adds key:value pair to json object with value as double
| appd_iot_error_code_t appd_iot_json_add_boolean_key_value | ( | json_t * | json, |
| const char * | key, | ||
| bool | boolval | ||
| ) |
adds key:value pair to json object with value as boolean
| json | struct which contains the json buf |
| key | contains string representing key |
| boolval | contains boolean representing value |
| appd_iot_error_code_t appd_iot_json_add_string_value | ( | json_t * | json, |
| const char * | value | ||
| ) |
adds value to json object. This function is typically used to add string values to JSON arrays
| json | struct which contains the json buf |
| value | contains string to be added |
| appd_iot_error_code_t appd_iot_json_add_integer_value | ( | json_t * | json, |
| int64_t | intval | ||
| ) |
adds value to json object. This function is typically used to add integer values to JSON arrays
| json | struct which contains the json buf |
| intval | contains integer to be added |
| appd_iot_error_code_t appd_iot_json_add_double_value | ( | json_t * | json, |
| double | doubleval | ||
| ) |
adds value to json object. This function is typically used to add double values to JSON arrays
| json | struct which contains the json buf |
| doubleval | contains integer to be added |
| appd_iot_error_code_t appd_iot_json_add_boolean_value | ( | json_t * | json, |
| bool | boolval | ||
| ) |
adds value to json object. This function is typically used to add boolean values to JSON arrays
| json | struct which contains the json buf |
| boolval | contains boolean to be added |
| const char* appd_iot_json_get_string | ( | json_t * | json | ) |
returns the json string constructed so far.
| json | struct which contains the json buf |
| const char* appd_iot_json_pretty_print | ( | json_t * | json | ) |
format and returns json string with line breaks, indentiation at start/end of objects/arrays
| json | struct which contains the json buf |
| void appd_iot_json_free | ( | json_t * | json | ) |
frees json structure
| json | struct which contains the json buf |
|
static |