Skip to content

Commit

Permalink
feat: reimpl base64
Browse files Browse the repository at this point in the history
  • Loading branch information
neko-para committed Mar 14, 2024
1 parent a0ffa0f commit 9980a60
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 114 deletions.
12 changes: 12 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
"configurations": [
{
"name": "MaaHttp - Debug",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/bin/Debug/MaaHttp",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb"
},
{
"name": "MaaHttp - Debug Win",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/build/bin/Debug/MaaHttp.exe",
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@
],
"python.analysis.extraPaths": [
"./source/binding/Python"
]
],
"editor.formatOnSave": true
}
2 changes: 1 addition & 1 deletion source/MaaHttp/LHG
109 changes: 0 additions & 109 deletions source/MaaHttp/base64.hpp

This file was deleted.

1 change: 1 addition & 0 deletions source/MaaHttp/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <iostream>

#include "utils/base64.hpp"
#include "utils/phony.hpp"

#include "spec/spec.hpp"
Expand Down
10 changes: 7 additions & 3 deletions source/MaaHttp/spec/call.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "./type.hpp"
#include "./utils.hpp"

#include "../base64.hpp"
#include "utils/base64.hpp"
#include "utils/phony.hpp"

#include "../info.hpp"
Expand Down Expand Up @@ -47,7 +47,7 @@ auto size =
std::string_view data(
reinterpret_cast<char*>(std::get<maa::func_type_MaaGetImageEncoded::ret::index>(arg)),
size);
value = base64::to_base64(data);
value = lhg::to_base64(data);
res[name] = value;
__CALL_DECLARE_ARG_TO_JSON_END()

Expand All @@ -59,7 +59,11 @@ __CALL_DECLARE_INPUT(maa::func_type_MaaSetImageEncoded::_2_size, true)

__CALL_DECLARE_JSON_TO_ARG_BEGIN(maa::func_type_MaaSetImageEncoded, _1_data)
std::string& data = std::get<maa::func_type_MaaSetImageEncoded::_1_data::index>(state);
data = base64::from_base64(value.as_string());
auto opt = lhg::from_base64(value.as_string());
if (!opt.has_value()) {
return false;
}
data = opt.value();
std::get<maa::func_type_MaaSetImageEncoded::_1_data::index>(arg) =
reinterpret_cast<unsigned char*>(const_cast<char*>(data.c_str()));
std::get<maa::func_type_MaaSetImageEncoded::_2_size::index>(arg) = data.size();
Expand Down

0 comments on commit 9980a60

Please sign in to comment.