53std::string
DataMessageHeader::toJSON(std::map<uint16, std::string>* subtypes, std::map<uint16, std::string>* subcontexts, std::map<uint32, std::string>* compNames) {
55 if (!subtypes && !subcontexts && !compNames)
56 return utils::StringFormat(
"{ \"size\": %u, \"memid\": \"%llu\", \"time\": \"%llu\", \"time__desc\": \"%s\", \"sendtime\": \"%llu\", \"sendtime__desc\": \"%s\", \"recvtime\": \"%llu\", \"recvtime__desc\": \"%s\", "
57 "\"modulecputime\": %u, \"modulewalltime\": %u, \"chaincputime\": %u, \"chainwalltime\": %u, \"chaincount\": %u, "
58 "\"origin\": %u, \"destination\": %u, \"ttl\": \"%llu\", \"eol__desc\": \"%s\", \"priority\": %u, \"policy\": %u, \"from\": %u, \"to\": %u, \"type\": \"%s\", \"tag\": \"%u\", \"status\": %u, \"reference\": \"%llu\", \"serial\": \"%llu\", \"contextchange\": \"%s\", \"userdatacount\": %u, \"userdatasize\": %u }",
69 std::string typeStr, contextStr, fromStr, toStr;
70 typeStr =
type.toString(subtypes);
73 fromStr = (*compNames)[
from];
74 toStr = (*compNames)[
to];
76 if (!fromStr.length()) {
80 if (!toStr.length()) {
84 return utils::StringFormat(
"{ \"size\": %u, \"memid\": \"%llu\", \"time\": \"%llu\", \"time__desc\": \"%s\", \"sendtime\": \"%llu\", \"sendtime__desc\": \"%s\", \"recvtime\": \"%llu\", \"recvtime__desc\": \"%s\", "
85 "\"modulecputime\": %u, \"modulewalltime\": %u, \"chaincputime\": %u, \"chainwalltime\": %u, \"chaincount\": %u, "
86 "\"origin\": %u, \"destination\": %u, \"ttl\": \"%llu\", \"eol__desc\": \"%s\", \"priority\": %u, \"policy\": %u, \"from\": \"%s\", \"to\": \"%s\", \"type\": \"%s\", \"tag\": \"%u\", \"status\": %u, \"reference\": \"%llu\", \"serial\": \"%llu\", \"contextchange\": \"%s\", \"userdatacount\": %u, \"userdatasize\": %u }",
101std::string
DataMessageHeader::toXML(std::map<uint16, std::string>* subtypes, std::map<uint16, std::string>* subcontexts, std::map<uint32, std::string>* compNames) {
104 if (!subtypes && !subcontexts && !compNames)
105 return utils::StringFormat(
"<datamessage size=\"%u\" memid=\"%llu\" time=\"%llu\" timetext=\"%s\" sendtime=\"%llu\" sendtimetext=\"%s\" recvtime=\"%llu\" recvtimetext=\"%s\" "
106 "modulecputime=\"%u\" modulewalltime=\"%u\" chaincputime=\"%u\" chainwalltime=\"%u\" chaincount=\"%u\" "
107 "origin=\"%u\" destination=\"%u\" ttl=\"%llu\" eoltext=\"%s\" priority=\"%u\" policy=\"%u\" from=\"%u\" to=\"%u\" type=\"%s\" tag=\"%u\" status=\"%u\" reference=\"%llu\" serial=\"%llu\" contextchange=\"%s\" userdatacount=\"%u\" userdatasize=\"%u\" />\n",
113 origin,
destination,
ttl,
ttl ?
PrintTimeString(
time +
ttl).c_str() :
"",
priority,
policy,
from,
to,
type.toString().c_str(),
tag,
status,
reference,
serial,
contextchange.isValid() ?
contextchange.toString().c_str() :
"",
userCount,
userSize);
115 std::string typeStr, contextStr, fromStr, toStr;
116 typeStr =
type.toString(subtypes);
119 fromStr = (*compNames)[
from];
120 toStr = (*compNames)[
to];
122 if (!fromStr.length()) {
126 if (!toStr.length()) {
131 return utils::StringFormat(
"<datamessage size=\"%u\" memid=\"%llu\" time=\"%llu\" timetext=\"%s\" sendtime=\"%llu\" sendtimetext=\"%s\" recvtime=\"%llu\" recvtimetext=\"%s\" "
132 "modulecputime=\"%u\" modulewalltime=\"%u\" chaincputime=\"%u\" chainwalltime=\"%u\" chaincount=\"%u\" "
133 "origin=\"%u\" destination=\"%u\" ttl=\"%llu\" eoltext=\"%s\" priority=\"%u\" policy=\"%u\" from=\"%s\" to=\"%s\" type=\"%s\" tag=\"%u\" status=\"%u\" reference=\"%llu\" serial=\"%llu\" contextchange=\"%s\" userdatacount=\"%u\" userdatasize=\"%u\" />\n",
162 while (src < srcEnd) {
179 struct ArrayElem { int64 index;
char* entryPtr; uint32 cid; };
180 struct MapElem { std::string index;
char* entryPtr; uint32 cid; };
191 if (!
data->userCount)
194 std::map< std::string, std::list<ArrayElem> > userArrays;
195 std::map< std::string, std::list<MapElem> > userMaps;
200 const char* mapStart, *mapEnd;
201 std::string userData;
202 userData.reserve(
data->userSize +
data->userCount * 64);
204 char* srcEnd = (
char*)
data +
data->size;
205 while (src < srcEnd) {
209 if ((mapStart = strstr(key,
"_-|")) && (mapEnd = strstr(key,
"|-_"))) {
211 e.index =
utils::Ascii2Int64(std::string(mapStart + 3, mapEnd - mapStart - 3).c_str());
214 userArrays[std::string(key, mapStart - key)].push_back(e);
218 else if ((mapStart = strstr(key,
"_-[")) && (mapEnd = strstr(key,
"]-_"))) {
220 e.index = std::string(mapStart + 3, mapEnd - mapStart - 3);
223 userMaps[std::string(key, mapStart - key)].push_back(e);
258 if (userData.length()) userData +=
", ";
273 std::string subUserData;
275 std::list<ArrayElem>::iterator entryII, entryEE;
276 std::map< std::string, std::list<ArrayElem> >::iterator keyII = userArrays.begin(), keyEE = userArrays.end();
277 while (keyII != keyEE) {
279 entryII = keyII->second.begin();
280 entryEE = keyII->second.end();
281 while (entryII != entryEE) {
282 char* ep = entryII->entryPtr;
284 uint32 cid = entryII->cid;
301 if (subUserData.length()) subUserData +=
", ";
307 subUserData +=
utils::StringFormat(
"%lld : %lld (integer)\n", entryII->index, *(int64*)val);
313 subUserData +=
utils::StringFormat(
"%lld : (string of size %lld)\n", entryII->index, *(int64*)val);
316 subUserData +=
utils::StringFormat(
"%lld : (binary of size %lld)\n", entryII->index, *(int64*)val);
319 subUserData +=
utils::StringFormat(
"%lld : (message of size %lld)\n", entryII->index, *(int64*)val);
330 std::list<MapElem>::iterator entryI, entryE;
331 std::map< std::string, std::list<MapElem> >::iterator keyI = userMaps.begin(), keyE = userMaps.end();
332 while (keyI != keyE) {
334 entryI = keyI->second.begin();
335 entryE = keyI->second.end();
336 while (entryI != entryE) {
337 char* ep = entryI->entryPtr;
339 uint32 cid = entryI->cid;
346 entryI->index.c_str(),
356 if (subUserData.length()) subUserData +=
", ";
362 subUserData +=
utils::StringFormat(
"'%s' : %lld (integer)\n", entryI->index.c_str(), *(int64*)val);
365 subUserData +=
utils::StringFormat(
"'%s' : %f (float)\n", entryI->index.c_str(), *(float64*)val);
368 subUserData +=
utils::StringFormat(
"'%s' : (string of size %lld)\n", entryI->index.c_str(), *(int64*)val);
371 subUserData +=
utils::StringFormat(
"'%s' : (binary of size %lld)\n", entryI->index.c_str(), *(int64*)val);
374 subUserData +=
utils::StringFormat(
"'%s' : (message of size %lld)\n", entryI->index.c_str(), *(int64*)val);
396 if (!
data->userCount)
399 std::map< std::string, std::list<ArrayElem> > userArrays;
400 std::map< std::string, std::list<MapElem> > userMaps;
402 const char* oldData = NULL;
406 const char* mapStart, *mapEnd;
407 std::string userData;
408 userData.reserve(
data->userSize +
data->userCount * 64);
410 char* srcEnd = (
char*)
data +
data->size;
411 while (src < srcEnd) {
415 if ((mapStart = strstr(key,
"_-|")) && (mapEnd = strstr(key,
"|-_"))) {
417 e.index =
utils::Ascii2Int64(std::string(mapStart + 3, mapEnd - mapStart - 3).c_str());
420 userArrays[std::string(key, mapStart - key)].push_back(e);
424 else if ((mapStart = strstr(key,
"_-[")) && (mapEnd = strstr(key,
"]-_"))) {
426 e.index = std::string(mapStart + 3, mapEnd - mapStart - 3);
429 userMaps[std::string(key, mapStart - key)].push_back(e);
435 if (userData.length()) userData +=
", ";
442 if (userData.length()) userData +=
", ";
444 userData +=
utils::StringFormat(
"\"%s\": {\"type\": \"time\", \"value\": %llu, \"text\": \"%s\" }\n",
455 if (userData.length()) userData +=
", ";
460 if (userData.length()) userData +=
", ";
467 if (userData.length()) userData +=
", ";
481 if (userData.length()) userData +=
", ";
492 if (userData.length()) userData +=
", ";
498 if (userData.length()) userData +=
", ";
504 if (userData.length()) userData +=
", ";
521 std::string subUserData;
523 std::list<ArrayElem>::iterator entryII, entryEE;
524 std::map< std::string, std::list<ArrayElem> >::iterator keyII = userArrays.begin(), keyEE = userArrays.end();
525 while (keyII != keyEE) {
527 entryII = keyII->second.begin();
528 entryEE = keyII->second.end();
529 while (entryII != entryEE) {
530 char* ep = entryII->entryPtr;
532 uint32 cid = entryII->cid;
533 if (subUserData.length()) subUserData +=
", ";
537 subUserData +=
utils::StringFormat(
"%lld: {\"type\": \"text\", \"value\": \"%s\" }\n", entryII->index, val);
543 subUserData +=
utils::StringFormat(
"%lld: {\"type\": \"time\", \"value\": %llu, \"text\": \"%s\" }\n",
544 entryII->index, *(uint64*)val,
557 if (subUserData.length()) subUserData +=
", ";
559 subUserData +=
utils::StringFormat(
"%lld: {\"type\": \"message\", \"value\": %s }\n", entryII->index, msg->
toJSON().c_str());
567 subUserData +=
utils::StringFormat(
"%lld: {\"type\": \"integer\", \"value\": %lld }\n", entryII->index, *(int64*)val);
573 subUserData +=
utils::StringFormat(
"%lld: {\"type\": \"double\", \"value\": %f }\n", entryII->index, *(float64*)val);
579 subUserData +=
utils::StringFormat(
"%lld: {\"type\": \"textinfo\", \"size\": %lld }", entryII->index, *(int64*)val);
583 subUserData +=
utils::StringFormat(
"%lld: {\"type\": \"binary\", \"size\": %lld }", entryII->index, *(int64*)val);
587 subUserData +=
utils::StringFormat(
"%lld: {\"type\": \"messageinfo\", \"size\": %lld }", entryII->index, *(int64*)val);
594 if (userData.length()) userData +=
", ";
596 userData +=
utils::StringFormat(
"\"%s\": {\"type\": \"array\", \"value\":\n{%s} }\n", keyII->first.c_str(), subUserData.c_str());
598 userData +=
utils::StringFormat(
"\"%s\": {%s}\n", keyII->first.c_str(), subUserData.c_str());
603 std::list<MapElem>::iterator entryI, entryE;
604 std::map< std::string, std::list<MapElem> >::iterator keyI = userMaps.begin(), keyE = userMaps.end();
605 while (keyI != keyE) {
607 entryI = keyI->second.begin();
608 entryE = keyI->second.end();
609 while (entryI != entryE) {
610 char* ep = entryI->entryPtr;
612 uint32 cid = entryI->cid;
613 if (subUserData.length()) subUserData +=
", ";
617 subUserData +=
utils::StringFormat(
"\"%s\": {\"type\": \"text\", \"value\": \"%s\" }\n", entryI->index.c_str(), val);
623 subUserData +=
utils::StringFormat(
"\"%s\": {\"type\": \"time\", \"value\": %llu, \"text\": \"%s\" }\n",
624 entryI->index.c_str(), *(uint64*)val,
637 if (subUserData.length()) subUserData +=
", ";
639 subUserData +=
utils::StringFormat(
"\"%s\": {\"type\": \"message\", \"value\": %s }\n", entryI->index.c_str(), msg->
toJSON().c_str());
647 subUserData +=
utils::StringFormat(
"\"%s\": {\"type\": \"integer\", \"value\": %lld }\n", entryI->index.c_str(), *(int64*)val);
649 subUserData +=
utils::StringFormat(
"\"%s\": \"%lld\"\n", entryI->index.c_str(), *(int64*)val);
653 subUserData +=
utils::StringFormat(
"\"%s\": {\"type\": \"double\", \"value\": %f }\n", entryI->index.c_str(), *(float64*)val);
655 subUserData +=
utils::StringFormat(
"\"%s\": \"%f\" }\n", entryI->index.c_str(), *(float64*)val);
659 subUserData +=
utils::StringFormat(
"\"%s\": {\"type\": \"textinfo\", \"size\": %lld }", entryI->index.c_str(), *(int64*)val);
663 subUserData +=
utils::StringFormat(
"\"%s\": {\"type\": \"binary\", \"size\": %lld }", entryI->index.c_str(), *(int64*)val);
667 subUserData +=
utils::StringFormat(
"\"%s\": {\"type\": \"messageinfo\", \"size\": %lld }", entryI->index.c_str(), *(int64*)val);
674 if (userData.length()) userData +=
", ";
676 userData +=
utils::StringFormat(
"\"%s\": {\"type\": \"map\", \"value\":\n{%s} }\n", keyI->first.c_str(), subUserData.c_str());
678 userData +=
utils::StringFormat(
"\"%s\": {%s}\n", keyI->first.c_str(), subUserData.c_str());
686std::string
DataMessage::toJSON(std::map<uint16, std::string>* subtypes, std::map<uint16, std::string>* subcontexts, std::map<uint32, std::string>* compNames) {
689 if (!
data->userCount)
690 return data->toJSON(subtypes, subcontexts, compNames);
694 std::map< std::string, std::list<std::string> > userMaps;
695 std::map< std::string, std::list<int64> > userArrays;
697 uint32 draftSize = 0;
698 uint32 draftUserSize = 0;
699 uint32 draftUserCount = 0;
703 char* srcEnd = (
char*)
data +
data->size;
704 while (src < srcEnd) {
710 if (strcmp(key,
"OS") == 0)
712 else if (strcmp(key,
"US") == 0)
714 else if (strcmp(key,
"UC") == 0)
724 return utils::StringFormat(
"{ \"draft\":\"yes\", \"size\": %u, \"memid\": \"%llu\", \"time\": \"%llu\", \"time__text\": \"%s\", \"sendtime\": \"%llu\", \"sendtime__text\": \"%s\", \"recvtime\": \"%llu\", \"recvtime__text\": \"%s\", \"origin\": %u, \"destination\": %u, \"ttl\": \"%llu\", \"eol__text\": \"%s\", \"priority\": %u, \"policy\": %u, \"from\": %u, \"to\": %u, \"type\": \"%s\", \"tag\": \"%u\", \"status\": %u, \"reference\": \"%llu\", \"serial\": \"%llu\", \"contextchange\": \"%s\", \"userdatacount\": %u, \"userdatasize\": %u, \"userdata\":\n%s }\n",
725 draftSize,
data->memid,
731 data->contextchange.isValid() ?
data->contextchange.toString().c_str() :
"",
732 draftUserCount, draftUserSize, userData.c_str());
735 return utils::StringFormat(
"{ \"size\": %u, \"memid\": \"%llu\", \"time\": \"%llu\", \"time__text\": \"%s\", \"sendtime\": \"%llu\", \"sendtime__text\": \"%s\", \"recvtime\": \"%llu\", \"recvtime__text\": \"%s\", \"origin\": %u, \"destination\": %u, \"ttl\": \"%llu\", \"eol__text\": \"%s\", \"priority\": %u, \"policy\": %u, \"from\": %u, \"to\": %u, \"type\": \"%s\", \"tag\": \"%u\", \"status\": %u, \"reference\": \"%llu\", \"serial\": \"%llu\", \"contextchange\": \"%s\", \"userdatacount\": %u, \"userdatasize\": %u, \"userdata\":\n%s }\n",
742 data->contextchange.isValid() ?
data->contextchange.toString().c_str() :
"",
743 data->userCount,
data->userSize, userData.c_str());
747std::string
DataMessage::toCSV(
const char* separator,
const char* preample, std::map<uint16, std::string>* subtypes, std::map<uint16, std::string>* subcontexts, std::map<uint32, std::string>* compNames) {
752 if (separator && (len = (uint32)strlen(separator)))
753 memcpy(sep, separator, len+1);
757 std::string userData;
758 if (
data->userCount) {
764 std::string typeStr, contextStr, fromStr, toStr;
765 typeStr =
data->type.toString(subtypes);
766 contextStr =
data->contextchange.toString(subcontexts);
768 fromStr = (*compNames)[
data->from];
769 toStr = (*compNames)[
data->to];
771 if (!fromStr.length()) {
775 if (!toStr.length()) {
780 if (preample && strlen(preample)) {
781 return utils::StringFormat(
"%s%s%s%s%s%s%s%s%s%s%u%s%u%s%u%s%u%s%u%s%u%s%u%s%llu%s%s%s%s%s%u%s%llu%s%s%s%u%s%u%s%s\n",
783 typeStr.c_str(), sep,
787 data->cyclecputime, sep,
788 data->cyclewalltime, sep,
789 data->chaincputime, sep,
790 data->chainwalltime, sep,
791 data->chaincount, sep,
795 fromStr.c_str(), sep,
799 contextStr.c_str(), sep,
800 data->userCount, sep,
805 return utils::StringFormat(
"%s%s%s%s%s%s%s%s%u%s%u%s%u%s%u%s%u%s%u%s%u%s%llu%s%s%s%s%s%u%s%llu%s%s%s%u%s%u%s%s\n",
806 typeStr.c_str(), sep,
810 data->cyclecputime, sep,
811 data->cyclewalltime, sep,
812 data->chaincputime, sep,
813 data->chainwalltime, sep,
814 data->chaincount, sep,
818 fromStr.c_str(), sep,
822 contextStr.c_str(), sep,
823 data->userCount, sep,
834 if (separator && (len = (uint32)strlen(separator)))
835 memcpy(sep, separator, len + 1);
840 if (preample && strlen(preample))
841 header =
utils::StringFormat(
"%s,type,created,sent,received,modulecputime,modulewalltime,chaincputime,chainwalltime,chaincount,size,priority,ttl,from,to,tag,serial,contextchange,userdatacount,userdatasize,userdata\n", preample);
843 header =
"type,created,sent,received,modulecputime,modulewalltime,chaincputime,chainwalltime,chaincount,size,priority,ttl,from,to,tag,serial,contextchange,userdatacount,userdatasize,userdata\n";
852std::string
DataMessage::toXML(std::map<uint16, std::string>* subtypes, std::map<uint16, std::string>* subcontexts, std::map<uint32, std::string>* compNames) {
855 if (!
data->userCount)
856 return data->toXML(subtypes, subcontexts, compNames);
858 std::map< std::string, std::list<ArrayElem> > userArrays;
859 std::map< std::string, std::list<MapElem> > userMaps;
860 uint32 draftSize = 0;
861 uint32 draftUserSize = 0;
862 uint32 draftUserCount = 0;
864 const char* oldData = NULL;
867 const char* mapStart, *mapEnd;
868 std::string userData;
869 userData.reserve(
data->userSize +
data->userCount * 64);
871 char* srcEnd = (
char*)
data +
data->size;
872 while (src < srcEnd) {
876 if ((mapStart = strstr(key,
"_-|")) && (mapEnd = strstr(key,
"|-_"))) {
878 e.index =
utils::Ascii2Int64(std::string(mapStart + 3, mapEnd - mapStart - 3).c_str());
881 userArrays[std::string(key, mapStart - key)].push_back(e);
885 else if ((mapStart = strstr(key,
"_-[")) && (mapEnd = strstr(key,
"]-_"))) {
887 e.index = std::string(mapStart + 3, mapEnd - mapStart - 3);
890 userMaps[std::string(key, mapStart - key)].push_back(e);
899 userData +=
utils::StringFormat(
"<data name=\"%s\" type=\"time\" value=\"%llu\" text=\"%s\" />\n",
937 if (strcmp(key,
"OS") == 0)
939 else if (strcmp(key,
"US") == 0)
941 else if (strcmp(key,
"UC") == 0)
955 std::string subUserData;
957 std::list<ArrayElem>::iterator entryII, entryEE;
958 std::map< std::string, std::list<ArrayElem> >::iterator keyII = userArrays.begin(), keyEE = userArrays.end();
959 while (keyII != keyEE) {
961 entryII = keyII->second.begin();
962 entryEE = keyII->second.end();
963 while (entryII != entryEE) {
964 char* ep = entryII->entryPtr;
966 uint32 cid = entryII->cid;
969 subUserData +=
utils::StringFormat(
"<data name=\"%lld\" type=\"text\" value=\"%s\" />\n", entryII->index, val);
972 subUserData +=
utils::StringFormat(
"<data name=\"%lld\" type=\"time\" value=\"%llu\" text=\"%s\" />\n",
973 entryII->index, *(uint64*)val,
981 subUserData +=
utils::StringFormat(
"<data name=\"%lld\" type=\"integer\" value=\"%lld\" />\n", entryII->index, *(int64*)val);
984 subUserData +=
utils::StringFormat(
"<data name=\"%lld\" type=\"float\" value=\"%f\" />\n", entryII->index, *(float64*)val);
989 subUserData +=
utils::StringFormat(
"<data name=\"%lld\" type=\"datamessage\">\n%s</data>", entryII->index, msg->
toXML().c_str());
994 subUserData +=
utils::StringFormat(
"<data name=\"%lld\" type=\"textinfo\" size=\"%lld\" />\n", entryII->index, *(int64*)val);
997 subUserData +=
utils::StringFormat(
"<data name=\"%lld\" type=\"binary\" size=\"%lld\" />\n", entryII->index, *(int64*)val);
1000 subUserData +=
utils::StringFormat(
"<data name=\"%lld\" type=\"messageinfo\" size=\"%lld\" />\n", entryII->index, *(int64*)val);
1007 userData +=
utils::StringFormat(
"<array name=\"%s\">\n%s</array>\n", keyII->first.c_str(), subUserData.c_str());
1011 std::list<MapElem>::iterator entryI, entryE;
1012 std::map< std::string, std::list<MapElem> >::iterator keyI = userMaps.begin(), keyE = userMaps.end();
1013 while (keyI != keyE) {
1014 subUserData.clear();
1015 entryI = keyI->second.begin();
1016 entryE = keyI->second.end();
1017 while (entryI != entryE) {
1018 char* ep = entryI->entryPtr;
1020 uint32 cid = entryI->cid;
1023 subUserData +=
utils::StringFormat(
"<data name=\"%s\" type=\"text\" value=\"%s\" />\n", entryI->index.c_str(), val);
1026 subUserData +=
utils::StringFormat(
"<data name=\"%s\" type=\"time\" value=\"%llu\" text=\"%s\" />\n",
1027 entryI->index.c_str(), *(uint64*)val,
1035 subUserData +=
utils::StringFormat(
"<data name=\"%s\" type=\"integer\" value=\"%lld\" />\n", entryI->index.c_str(), *(int64*)val);
1038 subUserData +=
utils::StringFormat(
"<data name=\"%s\" type=\"float\" value=\"%f\" />\n", entryI->index.c_str(), *(float64*)val);
1043 subUserData +=
utils::StringFormat(
"<data name=\"%s\" type=\"datamessage\">\n%s</data>", entryI->index.c_str(), msg->
toXML().c_str());
1048 subUserData +=
utils::StringFormat(
"<data name=\"%s\" type=\"textinfo\" size=\"%lld\" />\n", entryI->index.c_str(), *(int64*)val);
1051 subUserData +=
utils::StringFormat(
"<data name=\"%s\" type=\"binary\" size=\"%lld\" />\n", entryI->index.c_str(), *(int64*)val);
1054 subUserData +=
utils::StringFormat(
"<data name=\"%s\" type=\"messageinfo\" size=\"%lld\" />\n", entryI->index.c_str(), *(int64*)val);
1061 userData +=
utils::StringFormat(
"<map name=\"%s\">\n%s</map>\n", keyI->first.c_str(), subUserData.c_str());
1066 return utils::StringFormat(
"<datamessage draft=\"yes\" size=\"%u\" memid=\"%llu\" time=\"%llu\" timetext=\"%s\" sendtime=\"%llu\" sendtimetext=\"%s\" recvtime=\"%llu\" recvtimetext=\"%s\" origin=\"%u\" destination=\"%u\" ttl=\"%llu\" eoltext=\"%s\" priority=\"%u\" policy=\"%u\" from=\"%u\" to=\"%u\" type=\"%s\" tag=\"%u\" status=\"%u\" reference=\"%llu\" serial=\"%llu\" contextchange=\"%s\" userdatacount=\"%u\" userdatasize=\"%u\">\n%s</datamessage>\n",
1067 draftSize,
data->memid,
1072 data->priority,
data->policy,
data->from,
data->to,
data->type.toString().c_str(),
data->tag,
data->status,
data->reference,
data->serial,
data->contextchange.isValid() ?
data->contextchange.toString().c_str() :
"", draftUserCount, draftUserSize, userData.c_str());
1075 return utils::StringFormat(
"<datamessage size=\"%u\" memid=\"%llu\" time=\"%llu\" timetext=\"%s\" sendtime=\"%llu\" sendtimetext=\"%s\" recvtime=\"%llu\" recvtimetext=\"%s\" origin=\"%u\" destination=\"%u\" ttl=\"%llu\" eoltext=\"%s\" priority=\"%u\" policy=\"%u\" from=\"%u\" to=\"%u\" type=\"%s\" tag=\"%u\" status=\"%u\" reference=\"%llu\" serial=\"%llu\" contextchange=\"%s\" userdatacount=\"%u\" userdatasize=\"%u\">\n%s</datamessage>\n",
1081 data->priority,
data->policy,
data->from,
data->to,
data->type.toString().c_str(),
data->tag,
data->status,
data->reference,
data->serial,
data->contextchange.isValid() ?
data->contextchange.toString().c_str() :
"",
data->userCount,
data->userSize, userData.c_str());
1130 data->priority = priority;
1147 data->priority = priority;
1164 char* newData = NULL;
1186 uint32 size = *(uint32*)
data;
1188 memcpy(this->data,
data, size);
1219 char* newData = NULL;
1236 uint32 size = *(uint32*)
data;
1238 memcpy(this->data,
data, size);
1289 const char* newData = (
const char*)correctMsg->
data;
1290 uint32 size = *(uint32*)newData;
1291 if (size <= maxDraftSize) {
1293 memcpy(this->data, newData, size);
1314 uint32 size = *(uint32*)
data;
1315 if (size <= maxDraftSize) {
1317 memcpy(this->data,
data, size);
1338 uint32 size = *(uint32*)msg.
data;
1339 if (size <= maxDraftSize) {
1341 memcpy(this->
data, msg.
data, size);
1367 if (!
data->userCount)
1372 if (this->data->
size + (3 * draftInfoSize) > maxDraftSize)
1383 size =
data->userSize;
1385 size =
data->userCount;
1388 std::map< std::string, std::list<std::string> > userMaps;
1391 std::string userData;
1395 char* srcEnd = (
char*)
data +
data->size;
1396 while (src < srcEnd) {
1404 if (this->data->
size + itemSize < maxDraftSize) {
1414 if (this->data->
size + itemSize < maxDraftSize) {
1424 if (this->data->
size + itemSize < maxDraftSize) {
1435 if (this->data->
size + itemSize < maxDraftSize) {
1440 this->data->
userSize += itemSize -
sizeof(int64) + (uint32)size;
1446 if (this->data->
size + itemSize < maxDraftSize) {
1451 this->data->
userSize += itemSize -
sizeof(int64) + (uint32)size;
1458 if (this->data->
size + itemSize < maxDraftSize) {
1463 this->data->
userSize += itemSize -
sizeof(int64) + (uint32)size;
1469 if (this->data->
size + itemSize < maxDraftSize) {
1474 this->data->
userSize += itemSize -
sizeof(int64) + (uint32)size;
1480 if (this->data->
size + itemSize < maxDraftSize) {
1485 this->data->
userSize += itemSize -
sizeof(int64) + (uint32)size;
1500 while (src < srcEnd) {
1509 if (this->data->
size + itemSize + size < maxDraftSize) {
1513 else if (this->data->
size + itemSize +
sizeof(int64) < maxDraftSize) {
1518 this->data->
userSize += itemSize + (uint32)size;
1553 const char* oldData = (
const char*)this->data;
1611 return (*(uint64*)src != 0);
1615 return (*(int64*)src != 0);
1617 return (((int64)(*(float64*)src)) != 0);
1634 if (
stricmp(key,
"size") == 0)
1636 else if (
stricmp(key,
"cid") == 0)
1638 else if (
stricmp(key,
"memid") == 0)
1640 else if (
stricmp(key,
"time") == 0)
1642 else if (
stricmp(key,
"sendtime") == 0)
1644 else if (
stricmp(key,
"recvtime") == 0)
1646 else if (
stricmp(key,
"timetext") == 0)
1648 else if (
stricmp(key,
"sendtimetext") == 0)
1650 else if (
stricmp(key,
"recvtimetext") == 0)
1652 else if (
stricmp(key,
"origin") == 0)
1654 else if (
stricmp(key,
"destination") == 0)
1656 else if (
stricmp(key,
"ttl") == 0)
1658 else if (
stricmp(key,
"eol") == 0)
1660 else if (
stricmp(key,
"eoltext") == 0)
1662 else if (
stricmp(key,
"priority") == 0)
1664 else if (
stricmp(key,
"policy") == 0)
1666 else if (
stricmp(key,
"from") == 0)
1668 else if (
stricmp(key,
"to") == 0)
1670 else if (
stricmp(key,
"type") == 0)
1671 return data->type.toString();
1672 else if (
stricmp(key,
"tag") == 0)
1674 else if (
stricmp(key,
"status") == 0)
1676 else if (
stricmp(key,
"reference") == 0)
1678 else if (
stricmp(key,
"serial") == 0)
1680 else if (
stricmp(key,
"contextchange") == 0)
1681 return data->contextchange.isValid() ?
data->contextchange.toString() :
"";
1682 else if (
stricmp(key,
"userSize") == 0)
1684 else if (
stricmp(key,
"userCount") == 0)
1715 bool success =
false;
1720 bool success =
false;
1725 bool success =
false;
1730 bool success =
false;
1731 value =
getInt(key, success);
1736 bool success =
false;
1742 bool success =
false;
1748 bool success =
false;
1749 return getData(key, size, success);
1753 bool success =
false;
1758 bool success =
false;
1800 if (src == NULL)
return 0;
1806 if (src == NULL)
return 0;
1814 if (src == NULL)
return 0;
1827 if (src == NULL)
return 0;
1837 bool success =
false;
1838 return getInt(key, success);
1844 if (src == NULL)
return false;
1856 if (src == NULL)
return false;
1866 bool success =
false;
1871 bool success =
false;
1878 if (src == NULL)
return NULL;
1892 if (src == NULL)
return NULL;
1897 char*
data =
new char[size];
1908 if (src == NULL)
return NULL;
1944 float64 val = value;
1990 data->size = oldSize + fullSpaceReq;
1993 src = (
char*)
data + oldSize;
2005 data->userSize += fullSpaceReq;
2023 char* srcEnd = (
char*)
data +
data->size;
2024 while (src < srcEnd) {
2041 char* srcEnd = (
char*)
data +
data->size;
2042 while (src < srcEnd) {
2060 char* srcEnd = (
char*)
data +
data->size;
2061 while (src < srcEnd) {
2074 delete[] arrayKeyStart;
2075 delete[] mapKeyStart;
2088 if (src == NULL)
return 0;
2094 if (src == NULL)
return 0;
2100 if (src == NULL)
return 0;
2106 if (src == NULL)
return 0;
2112 if (src == NULL)
return 0;
2118 if (src == NULL)
return 0;
2129 int n = snprintf(buf,
sizeof(buf),
"%s_-|%lld|-_", key, i);
2130 if (n < 0 || (
size_t)n >=
sizeof(buf))
2181 return getInt(i, key, success);
2196 return getInt(idx, key, success);
2206 return getFloat(idx, key, success);
2255 int n = snprintf(buf,
sizeof(buf),
"%s_-[%s]-_", key, idx);
2256 if (n < 0 || (
size_t)n >=
sizeof(buf))
2354 std::map<int64, uint64> map;
2361 char* srcEnd = (
char*)
data +
data->size;
2362 while (src < srcEnd) {
2380 std::map<int64, int64> map;
2387 char* srcEnd = (
char*)
data +
data->size;
2388 while (src < srcEnd) {
2427 std::map<int64, float64> map;
2434 char* srcEnd = (
char*)
data +
data->size;
2435 while (src < srcEnd) {
2474 std::map<int64, std::string> map;
2481 char* srcEnd = (
char*)
data +
data->size;
2482 while (src < srcEnd) {
2521 std::map<int64, std::string> map;
2528 char* srcEnd = (
char*)
data +
data->size;
2529 while (src < srcEnd) {
2548 std::map<int64, int64> map;
2555 char* srcEnd = (
char*)
data +
data->size;
2556 while (src < srcEnd) {
2574 std::map<int64, double> map;
2581 char* srcEnd = (
char*)
data +
data->size;
2582 while (src < srcEnd) {
2600 std::map<int64, float64> map;
2607 char* srcEnd = (
char*)
data +
data->size;
2608 while (src < srcEnd) {
2626 std::map<int64, DataMessage*> map;
2633 char* srcEnd = (
char*)
data +
data->size;
2634 while (src < srcEnd) {
2652 std::map<int64, uint64>::iterator i = map.begin(), e = map.end();
2654 if (!
setTime(i->first, key, i->second))
2662 std::map<int64, std::string>::iterator i = map.begin(), e = map.end();
2664 if (!
setString(i->first, key, i->second.c_str()))
2672 std::map<int64, int64>::iterator i = map.begin(), e = map.end();
2674 if (!
setInt(i->first, key, i->second))
2682 std::map<int64, double>::iterator i = map.begin(), e = map.end();
2684 if (!
setDouble(i->first, key, i->second))
2692 std::map<int64, float64>::iterator i = map.begin(), e = map.end();
2694 if (!
setFloat(i->first, key, i->second))
2702 std::map<int64, DataMessage*>::iterator i = map.begin(), e = map.end();
2725 char* srcEnd = (
char*)
data +
data->size;
2726 while (src < srcEnd) {
2751 char* srcEnd = (
char*)
data +
data->size;
2752 while (src < srcEnd) {
2777 std::map<std::string, uint64> map;
2784 char* srcEnd = (
char*)
data +
data->size;
2785 while (src < srcEnd) {
2802 std::map<std::string, int64> map;
2809 char* srcEnd = (
char*)
data +
data->size;
2810 while (src < srcEnd) {
2846 std::map<std::string, float64> map;
2853 char* srcEnd = (
char*)
data +
data->size;
2854 while (src < srcEnd) {
2890 std::map<std::string, std::string> map;
2897 char* srcEnd = (
char*)
data +
data->size;
2898 while (src < srcEnd) {
2934 std::map<std::string, std::string> map;
2941 char* srcEnd = (
char*)
data +
data->size;
2942 while (src < srcEnd) {
2959 std::map<std::string, int64> map;
2966 char* srcEnd = (
char*)
data +
data->size;
2967 while (src < srcEnd) {
2984 std::map<std::string, double> map;
2991 char* srcEnd = (
char*)
data +
data->size;
2992 while (src < srcEnd) {
3009 std::map<std::string, float64> map;
3016 char* srcEnd = (
char*)
data +
data->size;
3017 while (src < srcEnd) {
3034 std::map<std::string, DataMessage*> map;
3041 char* srcEnd = (
char*)
data +
data->size;
3042 while (src < srcEnd) {
3059 std::map<std::string, uint64>::iterator i = map.begin(), e = map.end();
3061 if (!
setTime(i->first.c_str(), key, i->second))
3069 std::map<std::string, std::string>::iterator i = map.begin(), e = map.end();
3071 if (!
setString(i->first.c_str(), key, i->second.c_str()))
3079 std::map<std::string, int64>::iterator i = map.begin(), e = map.end();
3081 if (!
setInt(i->first.c_str(), key, i->second))
3089 std::map<std::string, double>::iterator i = map.begin(), e = map.end();
3091 if (!
setDouble(i->first.c_str(), key, i->second))
3099 std::map<std::string, float64>::iterator i = map.begin(), e = map.end();
3101 if (!
setFloat(i->first.c_str(), key, i->second))
3109 std::map<std::string, DataMessage*>::iterator i = map.begin(), e = map.end();
3120 uint64 bestCandidateDiff = 0, diff;
3122 std::map<uint64, DataMessage*>::reverse_iterator i = messages.rbegin(), e = messages.rend();
3124 if (!bestCandidate) {
3125 bestCandidate = i->second;
3126 bestCandidateDiff = (i->first > t) ? i->first - t : t - i->first;
3129 diff = (i->first > t) ? i->first - t : t - i->first;
3130 if (diff < bestCandidateDiff) {
3131 bestCandidate = i->second;
3132 bestCandidateDiff = diff;
3137 return bestCandidate;
3143 data->chaincputime = chainCPUTime + cycleCPUTime;
3144 data->chainwalltime = chainWallTime + cycleWallTime;
3145 data->chaincount = chainCount;
3147 data->cyclecputime = cycleCPUTime;
3148 data->cyclewalltime = cycleWallTime;
3155 if (!
data)
return false;
3171 *newData =
new char[newSize];
3173 memset(*newData, 0, newSize);
3207 *newData =
new char[header->
size];
3208 memcpy(*newData,
data, header->
size);
3211 switch (header->
cver) {
3213 *newData =
new char[header->
size];
3214 memcpy(*newData,
data, header->
size);
3231 unittest::fail(
"DataMessage test: default constructor invalid\n");
3241 unittest::fail(
"DataMessage test: DataMessage(type, from) invalid\n");
3247 unittest::fail(
"DataMessage test: DataMessage(type, from, to, ttl, priority) invalid\n");
3256 const uint64 t = 1234567890ULL;
3259 if (!msg.
setInt(
"I", -42)) {
unittest::fail(
"DataMessage test: setInt failed\n");
return false; }
3262 const char bin[] = {
'x',
'y',
'z' };
3263 if (!msg.
setData(
"B", bin, 3)) {
unittest::fail(
"DataMessage test: setData failed\n");
return false; }
3265 if (msg.
getTime(
"T") != t) {
unittest::fail(
"DataMessage test: getTime mismatch\n");
return false; }
3267 if (!s || strcmp(s,
"hello") != 0) {
unittest::fail(
"DataMessage test: getString mismatch\n");
return false; }
3269 if (!msg.
getInt(
"I", i) || i != -42) {
unittest::fail(
"DataMessage test: getInt mismatch\n");
return false; }
3271 if (!msg.
getDouble(
"D", d) || d < 3.13 || d > 3.15) {
unittest::fail(
"DataMessage test: getDouble mismatch\n");
return false; }
3273 if (!msg.
getFloat(
"F", f) || f < 2.4f || f > 2.6f) {
unittest::fail(
"DataMessage test: getFloat mismatch\n");
return false; }
3275 const char* b = msg.
getData(
"B", bsize);
3276 if (!b || bsize != 3 || b[0] !=
'x' || b[1] !=
'y' || b[2] !=
'z') {
3277 unittest::fail(
"DataMessage test: getData mismatch\n");
return false;
3286 unittest::fail(
"DataMessage test: hasKey/hasString etc failed\n");
return false;
3289 unittest::fail(
"DataMessage test: getKeyType/isSingleValue failed\n");
return false;
3297 if (!cpy || csize != 3) {
unittest::fail(
"DataMessage test: getDataCopy failed\n");
return false; }
3305 if (!got || got->
getUserCount() == 0) {
unittest::fail(
"DataMessage test: getAttachedMessageCopy failed\n");
delete got;
return false; }
3306 if (got->
getAsString(
"nested") !=
"value") {
unittest::fail(
"DataMessage test: attached message content mismatch\n");
delete got;
return false; }
3317 if (!msg.
setTime(
static_cast<int64
>(0),
"arr", 100ULL)) {
unittest::fail(
"DataMessage test: setTime array failed\n");
return false; }
3318 if (!msg.
setString(1,
"arr",
"one")) {
unittest::fail(
"DataMessage test: setString array failed\n");
return false; }
3319 if (!msg.
setInt(2,
"arr", 999)) {
unittest::fail(
"DataMessage test: setInt array failed\n");
return false; }
3320 if (msg.
getTime(
static_cast<int64
>(0),
"arr") != 100ULL) {
unittest::fail(
"DataMessage test: getTime array mismatch\n");
return false; }
3321 if (msg.
getAsString(1,
"arr") !=
"one") {
unittest::fail(
"DataMessage test: getAsString array mismatch\n");
return false; }
3323 if (!msg.
getInt(2,
"arr", vi) || vi != 999) {
unittest::fail(
"DataMessage test: getInt array mismatch\n");
return false; }
3325 unittest::fail(
"DataMessage test: array key type failed\n");
return false;
3329 unittest::fail(
"DataMessage test: getArraySize failed\n");
return false;
3332 std::map<int64, uint64> tmap; tmap[0] = 10; tmap[1] = 20;
3334 std::map<int64, std::string> smap; smap[0] =
"a"; smap[1] =
"b";
3336 std::map<int64, int64> imap; imap[0] = 1; imap[1] = 2;
3338 std::map<int64, double> dmap; dmap[0] = 1.1; dmap[1] = 2.2;
3340 std::map<int64, uint64> gotT = msg.
getTimeArray(
"tarr");
3341 if (gotT.size() != 2 || gotT[0] != 10 || gotT[1] != 20) {
unittest::fail(
"DataMessage test: getTimeArray mismatch\n");
return false; }
3343 if (gotS.size() != 2 || gotS[0] !=
"a" || gotS[1] !=
"b") {
unittest::fail(
"DataMessage test: getAsStringArray mismatch\n");
return false; }
3344 std::map<int64, int64> gotI = msg.
getIntArray(
"iarr");
3345 if (gotI.size() != 2 || gotI[0] != 1 || gotI[1] != 2) {
unittest::fail(
"DataMessage test: getIntArray mismatch\n");
return false; }
3347 if (gotD.size() != 2 || gotD[0] < 1.0 || gotD[0] > 1.2 || gotD[1] < 2.1 || gotD[1] > 2.3) {
unittest::fail(
"DataMessage test: getDoubleArray mismatch\n");
return false; }
3354 if (!msg.
setTime(
"x",
"m", 200ULL)) {
unittest::fail(
"DataMessage test: setTime map failed\n");
return false; }
3355 if (!msg.
setString(
"y",
"m",
"mapval")) {
unittest::fail(
"DataMessage test: setString map failed\n");
return false; }
3356 if (!msg.
setInt(
"z",
"m", -7)) {
unittest::fail(
"DataMessage test: setInt map failed\n");
return false; }
3357 if (msg.
getTime(
"x",
"m") != 200ULL) {
unittest::fail(
"DataMessage test: getTime map mismatch\n");
return false; }
3358 if (msg.
getAsString(
"y",
"m") !=
"mapval") {
unittest::fail(
"DataMessage test: getAsString map mismatch\n");
return false; }
3360 if (!msg.
getInt(
"z",
"m", vi) || vi != -7) {
unittest::fail(
"DataMessage test: getInt map mismatch\n");
return false; }
3362 unittest::fail(
"DataMessage test: map key type failed\n");
return false;
3366 unittest::fail(
"DataMessage test: getMapSize failed\n");
return false;
3369 std::map<std::string, uint64> tmap; tmap[
"a"] = 1; tmap[
"b"] = 2;
3371 std::map<std::string, std::string> smap; smap[
"k1"] =
"v1"; smap[
"k2"] =
"v2";
3373 std::map<std::string, int64> imap; imap[
"i1"] = 10; imap[
"i2"] = 20;
3375 std::map<std::string, uint64> gotT = msg.
getTimeMap(
"tm");
3376 if (gotT.size() != 2 || gotT[
"a"] != 1 || gotT[
"b"] != 2) {
unittest::fail(
"DataMessage test: getTimeMap mismatch\n");
return false; }
3377 std::map<std::string, std::string> gotS = msg.
getAsStringMap(
"sm");
3378 if (gotS.size() != 2 || gotS[
"k1"] !=
"v1" || gotS[
"k2"] !=
"v2") {
unittest::fail(
"DataMessage test: getAsStringMap mismatch\n");
return false; }
3379 std::map<std::string, int64> gotI = msg.
getIntMap(
"im");
3380 if (gotI.size() != 2 || gotI[
"i1"] != 10 || gotI[
"i2"] != 20) {
unittest::fail(
"DataMessage test: getIntMap mismatch\n");
return false; }
3390 std::map<int64, std::string> amap; amap[0] =
"elem0";
3392 std::map<std::string, int64> mmap; mmap[
"idx"] = 42;
3396 if (!raw || sz == 0) {
unittest::fail(
"DataMessage test: getRawData/getSize failed\n");
return false; }
3398 if (!decoded.
isValid()) {
unittest::fail(
"DataMessage test: decoded message invalid\n");
return false; }
3400 unittest::fail(
"DataMessage test: round-trip getUserCount mismatch\n");
return false;
3402 if (decoded.
getAsString(
"k") !=
"roundtrip") {
unittest::fail(
"DataMessage test: round-trip string mismatch\n");
return false; }
3404 if (!decoded.
getInt(
"n", nval) || nval != 77) {
unittest::fail(
"DataMessage test: round-trip int mismatch\n");
return false; }
3406 if (!decoded.
getDouble(
"x", xval) || xval < 1.4 || xval > 1.6) {
unittest::fail(
"DataMessage test: round-trip double mismatch\n");
return false; }
3408 if (decoded.
getIntMap(
"m")[
"idx"] != 42) {
unittest::fail(
"DataMessage test: round-trip map mismatch\n");
return false; }
3417 if (ustr.empty()) {
unittest::fail(
"DataMessage test: getUserEntriesAsString empty\n");
return false; }
3419 if (ujson.empty()) {
unittest::fail(
"DataMessage test: getUserEntriesAsJSON empty\n");
return false; }
3421 std::string json = msg.
toJSON();
3422 if (json.empty()) {
unittest::fail(
"DataMessage test: toJSON empty\n");
return false; }
3423 std::string xml = msg.
toXML();
3424 if (xml.empty()) {
unittest::fail(
"DataMessage test: toXML empty\n");
return false; }
3425 std::string csv = msg.
toCSV();
3426 if (csv.empty()) {
unittest::fail(
"DataMessage test: toCSV empty\n");
return false; }
3428 if (hdr.empty()) {
unittest::fail(
"DataMessage test: GetCSVHeader empty\n");
return false; }
3439 unittest::fail(
"DataMessage test: copyUserEntriesFromMessage count\n");
return false;
3442 unittest::fail(
"DataMessage test: copyUserEntriesFromMessage content\n");
return false;
3446 if (dst.
hasKey(
"a")) {
unittest::fail(
"DataMessage test: removeEntry key still present\n");
return false; }
3454 if (msg.
hasKey(
"nonexistent")) {
unittest::fail(
"DataMessage test: hasKey nonexistent true\n");
return false; }
3455 if (msg.
getString(
"nonexistent") != NULL) {
unittest::fail(
"DataMessage test: getString nonexistent non-NULL\n");
return false; }
3456 if (msg.
getTime(
"nonexistent") != 0) {
unittest::fail(
"DataMessage test: getTime nonexistent non-zero\n");
return false; }
3469 "Data message encode/decode, arrays, maps, serialisation",
"core");
The binary DataMessage container — the central data-exchange object of Psyclone/CMSDK.
#define CURRENTDATAMESSAGEVERSION
#define DATAMESSAGEINFOID
#define GetObjID(data)
Extract the cid field from a binary object block: the uint32 at byte offset 4 (after the leading size...
#define DATAMESSAGEDRAFTID
CMSDK time: µs-resolution 64-bit timestamps and the Time Mapping Constant (TMC).
Small, dependency-free unit test harness used by all CMSDK object tests.
bool setTime(const char *key, uint64 value)
setTime(const char* key, uint64 value)
std::map< int64, float64 > getAsFloatArray(const char *key)
getAsFloatArray(const char* key)
bool setFloatArray(const char *key, std::map< int64, float64 > &map)
setFloatArray(const char* key, std::map<int64, float64>& map) Sets the whole float array named key in...
static bool UnitTest()
Run the built-in self test for the DataMessage implementation.
DataMessage()
DataMessage() Creates an empty DataMessage.
bool getDouble(const char *key, double &value)
getDouble(const char* key, double& value)
~DataMessage()
~DataMessage() Message destructor
std::string toXML(std::map< uint16, std::string > *subtypes=NULL, std::map< uint16, std::string > *subcontexts=NULL, std::map< uint32, std::string > *compNames=NULL)
toXML()
static DataMessage * FindClosestMessage(uint64 t, std::map< uint64, DataMessage * > &messages)
FindClosestMessage(uint64 t, std::map<uint64, DataMessage*> &messages) In a map of time -> DataMessag...
bool setFloat(const char *key, float64 value)
setFloat(const char* key, float64 value)
std::map< int64, int64 > getIntArray(const char *key)
getIntArray(const char* key)
bool addTimeUsage(uint32 cycleCPUTime, uint32 cycleWallTime, uint32 chainCPUTime=0, uint32 chainWallTime=0, uint32 chainCount=0)
addTimeUsage()
std::map< std::string, double > getDoubleMap(const char *key)
returns the user double entry with this key
bool setString(const char *key, const char *value)
setString(const char* key, const char* value)
bool getInt(const char *key, int64 &value)
getInt(const char* key, int64& value)
bool setInt(const char *key, int64 value)
setInt(const char* key, int64 value)
bool isSingleValue(const char *key)
isSingleValue(const char* key)
bool hasData(const char *key)
Check if key variable exists and is a data entry.
uint32 getMapCount(const char *key)
getMapCount(const char* key) Returns the number of elements in map with name '<key>'
std::map< std::string, uint64 > getTimeMap(const char *key)
returns the user time entry with this key
std::map< std::string, int64 > getIntMap(const char *key)
returns the user integer entry with this key
uint32 getArraySize(const char *key)
getArraySize(const char* key) Returns the number of elements in array with name '<key>'
char * getDataCopy(const char *key, uint32 &size)
getDataCopy(const char* key, uint32& size)
bool setDoubleMap(const char *key, std::map< std::string, double > &map)
sets the user double entry with this key to the value provided
std::string getAsString(const char *key)
getAsString(const char* key)
DataMessageHeader * data
Pointer to the message's flat memory block (header + user entries).
std::string toJSON(std::map< uint16, std::string > *subtypes=NULL, std::map< uint16, std::string > *subcontexts=NULL, std::map< uint32, std::string > *compNames=NULL)
toJSON()
std::map< int64, float64 > getFloatArray(const char *key)
getFloatArray(const char* key)
std::string toCSV(const char *separator=NULL, const char *preample=NULL, std::map< uint16, std::string > *subtypes=NULL, std::map< uint16, std::string > *subcontexts=NULL, std::map< uint32, std::string > *compNames=NULL)
toCSV()
bool hasFloat(const char *key)
Check if key variable exists and is a float.
bool setIntMap(const char *key, std::map< std::string, int64 > &map)
sets the user integer entry with this key
char * findEntry(const char *key)
findEntry(const char* key)
const char * getData(const char *key, uint32 &size)
getData(const char* key, uint32& size)
bool getAsBool(const char *key)
getAsBool(const char* key)
uint32 getUserCount()
getUserCount()
uint32 getSize()
getSize() Get message size Many types of data of any size can be put into a message as user entries; ...
static bool ConvertDataFromOlderMessageFormat(const char *data, char **newData)
Convert a binary block in the legacy (pre-version-10, DATAMESSAGEOLDID) format to the current DataMes...
uint32 copyUserEntriesFromMessage(DataMessage *msg)
copyUserEntriesFromMessage(DataMessage* msg) Copies all user data from a message into this message,...
std::string getUserEntriesAsJSON(bool asText)
getUserEntriesAsJSON(bool asText) Returns the JSON representation of the full message including all u...
bool setAttachedMessage(const char *key, DataMessage *msg)
setAttachedMessage(const char* key, DataMessage* msg)
bool setTimeArray(const char *key, std::map< int64, uint64 > &map)
setTimeArray(const char* key, std::map<int64, uint64>& map) Sets the whole time array named key in on...
std::map< std::string, std::string > getStringMap(const char *key)
returns the user string entry with this key
std::map< int64, std::string > getStringArray(const char *key)
getStringArray(const char* key)
bool setAttachedMessageArray(const char *key, std::map< int64, DataMessage * > &map)
setAttachedMessageArray(const char* key, std::map<int64, DataMessage*>& map) Sets the whole array of ...
bool removeEntry(const char *key)
removeEntry(const char* key)
bool hasTime(const char *key)
Check if key variable exists and is a time.
std::map< int64, std::string > getAsStringArray(const char *key)
getAsStringArray(const char* key)
bool setIntArray(const char *key, std::map< int64, int64 > &map)
setIntArray(const char* key, std::map<int64, int64>& map) Sets the whole integer array named key in o...
std::map< std::string, DataMessage * > getAttachedMessageMap(const char *key)
returns a copy of the user message entry with this key
bool setTimeMap(const char *key, std::map< std::string, uint64 > &map)
sets the user time entry with this key
uint32 getContentSize(const char *key)
getContentSize(const char* key)
void invalidateFindKeyCache()
Internal: clears the single-entry key-lookup cache.
uint32 getArrayCount(const char *key)
getArrayCount(const char* key) Returns the number of elements in array with name '<key>'
std::map< std::string, int64 > getAsIntMap(const char *key)
returns the user entry as an integer map regardless of what type it is
bool setFloatMap(const char *key, std::map< std::string, float64 > &map)
sets the user float entry with this key to the value provided
uint64 getAsTime(const char *key)
getAsTime(const char* key)
bool isMapContent(const char *key)
isMapContent(const char* key)
bool hasKey(const char *key)
Check if key variable exists.
uint64 getTime(const char *key)
getTime(const char* key)
bool getFloat(const char *key, float64 &value)
getFloat(const char* key, float64& value)
bool setRawData(const char *key, const char *value, uint32 size, uint32 datatype)
Internal: low-level entry writer used by all typed set...() overloads.
bool setDouble(const char *key, double value)
setDouble(const char* key, double value)
std::map< std::string, std::string > getAsStringMap(const char *key)
returns the user entry as a string regardless of what type it is
int64 getAsInt(const char *key)
getAsInt(const char* key)
bool setDoubleArray(const char *key, std::map< int64, double > &map)
setDoubleArray(const char* key, std::map<int64, double>& map) Sets the whole double array named key i...
bool setStringMap(const char *key, std::map< std::string, std::string > &map)
sets the user string entry with this key
bool isArrayContent(const char *key)
isArrayContent(const char* key)
DataMessage * getAttachedMessageCopy(const char *key)
getAttachedMessageCopy(const char* key)
bool isValid()
isValid() Checks that the message memory block exists and carries the current-format object id (DATAM...
bool hasMessage(const char *key)
Check if key variable exists and is a message.
char * getRawData()
getRawData() Retrieve a pointer to the raw binary block of the message (header + entries).
const char * swapMessageData(const char *data)
swapMessageData(const char* data)
std::map< int64, uint64 > getTimeArray(const char *key)
uint32 getMapSize(const char *key)
getMapSize(const char* key) Returns the number of elements in map with name '<key>'
std::map< int64, double > getDoubleArray(const char *key)
getDoubleArray(const char* key)
bool setData(const char *key, const char *value, uint32 size)
setData(const char* key, const char* value, uint32 size)
bool hasString(const char *key)
Check if key variable exists and is a string.
std::map< int64, DataMessage * > getAttachedMessageArray(const char *key)
getAttachedMessageArray(const char* key)
const char * getString(const char *key)
getString(const char* key)
char * findSpace(uint32 space)
findSpace(uint32 space)
static std::string GetCSVHeader(const char *separator=NULL, const char *preample=NULL)
toCSVHeader()
bool fillInDraftUserDataFrom(const char *data, uint32 maxDraftSize)
fillInDraftUserDataFrom(const char* data, uint32 maxDraftSize)
KeyType getKeyType(const char *key)
getKeyType(const char* key)
uint32 getContentType(const char *key)
getContentType(const char* key)
bool setStringArray(const char *key, std::map< int64, std::string > &map)
setStringArray(const char* key, std::map<int64, std::string>& map) Sets the whole string array named ...
DataMessage * copy()
copy() Creates a full deep copy of the message and returns it.
bool hasInteger(const char *key)
Check if key variable exists and is an integer.
std::map< int64, int64 > getAsIntArray(const char *key)
getAsIntArray(const char* key)
bool setAttachedMessageMap(const char *key, std::map< std::string, DataMessage * > &map)
sets the user message entry with this key to the provided message
std::string getUserEntriesAsString()
getUserEntriesAsString() Returns the textual representation of the full message including all user en...
float64 getAsFloat(const char *key)
getAsFloat(const char* key)
std::map< std::string, float64 > getFloatMap(const char *key)
returns the user float entry with this key
std::map< std::string, float64 > getAsFloatMap(const char *key)
returns the user entry as a float map regardless of what type it is
static UnitTestRunner & instance()
Access the singleton (created on first use).
void registerTest(const char *name, UnitTestFunc func, const char *description="", const char *category="", bool inDefaultRun=true)
Register a test with the runner.
std::string PrintTimeString(uint64 t, bool local=true, bool us=true, bool ms=true)
uint64 GetTimeNow()
Return the current absolute time (µs since year 0) according to the TMC.
bool TextStartsWith(const char *str, const char *start, bool caseSensitive=true)
Test whether str starts with start.
std::string TextIndent(const char *text, const char *indent)
Prefix every line of text with indent.
uint32 StringSingleReplace(std::string &text, std::string key, std::string value, bool onlyFirst)
Replace occurrences of key with value in text.
std::string StringFormat(const char *format,...)
printf into a std::string.
uint64 Ascii2Uint64(const char *ascii, uint32 start=0, uint32 end=0)
Parse an unsigned 64-bit decimal integer from a substring.
bool TextEndsWith(const char *str, const char *end, bool caseSensitive=true)
Test whether str ends with end.
int64 Ascii2Int64(const char *ascii, uint32 start=0, uint32 end=0)
Parse a signed 64-bit decimal integer from a substring.
uint32 strcpyavail(char *dst, const char *src, uint32 maxlen, bool copyAvailable)
Bounded strcpy that always NUL-terminates.
float64 Ascii2Float64(const char *ascii, uint32 start=0, uint32 end=0)
Parse a 64-bit float from a substring (decimal point, not locale dependent).
void fail(const char *fmt,...)
Set an explanatory reason shown on the FAIL line.
void progress(int percent, const char *action)
Report progress with a short description of the current action.
void Register_DataMessage_Tests()
static struct PsyType CTRL_TEST
Hierarchical message type identifier — the key used for publish/subscribe matching in Psyclone.