src/cx/json.h

changeset 1543
7b66371d6da3
parent 1513
4d641c6a2f82
child 1547
12da0654e4a9
equal deleted inserted replaced
1542:197450c2b0b3 1543:7b66371d6da3
293 CxJsonNumber number; 293 CxJsonNumber number;
294 /** 294 /**
295 * The literal type if the type is #CX_JSON_LITERAL. 295 * The literal type if the type is #CX_JSON_LITERAL.
296 */ 296 */
297 CxJsonLiteral literal; 297 CxJsonLiteral literal;
298 } value; 298 };
299 }; 299 };
300 300
301 /** 301 /**
302 * Internally used structure for a parsed token. 302 * Internally used structure for a parsed token.
303 * 303 *
1075 * @see cxJsonIsTrue() 1075 * @see cxJsonIsTrue()
1076 * @see cxJsonIsFalse() 1076 * @see cxJsonIsFalse()
1077 */ 1077 */
1078 cx_attr_nonnull 1078 cx_attr_nonnull
1079 CX_INLINE bool cxJsonIsBool(const CxJsonValue *value) { 1079 CX_INLINE bool cxJsonIsBool(const CxJsonValue *value) {
1080 return cxJsonIsLiteral(value) && value->value.literal != CX_JSON_NULL; 1080 return cxJsonIsLiteral(value) && value->literal != CX_JSON_NULL;
1081 } 1081 }
1082 1082
1083 /** 1083 /**
1084 * Checks if the specified value is @c true. 1084 * Checks if the specified value is @c true.
1085 * 1085 *
1092 * @see cxJsonIsBool() 1092 * @see cxJsonIsBool()
1093 * @see cxJsonIsFalse() 1093 * @see cxJsonIsFalse()
1094 */ 1094 */
1095 cx_attr_nonnull 1095 cx_attr_nonnull
1096 CX_INLINE bool cxJsonIsTrue(const CxJsonValue *value) { 1096 CX_INLINE bool cxJsonIsTrue(const CxJsonValue *value) {
1097 return cxJsonIsLiteral(value) && value->value.literal == CX_JSON_TRUE; 1097 return cxJsonIsLiteral(value) && value->literal == CX_JSON_TRUE;
1098 } 1098 }
1099 1099
1100 /** 1100 /**
1101 * Checks if the specified value is @c false. 1101 * Checks if the specified value is @c false.
1102 * 1102 *
1109 * @see cxJsonIsBool() 1109 * @see cxJsonIsBool()
1110 * @see cxJsonIsTrue() 1110 * @see cxJsonIsTrue()
1111 */ 1111 */
1112 cx_attr_nonnull 1112 cx_attr_nonnull
1113 CX_INLINE bool cxJsonIsFalse(const CxJsonValue *value) { 1113 CX_INLINE bool cxJsonIsFalse(const CxJsonValue *value) {
1114 return cxJsonIsLiteral(value) && value->value.literal == CX_JSON_FALSE; 1114 return cxJsonIsLiteral(value) && value->literal == CX_JSON_FALSE;
1115 } 1115 }
1116 1116
1117 /** 1117 /**
1118 * Checks if the specified value is @c null. 1118 * Checks if the specified value is @c null.
1119 * 1119 *
1122 * @retval false otherwise 1122 * @retval false otherwise
1123 * @see cxJsonIsLiteral() 1123 * @see cxJsonIsLiteral()
1124 */ 1124 */
1125 cx_attr_nonnull 1125 cx_attr_nonnull
1126 CX_INLINE bool cxJsonIsNull(const CxJsonValue *value) { 1126 CX_INLINE bool cxJsonIsNull(const CxJsonValue *value) {
1127 return cxJsonIsLiteral(value) && value->value.literal == CX_JSON_NULL; 1127 return cxJsonIsLiteral(value) && value->literal == CX_JSON_NULL;
1128 } 1128 }
1129 1129
1130 /** 1130 /**
1131 * Obtains a C string from the given JSON value. 1131 * Obtains a C string from the given JSON value.
1132 * 1132 *
1200 * @return the value represented as double 1200 * @return the value represented as double
1201 * @see cxJsonIsLiteral() 1201 * @see cxJsonIsLiteral()
1202 */ 1202 */
1203 cx_attr_nonnull 1203 cx_attr_nonnull
1204 CX_INLINE bool cxJsonAsBool(const CxJsonValue *value) { 1204 CX_INLINE bool cxJsonAsBool(const CxJsonValue *value) {
1205 return value->value.literal == CX_JSON_TRUE; 1205 return value->literal == CX_JSON_TRUE;
1206 } 1206 }
1207 1207
1208 /** 1208 /**
1209 * Returns the size of a JSON array. 1209 * Returns the size of a JSON array.
1210 * 1210 *
1214 * @return the size of the array 1214 * @return the size of the array
1215 * @see cxJsonIsArray() 1215 * @see cxJsonIsArray()
1216 */ 1216 */
1217 cx_attr_nonnull 1217 cx_attr_nonnull
1218 CX_INLINE size_t cxJsonArrSize(const CxJsonValue *value) { 1218 CX_INLINE size_t cxJsonArrSize(const CxJsonValue *value) {
1219 return value->value.array.array_size; 1219 return value->array.array_size;
1220 } 1220 }
1221 1221
1222 /** 1222 /**
1223 * Returns an element from a JSON array. 1223 * Returns an element from a JSON array.
1224 * 1224 *
1275 * @return the size of the object, i.e., the number of key/value pairs 1275 * @return the size of the object, i.e., the number of key/value pairs
1276 * @see cxJsonIsObject() 1276 * @see cxJsonIsObject()
1277 */ 1277 */
1278 cx_attr_nonnull 1278 cx_attr_nonnull
1279 CX_INLINE size_t cxJsonObjSize(const CxJsonValue *value) { 1279 CX_INLINE size_t cxJsonObjSize(const CxJsonValue *value) {
1280 return value->value.object.values_size; 1280 return value->object.values_size;
1281 } 1281 }
1282 1282
1283 /** 1283 /**
1284 * Returns an iterator over the JSON object members. 1284 * Returns an iterator over the JSON object members.
1285 * 1285 *

mercurial