42 mName = field->Attribute(
"name");
44 _log(COMMON__ERROR,
"<element> at line %d is missing the name attribute, skipping.", field->Row());
48 const TiXmlElement*
main = field->FirstChildElement();
51 "bool %s::Decode(PyRep* packet) {\n",
64 "bool %s::Decode(PyRep** packet) {\n"
65 " bool res = Decode(*packet);\n"
66 " PyDecRef(*packet);\n"
67 " *packet = nullptr;\n"
70 "bool %s::Decode(%s** packet) {\n"
71 " //quick forwarder to avoid making the user cast it if they have a properly typed object\n"
72 " return Decode((PyRep**)packet);\n"
83 const char* name = field->Attribute(
"name");
84 if (name ==
nullptr) {
85 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessElement field at line " << field->Row() <<
" is missing the name attribute, skipping.";
89 const char* v =
top();
91 " if (!%s.Decode(%s)) {\n"
92 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: unable to decode element %s\");\n"
105 const char* name = field->Attribute(
"name");
106 if (name ==
nullptr) {
107 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessElementPtr field at line " << field->Row() <<
" is missing the name attribute, skipping.";
111 const char* type = field->Attribute(
"type");
113 _log(COMMON__ERROR,
"field at line %d is missing the type attribute, skipping.", field->Row());
117 const char* v =
top();
121 " if (!%s->Decode(%s)) {\n"
122 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: unable to decode element %s\");\n"
138 const char* name = field->Attribute(
"name");
139 if (name ==
nullptr) {
140 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessRaw field at line " << field->Row() <<
" is missing the name attribute, skipping.";
144 const char* unusual = field->Attribute(
"unusual");
145 const char* v =
top();
188 " PySafeDecRef(%s);\n"
190 " PyIncRef(%s);\n\n",
203 const char* name = field->Attribute(
"name");
204 if (name ==
nullptr) {
205 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessInt field at line " << field->Row() <<
" is missing the name attribute, skipping.";
211 const char* none_marker = field->Attribute(
"none_marker");
213 const char* v =
top();
214 if (none_marker !=
nullptr)
216 " if (%s->IsNone())\n"
223 fprintf(
mOutputFile,
" %s = PyRep::IntegerValue(%s);\n", name, v);
270 const char* name = field->Attribute(
"name");
271 if (name ==
nullptr) {
272 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessLong field at line " << field->Row() <<
" is missing the name attribute, skipping.";
276 const char* v =
top();
277 fprintf(
mOutputFile,
" %s = PyRep::IntegerValue(%s);\n", name, v);
285 const char* name = field->Attribute(
"name");
286 if (name ==
nullptr) {
287 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessReal field at line " << field->Row() <<
" is missing the name attribute, skipping.";
291 const char* safe = field->Attribute(
"safe");
292 const char* none_marker = field->Attribute(
"none_marker");
294 const char* v =
top();
295 if (none_marker !=
nullptr)
297 " if (%s->IsNone())\n"
305 " if (%s->IsFloat())\n"
306 " %s = %s->AsFloat()->value();\n"
312 if (safe !=
nullptr) {
313 fprintf(
mOutputFile,
"\n %s = PyRep::IntegerValue(%s);\n", name, v);
317 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is not a Double: %%s\", %s->TypeString());\n"
330 const char* name = field->Attribute(
"name");
331 if (name ==
nullptr) {
332 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessBool field at line " << field->Row() <<
" is missing the name attribute, skipping.";
336 const char* v =
top();
337 fprintf(
mOutputFile,
" %s = PyRep::IntegerValue(%s);\n", name, v);
345 const char* v =
top();
347 " if (!%s->IsNone()) {\n"
348 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is not a None: %%s\", %s->TypeString());\n"
360 const char* name = field->Attribute(
"name");
361 if (name ==
nullptr) {
362 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessBuffer field at line " << field->Row() <<
" is missing the name attribute, skipping.";
366 const char* v =
top();
368 " PySafeDecRef(%s);\n"
369 " if (%s->IsBuffer()) {\n"
370 " %s = %s->AsBuffer();\n"
372 " } else if (%s->IsString()) {\n"
373 " %s = new PyBuffer(*%s->AsString());\n"
375 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is not a buffer: %%s\", %s->TypeString());\n"
393 const char* name = field->Attribute(
"name");
394 if (name ==
nullptr) {
395 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessString field at line " << field->Row() <<
" is missing the name attribute, skipping.";
399 const char* safe = field->Attribute(
"safe");
400 const char* none_marker = field->Attribute(
"none_marker");
401 const char* v =
top();
402 if (none_marker !=
nullptr)
404 " if (%s->IsNone())\n"
412 " if (%s->IsString())\n"
413 " %s = %s->AsString()->content();\n"
421 " if (%s->IsWString()) {\n"
422 " _log(XMLP__DECODE_WARNING, \" Safe is enabled. %s was decoded as PyWString\");\n"
423 " %s = %s->AsWString()->content();\n"
431 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is not a string: %%s\", %s->TypeString());\n"
444 const char* value = field->Attribute(
"value");
446 _log(COMMON__ERROR,
"String element at line %d has no value attribute.", field->Row());
453 const char* v =
top();
455 " if (!%s->IsString()) {\n"
456 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is not a string: %%s\", %s->TypeString());\n"
459 " PyString* %s(%s->AsString());\n"
460 " if (\"%s\" != %s->content()) {\n"
461 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: expected %s to be '%s', but it's '%%s'\", %s->content().c_str());\n"
469 mName, iname, value, iname
478 const char* name = field->Attribute(
"name");
479 if (name ==
nullptr) {
480 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessWString field at line " << field->Row() <<
" is missing the name attribute, skipping.";
484 const char* safe = field->Attribute(
"safe");
485 const char* none_marker = field->Attribute(
"none_marker");
486 const char* v =
top();
487 if (none_marker !=
nullptr)
489 " if (%s->IsNone())\n"
498 " if (%s->IsWString())\n"
499 " %s = %s->AsWString()->content();\n"
507 " if (%s->IsString()) {\n"
508 " _log(XMLP__DECODE_WARNING, \" Safe is enabled. %s was decoded as PyString\");\n"
509 " %s = %s->AsString()->content();\n"
517 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is not a string: %%s\", %s->TypeString());\n"
529 const char* value = field->Attribute(
"value");
531 _log(COMMON__ERROR,
"WString element at line %d has no value attribute.", field->Row());
538 const char* v =
top();
540 " if (!%s->IsWString()) {\n"
541 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is not a wstring: %%s\", %s->TypeString());\n"
544 " PyWString* %s(%s->AsWString());\n"
545 " if (\"%s\" != %s->content()) {\n"
546 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: expected %s to be '%s', but it's '%%s'\", %s->content().c_str());\n"
554 mName, iname, value, iname
563 const char* name = field->Attribute(
"name");
564 if (name ==
nullptr) {
565 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessToken field at line " << field->Row() <<
" is missing the name attribute, skipping.";
569 bool optional =
false;
570 const char* optional_str = field->Attribute(
"optional");
571 if (optional_str !=
nullptr)
575 " PySafeDecRef(%s);\n",
579 const char* v =
top();
582 " if (%s->IsNone())\n"
590 " if (%s->IsToken()) {\n"
591 " %s = %s->AsToken();\n"
594 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is not a token: %%s\", %s->TypeString());\n"
610 const char* value = field->Attribute(
"value");
612 _log(COMMON__ERROR,
"Token element at line %d has no value attribute.", field->Row());
619 const char* v =
top();
621 " if (!%s->IsToken()) {\n"
622 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is not a token: %%s\", %s->TypeString());\n"
625 " PyToken* %s(%s->AsToken());\n"
626 " if (%s->content() != \"%s\") {\n"
627 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: expected %s to be '%s', but it's '%%s'\", %s->content().c_str());\n"
635 mName, iname, value, iname
644 const char* name = field->Attribute(
"name");
645 if (name ==
nullptr) {
646 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessObject field at line " << field->Row() <<
" is missing the name attribute, skipping.";
650 bool optional =
false;
651 const char* optional_str = field->Attribute(
"optional");
652 if (
nullptr != optional_str)
656 " PySafeDecRef(%s);\n",
660 const char* v =
top();
663 " if (%s->IsNone())\n"
673 " if (%s->IsObject()) {\n"
674 " %s = %s->AsObject();\n"
677 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is the wrong type: %%s\", %s->TypeString());\n"
697 const char* v =
top();
699 " if (!%s->IsObject()) {\n"
700 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is the wrong type: %%s\", %s->TypeString());\n"
703 " PyObject* %s(%s->AsObject());\n\n",
710 snprintf(aname,
sizeof(aname),
"%s->arguments()", iname);
714 snprintf(tname,
sizeof(tname),
"%s->type()", iname);
726 const char* name = field->Attribute(
"name");
727 if (name ==
nullptr) {
728 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessObjectEx field at line " << field->Row() <<
" is missing the name attribute, skipping.";
731 const char* type = field->Attribute(
"type");
732 if (type ==
nullptr) {
733 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessObjectEx field at line " << field->Row() <<
" is missing the type attribute, skipping.";
737 bool optional =
false;
738 const char* optional_str = field->Attribute(
"optional");
739 if (optional_str !=
nullptr)
743 " PySafeDecRef(%s);\n",
747 const char* v =
top();
750 " if (%s->IsNone())\n"
759 " if (%s->IsObjectEx()) {\n"
760 " %s = (%s*)%s->AsObjectEx();\n"
763 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is the wrong type: %%s\", %s->TypeString());\n"
779 const char* name = field->Attribute(
"name");
780 if (name ==
nullptr) {
781 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessTuple field at line " << field->Row() <<
" is missing the name attribute, skipping.";
785 bool optional =
false;
786 const char* optional_str = field->Attribute(
"optional");
787 if (optional_str !=
nullptr)
791 " PySafeDecRef(%s);\n",
795 const char* v =
top();
798 " if (%s->IsNone())\n"
806 " if (%s->IsTuple()) {\n"
807 " %s = %s->AsTuple();\n"
810 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is not a tuple: %%s\", %s->TypeString());\n"
827 const TiXmlNode* i(
nullptr);
830 while ((i = field->IterateChildren(i))) {
831 if (i->Type() == TiXmlNode::TINYXML_ELEMENT)
838 const char* v =
top();
841 " if (!%s->IsTuple()) {\n"
842 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is the wrong type: %%s\", %s->TypeString());\n"
845 " PyTuple* %s(%s->AsTuple());\n"
846 " if (%s->size() != %u) {\n"
847 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is the wrong size: expected %d, but got %%lu\", %s->size());\n"
855 mName, iname, count, iname
862 snprintf(varname,
sizeof(varname),
"%s->GetItem(%u)", iname, count);
875 const char* name = field->Attribute(
"name");
876 if (name ==
nullptr) {
877 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessList field at line " << field->Row() <<
" is missing the name attribute, skipping.";
882 bool optional =
false;
883 const char* optional_str = field->Attribute(
"optional");
884 if (optional_str !=
nullptr)
888 " PySafeDecRef(%s);\n",
892 const char* v =
top();
895 " if (%s->IsNone())\n"
903 " if (%s->IsList()) {\n"
904 " %s = %s->AsList();\n"
907 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is not a list: %%s\", %s->TypeString());\n"
924 const TiXmlNode* i(
nullptr);
927 while ((i = field->IterateChildren(i))) {
928 if (i->Type() == TiXmlNode::TINYXML_ELEMENT)
935 const char* v =
top();
938 " if (!%s->IsList()) {\n"
939 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is not a list: %%s\", %s->TypeString());\n"
942 " PyList* %s(%s->AsList());\n"
943 " if (%s->size() != %u) {\n"
944 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is the wrong size: expected %d, but got %%lu\", %s->size());\n"
951 mName, iname, count, iname
958 snprintf(varname,
sizeof(varname),
"%s->GetItem(%u)", iname, count);
971 const char* name = field->Attribute(
"name");
972 if (name ==
nullptr) {
973 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessListInt field at line " << field->Row() <<
" is missing the name attribute, skipping.";
980 const char* v =
top();
983 " if (!%s->IsList()) {\n"
984 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is not a list: %%s\", %s->TypeString());\n"
987 " PyList* %s(%s->AsList());\n"
989 " PyList::const_iterator %s_cur = %s->begin();\n"
990 " for (size_t %s_index(0); %s_cur != %s->end(); ++%s_cur, ++%s_index) {\n"
991 " if (!(*%s_cur)->IsInt()) {\n"
992 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: Element %%u in list %s is not an integer: %%s\", %s_index, (*%s_cur)->TypeString());\n"
995 " const PyInt* t = (*%s_cur)->AsInt();\n"
996 " %s.push_back(t->value());\n"
1005 iname, iname, iname, iname, iname,
1007 mName, iname, iname, iname,
1019 const char* name = field->Attribute(
"name");
1020 if (name ==
nullptr) {
1021 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessListLong field at line " << field->Row() <<
" is missing the name attribute, skipping.";
1028 const char* v =
top();
1031 " if (!%s->IsList()) {\n"
1032 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is not a list: %%s\", %s->TypeString());\n"
1035 " PyList* %s(%s->AsList());\n"
1037 " PyList::const_iterator %s_cur = %s->begin();\n"
1038 " for (size_t %s_index(0); %s_cur != %s->end(); ++%s_cur, ++%s_index) {\n"
1039 " if ((*%s_cur)->IsLong()) {\n"
1040 " PyLong* t = (*%s_cur)->AsLong();\n"
1041 " %s.push_back(t->value());\n"
1042 " } else if ((*%s_cur)->IsInt()) {\n"
1043 " PyInt* t = (*%s_cur)->AsInt();\n"
1044 " %s.push_back(t->value());\n"
1046 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: Element %%u in list %s is not a long integer: %%s\", %s_index, (*%s_cur)->TypeString());\n"
1057 iname, iname, iname, iname, iname,
1065 mName, iname, iname, iname
1074 const char* name = field->Attribute(
"name");
1075 if (name ==
nullptr) {
1076 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessListStr field at line " << field->Row() <<
" is missing the name attribute, skipping.";
1083 const char* v =
top();
1086 " if (!%s->IsList()) {\n"
1087 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is not a list: %%s\", %s->TypeString());\n"
1090 " PyList* %s(%s->AsList());\n"
1092 " PyList::const_iterator %s_cur = %s->begin();\n"
1093 " for (uint32 %s_index(0); %s_cur != %s->end(); ++%s_cur, ++%s_index) {\n"
1094 " if (!(*%s_cur)->IsString()) {\n"
1095 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: Element %%u in list %s is not a string: %%s\", %s_index, (*%s_cur)->TypeString());\n"
1098 " const PyString* t = (*%s_cur)->AsString();\n"
1099 " %s.push_back(t->content());\n"
1108 iname, iname, iname, iname, iname,
1110 mName, iname, iname, iname,
1122 const char* name = field->Attribute(
"name");
1123 if (name ==
nullptr)
1125 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessDict field at line " << field->Row() <<
" is missing the name attribute, skipping.";
1130 bool optional =
false;
1131 const char* optional_str = field->Attribute(
"optional");
1132 if (optional_str !=
nullptr)
1136 " PySafeDecRef(%s);\n",
1140 const char* v =
top();
1143 " if (%s->IsNone())\n"
1151 " if (%s->IsDict()) {\n"
1152 " %s = %s->AsDict();\n"
1153 " //PyIncRef(%s);\n"
1155 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is not a dict: %%s\", %s->TypeString());\n"
1179 const char* soft_str = field->Attribute(
"soft");
1183 const char* v =
top();
1186 " if (!%s->IsDict()) {\n"
1187 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is the wrong type: %%s\", %s->TypeString());\n"
1190 " PyDict* %s(%s->AsDict());\n\n",
1197 const TiXmlNode* i(
nullptr);
1201 while ((i = field->IterateChildren(i))) {
1202 if (i->Type() == TiXmlNode::TINYXML_ELEMENT) {
1203 const TiXmlElement* ele = i->ToElement();
1206 if (strcmp(ele->Value(),
"dictInlineEntry") != 0) {
1207 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessDictInline non-dictInlineEntry in <dictInline> at line " << ele->Row() <<
", ignoring.";
1212 " bool %s_%u = false;\n",
1227 " // %s is empty from our perspective, not enforcing though.\n",
1233 " PyDict::const_iterator %s_cur = %s->begin();\n"
1234 " for (; %s_cur != %s->end(); ++%s_cur) {\n"
1235 " if (!%s_cur->first->IsString()) {\n"
1236 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: a key in %s is the wrong type: %%s\", %s_cur->first->TypeString());\n"
1239 " const PyString* key_string__ = %s_cur->first->AsString();\n\n",
1241 iname, iname, iname,
1243 mName, iname, iname,
1249 while ((i = field->IterateChildren(i))) {
1250 if (i->Type() == TiXmlNode::TINYXML_ELEMENT) {
1251 const TiXmlElement* ele = i->ToElement();
1254 if (strcmp(ele->Value(),
"dictInlineEntry") != 0) {
1255 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessDictInline non-dictInlineEntry in <dictInline> at line " << ele->Row() <<
", ignoring.";
1258 const char*
key = ele->Attribute(
"key");
1259 if (key ==
nullptr) {
1260 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessDictInline <dictInlineEntry> at line " << ele->Row() <<
" is missing the key attribute, skipping.";
1266 " if (key_string__->content() == \"%s\") {\n"
1276 snprintf(vname,
sizeof(vname),
"%s_cur->second", iname);
1292 " /* do nothing, soft dict */\n"
1299 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: Unknown key string '%%s' in %s\", key_string__->content().c_str());\n"
1308 while ((i = field->IterateChildren(i))) {
1309 if(i->Type() == TiXmlNode::TINYXML_ELEMENT) {
1310 const TiXmlElement* ele = i->ToElement();
1313 if (strcmp(ele->Value(),
"dictInlineEntry") != 0) {
1314 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessDictInline non-dictInlineEntry in <dictInline> at line " << ele->Row() <<
", ignoring.";
1317 const char*
key = ele->Attribute(
"key");
1318 if (key ==
nullptr) {
1319 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessDictInline <dictInlineEntry> at line " << ele->Row() <<
" is missing the key attribute, skipping.";
1325 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: Missing dict entry '%s' in %s\");\n"
1342 const char* name = field->Attribute(
"name");
1343 if (name ==
nullptr) {
1344 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessDictRaw field at line " << field->Row() <<
" is missing the name attribute, skipping.";
1348 const char*
key = field->Attribute(
"key");
1349 if (key ==
nullptr) {
1350 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessDictRaw field at line " << field->Row() <<
" is missing the key attribute, skipping.";
1353 const char* value = field->Attribute(
"value");
1354 if (value ==
nullptr) {
1355 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessDictRaw field at line " << field->Row() <<
" is missing the value attribute, skipping.";
1358 const char* pykey = field->Attribute(
"pykey");
1359 if (pykey ==
nullptr) {
1360 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessDictRaw field at line " << field->Row() <<
" is missing the pykey attribute, skipping.";
1363 const char* pyvalue = field->Attribute(
"pyvalue");
1364 if (pyvalue ==
nullptr) {
1365 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessDictRaw field at line " << field->Row() <<
" is missing the pyvalue attribute, skipping.";
1372 const char* v =
top();
1374 " if (!%s->IsDict()) {\n"
1375 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is not a dict: %%s\", %s->TypeString());\n"
1378 " PyDict* %s(%s->AsDict());\n"
1380 " PyDict::const_iterator %s_cur = %s->begin();\n"
1381 " for (size_t %s_index(0); %s_cur != %s->end(); ++%s_cur, ++%s_index) {\n"
1382 " if (!%s_cur->first->Is%s()) {\n"
1383 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: Key %%u in dict %s is not %s: %%s\", %s_index, %s_cur->first->TypeString());\n"
1386 " const Py%s* k = %s_cur->first->As%s();\n"
1387 " if (!%s_cur->second->Is%s()) {\n"
1388 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: Value %%d in dict %s is not %s: %%s\", %s_index, %s_cur->second->TypeString());\n"
1391 " const Py%s *v = %s_cur->second->As%s();\n"
1392 " %s[ k->value() ] = v->value();\n"
1401 iname, iname, iname, iname, iname,
1403 mName, iname, pykey, iname, iname,
1405 pykey, iname, pykey,
1407 mName, iname, pyvalue, iname, iname,
1409 pyvalue, iname, pyvalue,
1419 const char* name = field->Attribute(
"name");
1420 if (name ==
nullptr) {
1421 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessDictInt field at line " << field->Row() <<
" is missing the name attribute, skipping.";
1428 const char* v =
top();
1430 " if (!%s->IsDict()) {\n"
1431 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is not a dict: %%s\", %s->TypeString());\n"
1434 " PyDict* %s(%s->AsDict());\n"
1436 " PyDict::const_iterator %s_cur = %s->begin();\n"
1437 " for (size_t %s_index(0); %s_cur != %s->end(); ++%s_cur, ++%s_index) {\n"
1438 " if (!%s_cur->first->IsInt()) {\n"
1439 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: Key %%u in dict %s is not an integer: %%s\", %s_index, %s_cur->first->TypeString());\n"
1442 " const PyInt* k = %s_cur->first->AsInt();\n"
1443 " %s[ k->value() ] = %s_cur->second->Clone();\n"
1452 iname, iname, iname, iname, iname,
1454 mName, iname, iname, iname,
1465 const char* name = field->Attribute(
"name");
1466 if (name ==
nullptr) {
1467 std::cout << std::endl <<
"ClassDecodeGenerator::ProcessDictStr field at line " << field->Row() <<
" is missing the name attribute, skipping.";
1474 const char* v =
top();
1476 " if (!%s->IsDict()) {\n"
1477 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is not a dict: %%s\", %s->TypeString());\n"
1480 " PyDict* %s(%s->AsDict());\n"
1482 " PyDict::const_iterator %s_cur = %s->begin();\n"
1483 " for (size_t %s_index(0); %s_cur != %s->end(); ++%s_cur, ++%s_index) {\n"
1484 " if (!%s_cur->first->IsString()) {\n"
1485 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: Key %%u in dict %s is not a string: %%s\", %s_index, %s_cur->first->TypeString());\n"
1488 " const PyString* k = %s_cur->first->AsString();\n"
1489 " %s[ k->content() ] = %s_cur->second->Clone();\n"
1498 iname, iname, iname, iname, iname,
1500 mName, iname, iname, iname,
1515 const char* v =
top();
1517 " if (!%s->IsSubStream()) {\n"
1518 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is not a substream: %%s\", %s->TypeString());\n"
1521 " PySubStream* %s(%s->AsSubStream());\n"
1522 " //make sure its decoded\n"
1523 " %s->DecodeData();\n"
1524 " if (!%s->decoded()) {\n"
1525 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: Unable to decode %s\");\n"
1537 snprintf(ssname,
sizeof(ssname),
"%s->decoded()", iname);
1554 const char* v =
top();
1556 " if (!%s->IsSubStruct()) {\n"
1557 " _log(XMLP__DECODE_ERROR, \"Decode %s failed: %s is not a substruct: %%s\", %s->TypeString());\n"
1560 " PySubStruct* %s(%s->AsSubStruct());\n\n",
1567 snprintf(ssname,
sizeof(ssname),
"%s->sub()", iname);
bool ProcessElementDef(const TiXmlElement *field)
bool ProcessObjectEx(const TiXmlElement *field)
bool ProcessSubStreamInline(const TiXmlElement *field)
bool ProcessRaw(const TiXmlElement *field)
bool ParseElement(const TiXmlElement *element) const
Parses element using registered parsers.
#define _log(type, fmt,...)
bool ProcessDictRaw(const TiXmlElement *field)
bool ProcessListStr(const TiXmlElement *field)
bool ProcessBuffer(const TiXmlElement *field)
bool ProcessReal(const TiXmlElement *field)
void RegisterProcessors()
bool ProcessObjectInline(const TiXmlElement *field)
bool ProcessListInt(const TiXmlElement *field)
ClassDecodeGenerator(FILE *outputFile=NULL)
bool ProcessWStringInline(const TiXmlElement *field)
bool ProcessDict(const TiXmlElement *field)
bool ProcessListInline(const TiXmlElement *field)
bool ProcessLong(const TiXmlElement *field)
bool str2< bool >(const char *str)
Converts string to boolean.
bool ProcessDictInline(const TiXmlElement *field)
bool ProcessNone(const TiXmlElement *field)
bool ProcessElementPtr(const TiXmlElement *field)
bool ProcessElement(const TiXmlElement *field)
bool ProcessString(const TiXmlElement *field)
bool ProcessListLong(const TiXmlElement *field)
bool ProcessTuple(const TiXmlElement *field)
static const char * GetEncodeType(const TiXmlElement *element)
Obtains encode type of given element.
bool ProcessInt(const TiXmlElement *field)
bool ProcessBool(const TiXmlElement *field)
int main(int argc, char *argv[])
bool ProcessDictInt(const TiXmlElement *field)
bool ProcessTokenInline(const TiXmlElement *field)
Generic class for eve-xmlpktgen's generators.
bool ProcessList(const TiXmlElement *field)
bool ParseElementChildren(const TiXmlElement *element, size_t max=0) const
Parses element's children using registered parsers.
bool ProcessStringInline(const TiXmlElement *field)
bool ProcessWString(const TiXmlElement *field)
bool ProcessSubStructInline(const TiXmlElement *field)
typeID Spawn an NPC with the specified type text Search for items matching the specified query() type() key(value)-Send an OnRemoteMessage" ) COMMAND( setbpattr
bool ProcessTupleInline(const TiXmlElement *field)
bool ProcessObject(const TiXmlElement *field)
bool ProcessDictStr(const TiXmlElement *field)
bool ProcessToken(const TiXmlElement *field)