Update on the JSON lib to support new parts encoding.
This commit is contained in:
parent
b10185be2a
commit
5ea87a37f7
2 changed files with 17 additions and 0 deletions
15
lib/json.cpp
15
lib/json.cpp
|
@ -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;
|
||||||
|
}
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue