190#if ADC_BOOST_JSON_PUBLIC
191 boost::json::object jo = {{
"a",
"b"},{
"C",
"d"},{
"n",1}};
194 b->add(
"bool0",
false);
196 ROUNDTRIP(
"bool0",
false, cp_bool,
bool);
198 ck = b->get_value(
"bool0"); \
200 *((
bool *)ck.
vp) !=
false || std::get<bool>(ck.
data) !=
false)
201 std::cerr <<
"bool0" <<
" not returned correctly" << std::endl;
204 b->add(
"bool1",
true);
207 b->add(
"char1",
'A');
211 ROUNDTRIP(
"c16", c16, cp_char16,
char16_t);
214 ROUNDTRIP(
"c32", c32, cp_char32,
char32_t);
216 uint8_t u8 = std::numeric_limits<uint8_t>::max() / 2;
217 uint16_t u16 = std::numeric_limits<uint16_t>::max() / 2;
218 uint32_t u32 = std::numeric_limits<uint32_t>::max() / 2;
219 uint64_t u64 = std::numeric_limits<uint64_t>::max() / 2;
223 ROUNDTRIP(
"u16", u16, cp_uint16, uint16_t);
225 ROUNDTRIP(
"u32", u32, cp_uint32, uint32_t);
227 ROUNDTRIP(
"u64", u64, cp_uint64, uint64_t);
228 int8_t i8 = std::numeric_limits<int8_t>::max() / 2;
229 int16_t i16 = std::numeric_limits<int16_t>::max() / 2;
230 int32_t i32 = std::numeric_limits<int32_t>::max() / 2;
231 int64_t i64 = std::numeric_limits<int64_t>::max() / 2;
232 float flt = std::numeric_limits<float>::max() / 2;
233 double dbl = std::numeric_limits<double>::max() / 2 ;
237 ROUNDTRIP(
"i16", i16, cp_int16, int16_t);
239 ROUNDTRIP(
"i32", i32, cp_int32, int32_t);
241 ROUNDTRIP(
"i64", i64, cp_int64, int64_t);
247 std::complex<float> fcplx(flt, flt);
248 std::complex<double> dcplx(dbl,dbl);
250 b->add(
"fcplx", fcplx);
251 ROUNDTRIP(
"fcplx", fcplx, cp_c_f32, std::complex<float>);
253 b->add(
"dcplx", dcplx);
254 ROUNDTRIP(
"dcplx", dcplx, cp_c_f64, std::complex<double>);
256 const std::string ccppstr(
"ccppstr");
257 b->add(
"ccppstr", ccppstr);
260 std::string cppstr(
"cppstr");
261 b->add(
"cppstr", cppstr);
264 const char *cstr =
"cstr_nul";
265 b->add(
"cstr1", cstr);
268 const char *jstr =
"{\"a\":\"b\", \"c\":[1,2, 3]}";
269 b->add_json_string(
"jstr1", std::string(jstr));
272 const char *ystr =
"---\na: b\nc: [1,2, 3]\nd:\n e: 1\n f: 2";
273 b->add_yaml_string(
"ystr1", ystr);
276 const char *xstr =
"<note> <to>Tove</to> <from>Jani</from> </note>";
277 b->add_xml_string(
"xstr1", std::string (xstr));
280 const char *nstr =
"1234567890123456789012345678901234567890.123";
281 b->add_number_string(
"number1", std::string (nstr));
283#if ADC_BOOST_JSON_PUBLIC
284 b->add(
"jsonobj", jo);
287 const char *cstrings[] = {
"a",
"B",
"c2"};
293 for (
int i = 0; i < 4; i++) {
294 vcstrings[i] =
new char[2];
295 snprintf(vcstrings[i], 2,
"%d", i);
301 b->add_array(
"ia", ia, 4);
302 b->add_array(
"ua", ua, 4);
303 b->add_array(
"fa", fa, 4);
304 b->add_array(
"da", da, 4);
310 b->add_array(
"nulembed",
"a\0b", 3);
313 std::string cppstrings[] = {
"ap",
"Bp",
"c2p"};
314 b->add_array(
"cstrs", cstrings, 3);
316 b->add_array(
"cppstrs", cppstrings, 3);
318 b->add_array(
"vcstrs", vcstrings, 4);
320 for (
int i = 0; i < 4; i++) {
321 delete [] vcstrings[i];
323 const char *e1=
"a1", *e2=
"a2", *e3=
"a3",* eb=
"b",* ec=
"c_";
324 std::vector<std::string> tcsv = { e1, eb, ec };
325 std::list<std::string> tcsl = { e2, eb, ec };
326 std::set<std::string> tcss = { e3, eb, ec };
327 const char * tcsv_a[] = { e1, eb, ec };
328 const char * tcsl_a[] = { e2, eb, ec };
329 const char * tcss_a[] = { e3, eb, ec };
331 b->add_array(
"sv", tcsv);
332 b->add_array(
"sl", tcsl);
333 b->add_array(
"ss", tcss);
339 std::vector<std::string> children = {
"uuid1",
"uuid2",
"uuid3"};
340 b->add_workflow_section();
341 b->add_workflow_children(children);
345 std::shared_ptr<adc::builder_api> host = f.
get_builder();
346 std::shared_ptr<adc::builder_api> arch = f.
get_builder();
347 std::shared_ptr<adc::builder_api> cpu = f.
get_builder();
348 std::shared_ptr<adc::builder_api> mem = f.
get_builder();
350 host->add(
"name",
"myhost");
351 host->add(
"cluster",
"mycluster");
352 cpu->add(
"processor",
"pentium II");
353 mem->add(
"size",
"256G");
355 arch->add_section(
"cpu", cpu);
356 arch->add_section(
"memory", mem);
357 host->add_section(
"architecture",arch);
358 b->add_section(
"host", host);
360#if ADC_BOOST_JSON_PUBLIC
362 boost::json::object host2;
363 boost::json::object arch2;
364 boost::json::object cpu2;
365 boost::json::object mem2;
367 host2[
"name"] =
"myhost";
368 host2[
"cluster"]=
"mycluster";
369 cpu2[
"processor"]=
"pentium II";
372 arch2[
"memory"]= mem2;
373 host2[
"architecture"]=arch2;
375 b->add(
"host2", host2);
383 std::string ss = b->serialize();
384 std::cout <<
"-------------------------------" << std::endl;
385 std::cout << ss << std::endl;
386 std::cout <<
"-------------------------------" << std::endl;