17 #include <sys/types.h> 34 #ifdef USE_IS_INTERNAL 35 # include "../../cpp/libs/IS_internal.h" 55 pFile->
puts(s.c_str());
56 return (
int)s.length();
65 size_t pos = s.find(
"\"id\":");
66 if (pos == string::npos)
70 uint32_t
id = strtoul(s.c_str() + pos + 5,
NULLPTR, 10);
73 if (offsetMap == NULLPTR)
80 map_name_to_info_t::const_iterator offset;
82 size_t fieldStart = 0;
85 for (
size_t i = 0; i < s.size(); i++)
88 if (c ==
'"' && pc !=
'\\')
90 if ((inQuote = !inQuote))
103 inName = inQuote =
false;
109 fieldName.append(1, c);
112 else if ((c ==
'}' || c ==
'"' || (!inQuote && c ==
',')) && pc !=
'\\')
116 offset = offsetMap->find(fieldName);
117 string json = s.substr(fieldStart, i - fieldStart);
143 const uint8_t* bufPtr = buf;
149 memset(tmpBuffer, 0, hdr.
offset);
150 memcpy(tmpBuffer + hdr.
offset, buf, hdr.
size);
152 memset(tmpBuffer + dataEnd, 0, size - dataEnd);
161 SNPRINTF(tmp,
sizeof(tmp),
"{\"id\":%d", (
int)hdr.
id);
163 for (map_name_to_info_t::const_iterator offset = offsetMap->begin(); offset != offsetMap->end(); offset++)
168 json.append(offset->second.name);
static const map_name_to_info_t * GetMapInfo(uint32_t dataId)
static bool StringToData(const char *stringBuffer, int stringLength, const p_data_hdr_t *hdr, uint8_t *dataBuffer, const data_info_t &info, int radix=10, bool json=false)
bool DataToStringJSON(const p_data_hdr_t &hdr, const uint8_t *buf, string &json)
virtual int puts(const char *str)=0
static uint32_t GetSize(uint32_t dataId)
int WriteDataToFile(cISLogFileBase *pFile, const p_data_hdr_t &dataHdr, const uint8_t *dataBuf, const char *prefix)
#define IS_DATA_MAPPING_MAX_STRING_LENGTH
static bool DataToString(const data_info_t &info, const p_data_hdr_t *hdr, const uint8_t *dataBuffer, data_mapping_string_t stringBuffer, bool json=false)
map< string, data_info_t, sCaseInsensitiveCompare > map_name_to_info_t
bool StringJSONToData(string &s, p_data_hdr_t &hdr, uint8_t *buf, uint32_t bufSize)