Update on the JSON lib to support new parts encoding.

This commit is contained in:
Erik Zandvliet 2013-09-15 16:08:30 +02:00
parent b10185be2a
commit 5ea87a37f7
2 changed files with 17 additions and 0 deletions

View file

@ -992,3 +992,18 @@ JSON::Value JSON::fromDTMI2(const unsigned char * data, unsigned int len, unsign
tmp["trackid"] = tmpTrackID; tmp["trackid"] = tmpTrackID;
return tmp; return tmp;
} }
std::string JSON::encodeVector(std::vector<long long int> & toEncode){
std::string result;
for(int i = 0; i < toEncode.size(); i++){
long long int temp = toEncode[i];
while( temp >= 0xFFFF){
result += (char)0xFF;
result += (char)0xFF;
temp -= 0xFFFF;
}
result += (char)temp / 255;
result += (char)temp % 255;
}
return result;
}

View file

@ -5,6 +5,7 @@
#include <deque> #include <deque>
#include <map> #include <map>
#include <istream> #include <istream>
#include <vector>
//empty definition of DTSC::Stream so it can be a friend. //empty definition of DTSC::Stream so it can be a friend.
namespace DTSC { namespace DTSC {
@ -107,4 +108,5 @@ namespace JSON {
Value fromString(std::string json); Value fromString(std::string json);
Value fromFile(std::string filename); Value fromFile(std::string filename);
std::string encodeVector(std::vector<long long int> & toEncode);
} }