opencv would be used to compile actual processing part stdexec would be used for RPC module :) TG-8 #in-progress
42 lines
1.2 KiB
C++
42 lines
1.2 KiB
C++
//
|
|
// Created by vptyp on 11.03.2026.
|
|
//
|
|
#include "cloud_point_rpc/rpc_coder.h"
|
|
|
|
#include "libbase64.h"
|
|
#include <glog/logging.h>
|
|
namespace score {
|
|
|
|
Base64RPCCoder::Base64RPCCoder() = default;
|
|
Base64RPCCoder::~Base64RPCCoder() = default;
|
|
|
|
/**
|
|
* Tries to decode ASCII complained string to the raw bytes
|
|
* @param encoded ASCII complained base64 encoded string
|
|
* @return vector of raw bytes << allocated on encoded.size() / 4 * 3 + 1 size
|
|
*/
|
|
std::vector<char> Base64RPCCoder::decode(const std::string& encoded) {
|
|
DLOG(INFO) << "Base64RPCCoder::decode";
|
|
std::vector<char> result((encoded.length() >> 2) * 3 + 1);
|
|
size_t result_len = 0;
|
|
base64_decode(encoded.data(), encoded.size(),
|
|
result.data(), &result_len, 0);
|
|
DLOG(INFO) << "result_len: " << result_len;
|
|
return result;
|
|
}
|
|
/**
|
|
*
|
|
* @param data raw byte stream
|
|
* @return encoded base64 string
|
|
*/
|
|
std::string Base64RPCCoder::encode(const std::vector<char>& data) {
|
|
DLOG(INFO) << "Base64RPCCoder::encode";
|
|
size_t result_len = 0;
|
|
std::string result(data.size() / 3 * 4 + 1, 0);
|
|
base64_encode(data.data(), data.size(),
|
|
result.data(), &result_len, 0
|
|
);
|
|
DLOG(INFO) << "result_len: " << result_len;
|
|
return result;
|
|
}
|
|
} |