src/cx/json.h

changeset 988
15b3ca7ee33f
parent 985
68754c7de906
equal deleted inserted replaced
987:53e22f112b11 988:15b3ca7ee33f
181 181
182 cx_attr_nonnull 182 cx_attr_nonnull
183 cx_attr_access_r(2, 3) 183 cx_attr_access_r(2, 3)
184 int cxJsonFilln(CxJson *json, const char *buf, size_t len); 184 int cxJsonFilln(CxJson *json, const char *buf, size_t len);
185 185
186 #ifdef __cplusplus
187 } // extern "C"
188
189 cx_attr_nonnull
190 static inline int cxJsonFill(
191 CxJson *json,
192 cxstring str
193 ) {
194 return cxJsonFilln(json, str.ptr, str.length);
195 }
196
197 cx_attr_nonnull
198 static inline int cxJsonFill(
199 CxJson *json,
200 cxmutstr str
201 ) {
202 return cxJsonFilln(json, str.ptr, str.length);
203 }
204
205 cx_attr_nonnull
206 cx_attr_cstr_arg(2)
207 static inline int cxJsonFill(
208 CxJson *json,
209 const char *str
210 ) {
211 return cxJsonFilln(json, str, strlen(str));
212 }
213
214 extern "C" {
215 #else // __cplusplus
186 #define cxJsonFill(json, str) _Generic((str), \ 216 #define cxJsonFill(json, str) _Generic((str), \
187 cxstring: cx_json_fill_cxstr, \ 217 cxstring: cx_json_fill_cxstr, \
188 cxmutstr: cx_json_fill_mutstr, \ 218 cxmutstr: cx_json_fill_mutstr, \
189 char*: cx_json_fill_str, \ 219 char*: cx_json_fill_str, \
190 const char*: cx_json_fill_str) \ 220 const char*: cx_json_fill_str) \
212 CxJson *json, 242 CxJson *json,
213 const char *str 243 const char *str
214 ) { 244 ) {
215 return cxJsonFilln(json, str, strlen(str)); 245 return cxJsonFilln(json, str, strlen(str));
216 } 246 }
247 #endif
217 248
218 void cxJsonValueFree(CxJsonValue *value); 249 void cxJsonValueFree(CxJsonValue *value);
219 250
220 // TODO: if the CxJsonValue was a returned value, we could reference cxJsonValueFree() as deallocator 251 // TODO: if the CxJsonValue was a returned value, we could reference cxJsonValueFree() as deallocator
221 cx_attr_nonnull 252 cx_attr_nonnull

mercurial