13#include "DebugServer2/Types.h"
14#include "DebugServer2/Utils/Log.h"
22template <
typename T> uint8_t Checksum(T
const &data) {
30template <
typename T> std::string Escape(T
const &data) {
31 std::ostringstream ss;
32 auto first = data.begin();
33 auto last = data.begin();
34 static std::string
const searchStr =
"$#}*";
36 while ((last = std::find_first_of(first, data.end(), searchStr.begin(),
37 searchStr.end())) != data.end()) {
38 while (first < last) {
41 ss << '}' << static_cast<char>(*last - 0x20);
45 while (first < data.end()) {
52template <
typename T> std::string Unescape(T
const &data) {
53 std::ostringstream ss;
54 auto first = data.begin();
55 auto last = data.begin();
57 while ((last = std::find(first, data.end(),
'}')) != data.end()) {
58 while (first < last) {
61 ss << static_cast<char>(*(last + 1) + 0x20);
62 last += 2, first = last;
65 while (first < data.end()) {