C++-ify base64 functions.

Change-Id: I5cf7a8971b18b7a2700fe8d616733e32fa1e3282
This commit is contained in:
Peter Johnson
2015-06-28 22:24:14 -07:00
parent b7a87bb6f9
commit 40ebb9a844
3 changed files with 40 additions and 68 deletions

View File

@@ -54,6 +54,8 @@ static void WriteString(std::ostream& os, llvm::StringRef str) {
}
void Storage::SavePersistent(std::ostream& os) const {
std::string base64_encoded;
// header
os << "[NetworkTables Storage 3.0]\n";
@@ -107,15 +109,10 @@ void Storage::SavePersistent(std::ostream& os) const {
case NT_STRING:
WriteString(os, v.GetString());
break;
case NT_RAW: {
char* buf = new char[Base64EncodeLen(v.data.v_raw.len)];
Base64Encode(buf,
reinterpret_cast<const unsigned char*>(v.data.v_raw.str),
v.data.v_raw.len);
os << buf;
delete[] buf;
case NT_RAW:
Base64Encode(v.GetRaw(), &base64_encoded);
os << base64_encoded;
break;
}
case NT_BOOLEAN_ARRAY: {
bool first = true;
for (auto elem : v.GetBooleanArray()) {