Skip to content

Commit a69927d

Browse files
committed
styles: format by clang-format
1 parent 6d2a040 commit a69927d

17 files changed

+33
-40
lines changed

source/MaaAdbControlUnit/Input/AutoDetectInput.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include "AutoDetectInput.h"
22

3+
#include <format>
34
#include <ranges>
45
#include <unordered_set>
5-
#include <format>
66

77
#include "AdbInput.h"
88
#include "MaatouchInput.h"

source/MaaAdbControlUnit/Input/MaatouchInput.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
#include <array>
44
#include <cmath>
5-
#include <ranges>
65
#include <format>
6+
#include <ranges>
77

88
#include "Utils/Codec.h"
99
#include "Utils/Logger.h"
@@ -68,8 +68,7 @@ bool MaatouchInput::press_key(int key)
6868
static constexpr std::string_view kKeyDownFormat = "k {} d\nc\n";
6969
static constexpr std::string_view kKeyUpFormat = "k {} u\nc\n";
7070

71-
bool ret =
72-
pipe_ios_->write(std::format(kKeyDownFormat, key)) && pipe_ios_->write(std::format(kKeyUpFormat, key));
71+
bool ret = pipe_ios_->write(std::format(kKeyDownFormat, key)) && pipe_ios_->write(std::format(kKeyUpFormat, key));
7372

7473
if (!ret) {
7574
LogError << "failed to write";

source/MaaAdbControlUnit/Input/MinitouchInput.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
#include <array>
44
#include <cmath>
5-
#include <ranges>
65
#include <format>
6+
#include <ranges>
77

88
#include "Utils/Logger.h"
99

source/MaaAdbControlUnit/Input/MtouchHelper.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
#include <array>
44
#include <cmath>
5-
#include <ranges>
65
#include <format>
6+
#include <ranges>
77

88
#include "Utils/Logger.h"
99

source/MaaAdbControlUnit/Screencap/FastestWay.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include "FastestWay.h"
22

3+
#include <format>
34
#include <ranges>
45
#include <unordered_set>
5-
#include <format>
66

77
#include "Encode.h"
88
#include "EncodeToFile.h"

source/MaaAdbControlUnit/Screencap/Minicap/MinicapBase.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include "MinicapBase.h"
22

33
#include <array>
4-
#include <ranges>
54
#include <format>
5+
#include <ranges>
66

77
#include "Utils/Logger.h"
88
#include "Utils/NoWarningCV.hpp"
@@ -63,8 +63,8 @@ bool MinicapBase::init(int swidth, int sheight)
6363

6464
// TODO: 确认低版本是否使用minicap-nopie
6565
const auto bin_path = agent_path_ / path(target_arch) / path("bin") / path("minicap");
66-
const auto lib_path = agent_path_ / path(target_arch) / path("lib") / path(std::format("android-{}", fit_sdk)) /
67-
path("minicap.so");
66+
const auto lib_path =
67+
agent_path_ / path(target_arch) / path("lib") / path(std::format("android-{}", fit_sdk)) / path("minicap.so");
6868
if (!binary_->push(bin_path) || !library_->push(lib_path)) {
6969
return false;
7070
}

source/MaaAdbControlUnit/Screencap/Minicap/MinicapDirect.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ std::optional<cv::Mat> MinicapDirect::screencap()
1212
int width = screencap_helper_.get_w();
1313
int height = screencap_helper_.get_h();
1414

15-
auto res =
16-
binary_->invoke_bin_and_read_pipe(std::format("-P {}x{}@{}x{}/{} -s", width, height, width, height, 0));
15+
auto res = binary_->invoke_bin_and_read_pipe(std::format("-P {}x{}@{}x{}/{} -s", width, height, width, height, 0));
1716

1817
if (!res) {
1918
return std::nullopt;

source/MaaFramework/Vision/ColorMatcher.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
#include <format>
44

5-
#include "Utils/NoWarningCV.hpp"
65
#include "Utils/Logger.h"
6+
#include "Utils/NoWarningCV.hpp"
77
#include "VisionUtils.hpp"
88

99
MAA_VISION_NS_BEGIN
@@ -118,8 +118,8 @@ void ColorMatcher::draw_result(const cv::Rect& roi, const cv::Mat& color, const
118118
const auto& res = results[i];
119119
cv::rectangle(image_draw, res.box, color_draw, 1);
120120

121-
std::string flag = std::format("{}: {}, [{}, {}, {}, {}]", i, res.count, res.box.x, res.box.y,
122-
res.box.width, res.box.height);
121+
std::string flag =
122+
std::format("{}: {}, [{}, {}, {}, {}]", i, res.count, res.box.x, res.box.y, res.box.width, res.box.height);
123123
cv::putText(image_draw, flag, cv::Point(res.box.x, res.box.y - 5), cv::FONT_HERSHEY_PLAIN, 1.2, color_draw, 1);
124124
if (i > 10 && res.count < 100) {
125125
// 太多了画不下,反正后面的也是没用的

source/MaaFramework/Vision/FeatureMatcher.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ void FeatureMatcher::draw_result(const cv::Mat& templ, const std::vector<cv::Key
230230
const auto& res = results.at(i);
231231
cv::rectangle(image_draw, res.box, color, 1);
232232

233-
std::string flag = std::format("Cnt: {}, [{}, {}, {}, {}]", res.count, res.box.x, res.box.y, res.box.width,
234-
res.box.height);
233+
std::string flag =
234+
std::format("Cnt: {}, [{}, {}, {}, {}]", res.count, res.box.x, res.box.y, res.box.width, res.box.height);
235235
cv::putText(image_draw, flag, cv::Point(res.box.x, res.box.y - 5), cv::FONT_HERSHEY_PLAIN, 1.2, color, 1);
236236
}
237237

source/MaaFramework/Vision/NeuralNetworkClassifier.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ void NeuralNetworkClassifier::draw_result(const Result& res) const
113113

114114
for (size_t i = 0; i != param_.cls_size; ++i) {
115115
const auto color = i == res.cls_index ? cv::Scalar(0, 0, 255) : cv::Scalar(255, 0, 0);
116-
std::string text =
117-
std::format("{} {}: prob {:.3f}, raw {:.3f}", i, param_.labels[i], res.probs[i], res.raw[i]);
116+
std::string text = std::format("{} {}: prob {:.3f}, raw {:.3f}", i, param_.labels[i], res.probs[i], res.raw[i]);
118117
cv::putText(image_draw, text, pt, cv::FONT_HERSHEY_PLAIN, 1.2, color, 1);
119118
pt.y += 20;
120119
}

source/MaaFramework/Vision/NeuralNetworkDetector.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ void NeuralNetworkDetector::draw_result(const cv::Rect& roi, const ResultsVec& r
169169

170170
const auto color = cv::Scalar(0, 0, 255);
171171
cv::rectangle(image_draw, my_box, color, 1);
172-
std::string flag = std::format("{} {} {:.3f}: [{}, {}, {}, {}]", res.cls_index, res.label, res.score,
173-
my_box.x, my_box.y, my_box.width, my_box.height);
172+
std::string flag = std::format("{} {} {:.3f}: [{}, {}, {}, {}]", res.cls_index, res.label, res.score, my_box.x,
173+
my_box.y, my_box.width, my_box.height);
174174
cv::putText(image_draw, flag, cv::Point(my_box.x, my_box.y - 5), cv::FONT_HERSHEY_PLAIN, 1.2, color, 1);
175175
}
176176

source/MaaFramework/Vision/TemplateMatcher.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void TemplateMatcher::draw_result(const cv::Rect& roi, const cv::Mat& templ, con
134134
cv::rectangle(image_draw, res.box, color, 1);
135135

136136
std::string flag = std::format("{}: {:.3f}, [{}, {}, {}, {}]", i, res.score, res.box.x, res.box.y,
137-
res.box.width, res.box.height);
137+
res.box.width, res.box.height);
138138
cv::putText(image_draw, flag, cv::Point(res.box.x, res.box.y - 5), cv::FONT_HERSHEY_PLAIN, 1.2, color, 1);
139139
}
140140

source/MaaProjectInterfaceCli/interactor.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "interactor.h"
22

3-
#include <unordered_set>
43
#include <format>
4+
#include <unordered_set>
55

66
#include "MaaToolkit/Device/MaaToolkitDevice.h"
77
#include "Utils/Logger.h"
@@ -86,10 +86,9 @@ void Interactor::print_config() const
8686

8787
std::cout << "Controller:\n\n";
8888
std::cout << "\t"
89-
<< MaaNS::utf8_to_crt(
90-
std::format("{}\n\t\t{}\n\t\t{}", config_.configuration().controller.name,
91-
MaaNS::path_to_utf8_string(config_.configuration().controller.adb_path),
92-
config_.configuration().controller.address))
89+
<< MaaNS::utf8_to_crt(std::format("{}\n\t\t{}\n\t\t{}", config_.configuration().controller.name,
90+
MaaNS::path_to_utf8_string(config_.configuration().controller.adb_path),
91+
config_.configuration().controller.address))
9392
<< "\n\n";
9493

9594
std::cout << "Resource:\n\n";

source/MaaProjectInterfaceCli/runner.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#include <format>
44
#include <iostream>
5-
#include <format>
65

76
#include <meojson/json.hpp>
87

source/include/Utils/ImageIo.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ inline cv::Mat imread(const std::string& utf8_path, int flags = cv::IMREAD_COLOR
2424

2525
inline bool imwrite(const std::filesystem::path& path, cv::InputArray img)
2626
{
27-
if (path.has_parent_path() && !std::filesystem::exists(path.parent_path())
28-
&& !std::filesystem::create_directories(path.parent_path())) {
27+
if (path.has_parent_path() && !std::filesystem::exists(path.parent_path()) &&
28+
!std::filesystem::create_directories(path.parent_path())) {
2929
return false;
3030
}
3131

source/include/Utils/LoggerUtils.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
#pragma once
22

33
#include <filesystem>
4-
#include <fstream>
54
#include <format>
5+
#include <fstream>
66
#include <iostream>
77
#include <mutex>
88
#include <ranges>
99
#include <thread>
1010
#include <tuple>
1111
#include <type_traits>
12-
#include <format>
1312

1413
#if defined(__APPLE__) || defined(__linux__)
1514
#include <unistd.h>
@@ -30,7 +29,7 @@
3029

3130
namespace cv
3231
{
33-
class Mat;
32+
class Mat;
3433
}
3534

3635
MAA_LOG_NS_BEGIN
@@ -212,4 +211,4 @@ class MAA_UTILS_API LogStream
212211
std::stringstream buffer_;
213212
};
214213

215-
MAA_LOG_NS_END
214+
MAA_LOG_NS_END

source/include/Utils/Time.hpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,37 @@
77
#endif
88

99
#include <chrono>
10-
#include <string>
1110
#include <format>
11+
#include <string>
1212

1313
MAA_NS_BEGIN
1414

1515
inline std::string format_now()
1616
{
1717
#ifndef __APPLE__ // Now Apple's compiler cannot build std::chrono::format. 2023/07/21
1818
return std::format("{}", std::chrono::current_zone()->to_local(
19-
std::chrono::floor<std::chrono::milliseconds>(std::chrono::system_clock::now())));
19+
std::chrono::floor<std::chrono::milliseconds>(std::chrono::system_clock::now())));
2020
#else
2121
timeval tv = {};
2222
gettimeofday(&tv, nullptr);
2323
time_t nowtime = tv.tv_sec;
2424
tm* tm_info = localtime(&nowtime);
2525
return std::format("{:0>4}-{:0>2}-{:0>2} {:0>2}:{:0>2}:{:0>2}.{:0>3}", tm_info->tm_year + 1900, tm_info->tm_mon,
26-
tm_info->tm_mday, tm_info->tm_hour, tm_info->tm_min, tm_info->tm_sec, tv.tv_usec / 1000);
26+
tm_info->tm_mday, tm_info->tm_hour, tm_info->tm_min, tm_info->tm_sec, tv.tv_usec / 1000);
2727
#endif
2828
}
2929

3030
inline std::string format_now_for_filename()
3131
{
3232
#ifndef __APPLE__ // Now Apple's compiler cannot build std::chrono::format. 2023/07/21
33-
return std::format("{:%Y.%m.%d-%H.%M.%S}",
34-
std::chrono::current_zone()->to_local(std::chrono::system_clock::now()));
33+
return std::format("{:%Y.%m.%d-%H.%M.%S}", std::chrono::current_zone()->to_local(std::chrono::system_clock::now()));
3534
#else
3635
timeval tv = {};
3736
gettimeofday(&tv, nullptr);
3837
time_t nowtime = tv.tv_sec;
3938
tm* tm_info = localtime(&nowtime);
4039
return std::format("{:0>4}.{:0>2}.{:0>2}-{:0>2}.{:0>2}.{:0>2}.{}", tm_info->tm_year + 1900, tm_info->tm_mon,
41-
tm_info->tm_mday, tm_info->tm_hour, tm_info->tm_min, tm_info->tm_sec, tv.tv_usec);
40+
tm_info->tm_mday, tm_info->tm_hour, tm_info->tm_min, tm_info->tm_sec, tv.tv_usec);
4241
#endif
4342
}
4443

0 commit comments

Comments
 (0)