194#if ADC_BOOST_JSON_PUBLIC
195 boost::json::object jo = {{
"a",
"b"},{
"C",
"d"},{
"n",1}};
198 b->add(
"bool0",
false);
200 ROUNDTRIP(
"bool0",
false, cp_bool,
bool);
202 ck = b->get_value(
"bool0"); \
204 *((
bool *)ck.
vp) !=
false || std::get<bool>(ck.
data) !=
false)
205 std::cerr <<
"bool0" <<
" not returned correctly" << std::endl;
208 b->add(
"bool1",
true);
211 b->add(
"char1",
'A');
215 ROUNDTRIP(
"c16", c16, cp_char16,
char16_t);
218 ROUNDTRIP(
"c32", c32, cp_char32,
char32_t);
220 uint8_t u8 = std::numeric_limits<uint8_t>::max() / 2;
221 uint16_t u16 = std::numeric_limits<uint16_t>::max() / 2;
222 uint32_t u32 = std::numeric_limits<uint32_t>::max() / 2;
223 uint64_t u64 = std::numeric_limits<uint64_t>::max() / 2;
227 ROUNDTRIP(
"u16", u16, cp_uint16, uint16_t);
229 ROUNDTRIP(
"u32", u32, cp_uint32, uint32_t);
231 ROUNDTRIP(
"u64", u64, cp_uint64, uint64_t);
232 int8_t i8 = std::numeric_limits<int8_t>::max() / 2;
233 int16_t i16 = std::numeric_limits<int16_t>::max() / 2;
234 int32_t i32 = std::numeric_limits<int32_t>::max() / 2;
235 int64_t i64 = std::numeric_limits<int64_t>::max() / 2;
236 float flt = std::numeric_limits<float>::max() / 2;
237 double dbl = std::numeric_limits<double>::max() / 2 ;
241 ROUNDTRIP(
"i16", i16, cp_int16, int16_t);
243 ROUNDTRIP(
"i32", i32, cp_int32, int32_t);
245 ROUNDTRIP(
"i64", i64, cp_int64, int64_t);
251 std::complex<float> fcplx(flt, flt);
252 std::complex<double> dcplx(dbl,dbl);
254 b->add(
"fcplx", fcplx);
255 ROUNDTRIP(
"fcplx", fcplx, cp_c_f32, std::complex<float>);
257 b->add(
"dcplx", dcplx);
258 ROUNDTRIP(
"dcplx", dcplx, cp_c_f64, std::complex<double>);
260 const std::string ccppstr(
"ccppstr");
261 b->add(
"ccppstr", ccppstr);
264 std::string cppstr(
"cppstr");
265 b->add(
"cppstr", cppstr);
268 const char *cstr =
"cstr_nul";
269 b->add(
"cstr1", cstr);
272 const char *jstr =
"{\"a\":\"b\", \"c\":[1,2, 3]}";
273 b->add_json_string(
"jstr1", std::string(jstr));
276 const char *ystr =
"---\na: b\nc: [1,2, 3]\nd:\n e: 1\n f: 2";
277 b->add_yaml_string(
"ystr1", ystr);
280 const char *xstr =
"<note> <to>Tove</to> <from>Jani</from> </note>";
281 b->add_xml_string(
"xstr1", std::string (xstr));
284 const char *nstr =
"1234567890123456789012345678901234567890.123";
285 b->add_number_string(
"number1", std::string (nstr));
287#if ADC_BOOST_JSON_PUBLIC
288 b->add(
"jsonobj", jo);
291 const char *cstrings[] = {
"a",
"B",
"c2"};
297 for (
int i = 0; i < 4; i++) {
298 vcstrings[i] =
new char[2];
299 snprintf(vcstrings[i], 2,
"%d", i);
305 b->add_array(
"ia", ia, 4);
306 b->add_array(
"ua", ua, 4);
307 b->add_array(
"fa", fa, 4);
308 b->add_array(
"da", da, 4);
314 b->add_array(
"nulembed",
"a\0b", 3);
317 std::string cppstrings[] = {
"ap",
"Bp",
"c2p"};
318 b->add_array(
"cstrs", cstrings, 3);
320 b->add_array(
"cppstrs", cppstrings, 3);
322 b->add_array(
"vcstrs", vcstrings, 4);
324 for (
int i = 0; i < 4; i++) {
325 delete [] vcstrings[i];
327 const char *e1=
"a1", *e2=
"a2", *e3=
"a3",* eb=
"b",* ec=
"c_";
328 std::vector<std::string> tcsv = { e1, eb, ec };
329 std::list<std::string> tcsl = { e2, eb, ec };
330 std::set<std::string> tcss = { e3, eb, ec };
331 const char * tcsv_a[] = { e1, eb, ec };
332 const char * tcsl_a[] = { e2, eb, ec };
333 const char * tcss_a[] = { e3, eb, ec };
335 b->add_array(
"sv", tcsv);
336 b->add_array(
"sl", tcsl);
337 b->add_array(
"ss", tcss);
343 std::vector<std::string> children = {
"uuid1",
"uuid2",
"uuid3"};
344 b->add_workflow_section();
345 b->add_workflow_children(children);
349 std::shared_ptr<adc::builder_api> host = f.
get_builder();
350 std::shared_ptr<adc::builder_api> arch = f.
get_builder();
351 std::shared_ptr<adc::builder_api> cpu = f.
get_builder();
352 std::shared_ptr<adc::builder_api> mem = f.
get_builder();
354 host->add(
"name",
"myhost");
355 host->add(
"cluster",
"mycluster");
356 cpu->add(
"processor",
"pentium II");
357 mem->add(
"size",
"256G");
359 arch->add_section(
"cpu", cpu);
360 arch->add_section(
"memory", mem);
361 host->add_section(
"architecture",arch);
362 b->add_section(
"host", host);
364#if ADC_BOOST_JSON_PUBLIC
366 boost::json::object host2;
367 boost::json::object arch2;
368 boost::json::object cpu2;
369 boost::json::object mem2;
371 host2[
"name"] =
"myhost";
372 host2[
"cluster"]=
"mycluster";
373 cpu2[
"processor"]=
"pentium II";
376 arch2[
"memory"]= mem2;
377 host2[
"architecture"]=arch2;
379 b->add(
"host2", host2);
387 std::string ss = b->serialize();
388 std::cout <<
"-------------------------------" << std::endl;
389 std::cout << ss << std::endl;
390 std::cout <<
"-------------------------------" << std::endl;