| 1452 | return result; |
| 1453 | } |
| 1454 | void gsoner::gen_gson(void) |
| 1455 | { |
| 1456 | const char *namespace_start = "namespace acl\n{"; |
| 1457 | const char *namespace_end = "\n}///end of acl.\n"; |
| 1458 | |
| 1459 | if(files_.size() == 1) { |
| 1460 | std::string filename = get_filename_without_ext(files_.front()); |
| 1461 | gen_header_filename_ = filename + ".gson.h"; |
| 1462 | gen_source_filename_ = filename + ".gson.cpp"; |
| 1463 | } |
| 1464 | write_source("#include \"stdafx.h\"\n"); |
| 1465 | write_source(get_include_files()); |
| 1466 | write_source("#include \"" + gen_header_filename_ + "\"\n"); |
| 1467 | // write_source("#include \"acl_cpp/serialize/gson_helper.ipp\"\n"); |
| 1468 | |
| 1469 | write_header(namespace_start); |
| 1470 | write_source(namespace_start); |
| 1471 | |
| 1472 | for (std::map<std::string, object_t>::iterator itr = objs_.begin(); |
| 1473 | itr != objs_.end(); ++itr) { |
| 1474 | |
| 1475 | function_code_t pack = gen_pack_code(itr->second); |
| 1476 | function_code_t unpack = gen_unpack_code(itr->second); |
| 1477 | |
| 1478 | write_header(('\n' + tab_ + "//" + itr->second.name_)); |
| 1479 | write_header(('\n' + tab_ + pack.declare2_)); |
| 1480 | write_header(('\n' + tab_ + pack.declare_)); |
| 1481 | write_header(('\n' + tab_ + pack.declare_ptr_)); |
| 1482 | write_header('\n' + tab_ + unpack.declare_); |
| 1483 | write_header('\n' + tab_ + unpack.declare_ptr_); |
| 1484 | write_header('\n' + tab_ + unpack.declare2_+"\n"); |
| 1485 | |
| 1486 | write_source(add_4space(pack.definition_)); |
| 1487 | write_source(add_4space(pack.definition_ptr_)); |
| 1488 | write_source(add_4space(pack.definition2_)); |
| 1489 | write_source(add_4space(unpack.definition_)); |
| 1490 | write_source(add_4space(unpack.definition_ptr_)); |
| 1491 | write_source(add_4space(unpack.definition2_)); |
| 1492 | } |
| 1493 | |
| 1494 | write_header(namespace_end); |
| 1495 | write_source(namespace_end); |
| 1496 | flush(); |
| 1497 | } |
| 1498 | |
| 1499 | std::string gsoner::add_4space(const std::string &code) |
| 1500 | { |
no test coverage detected