Skip to content

Commit dc8d0c7

Browse files
committed
style: code formatting to new clang format
1 parent f981209 commit dc8d0c7

File tree

10 files changed

+29
-58
lines changed

10 files changed

+29
-58
lines changed

include/python/API.hpp

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,13 @@ namespace python::API
5656
template <typename RetTy>
5757
RetTy convertToCppObject(PyObject* o)
5858
{
59-
if constexpr (std::is_same_v<RetTy, int>)
60-
{
59+
if constexpr (std::is_same_v<RetTy, int>) {
6160
return PyLong_AsLong(o);
6261
}
63-
else if constexpr (std::is_same_v<RetTy, double> || std::is_same_v<RetTy, float>)
64-
{
62+
else if constexpr (std::is_same_v<RetTy, double> || std::is_same_v<RetTy, float>) {
6563
return PyFloat_AsDouble(o);
6664
}
67-
else if constexpr (std::is_same_v<RetTy, std::string>)
68-
{
65+
else if constexpr (std::is_same_v<RetTy, std::string>) {
6966
return PyUnicode_AsUTF8(o);
7067
}
7168
}
@@ -85,13 +82,11 @@ namespace python::API
8582
// Import the Module (file name)
8683
PyObject* pModule = PyImport_ImportModule(moduleName.c_str());
8784

88-
if (pModule)
89-
{
85+
if (pModule) {
9086
// Get the function from the module
9187
PyObject* pFunc = PyObject_GetAttrString(pModule, functionName.c_str());
9288

93-
if (PyCallable_Check(pFunc))
94-
{
89+
if (PyCallable_Check(pFunc)) {
9590
// Create an empty Tuple of size len(args)
9691
PyObject* pArgs = PyTuple_New(sizeof...(args));
9792

@@ -102,27 +97,23 @@ namespace python::API
10297
// Call the function with the tuple containing the arguments
10398
PyObject* pValue = PyObject_CallObject(pFunc, pArgs);
10499

105-
if (!pValue)
106-
{
100+
if (!pValue) {
107101
Py_Finalize();
108102
throw Error("Function '" + functionName + "' failed.");
109103
}
110104

111-
if constexpr (!std::is_same_v<RetTy, void>)
112-
{
105+
if constexpr (!std::is_same_v<RetTy, void>) {
113106
RetTy result = convertToCppObject<RetTy>(pValue);
114107
Py_Finalize();
115108
return result;
116109
}
117110
}
118-
else
119-
{
111+
else {
120112
Py_Finalize();
121113
throw Error("Python function '" + functionName + "' is not callable.");
122114
}
123115
}
124-
else
125-
{
116+
else {
126117
Py_Finalize();
127118
throw Error("Failed to load Python module: '" + moduleName + "'.");
128119
}

include/utils/Debug.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212
#ifdef VC_DEBUG_ON
1313
#define VC_LOG_DEBUG(x) \
14-
do \
15-
{ \
14+
do { \
1615
std::cout << x << std::endl; \
1716
} while (0);
1817
#else

include/utils/Map.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ template <typename K, typename V>
1515
std::ostream &operator<<(std::ostream &os, const std::map<K, V> &map)
1616
{
1717
os << "{\n\t";
18-
for (auto it = map.begin(); it != map.end(); it++)
19-
{
18+
for (auto it = map.begin(); it != map.end(); it++) {
2019
os << (*it).first;
2120
os << " = ";
2221
os << (*it).second;
23-
if (std::next(it) != map.end())
24-
{
22+
if (std::next(it) != map.end()) {
2523
os << ",\n\t";
2624
}
2725
}

include/utils/Vector.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ template <typename T>
1515
std::ostream &operator<<(std::ostream &os, const std::vector<T> &vec)
1616
{
1717
os << "[";
18-
for (const auto &it : vec)
19-
{
18+
for (const auto &it : vec) {
2019
os << *it;
21-
if (it != vec.end() - 1)
22-
{
20+
if (it != vec.end() - 1) {
2321
os << ", ";
2422
}
2523
}

include/vm/AppEvent.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ class AppEvent : public QWidget
2828
{
2929
auto e = _events.find(event->key());
3030

31-
if (e != _events.end())
32-
{
31+
if (e != _events.end()) {
3332
e->second();
3433
}
3534

src/compiler/generateVideo.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,18 @@ int Compiler::Writer::generateVideo(
4545
"w"
4646
);
4747

48-
if (!ffmpegPipe)
49-
{
48+
if (!ffmpegPipe) {
5049
throw Error("Could not start the ffmpeg pipe.");
5150
}
5251

53-
for (const auto &f : frames)
54-
{
52+
for (const auto &f : frames) {
5553
const int nbRows = f.rows;
5654
const int nbCols = f.cols;
5755

5856
cv::Mat frame(nbRows, nbCols, CV_8UC4); // BGRA -> RGBA
5957

60-
for (int y = 0; y < nbRows; y++)
61-
{
62-
for (int x = 0; x < nbCols; x++)
63-
{
58+
for (int y = 0; y < nbRows; y++) {
59+
for (int x = 0; x < nbCols; x++) {
6460
const cv::Vec4b pixel = f.at<cv::Vec4b>(y, x);
6561

6662
const float alpha = pixel[3] / 255.0;

src/input/concrete/ABCConcreteInput.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ IInput* ABCConcreteInput::copy()
2424
ABCConcreteInput* cp = new ABCConcreteInput();
2525

2626
VC_LOG_DEBUG("fully cloned")
27-
for (const Frame& frame : _frames)
28-
{
27+
for (const Frame& frame : _frames) {
2928
cp->_frames.push_back(frame.clone());
3029
}
3130

@@ -51,10 +50,8 @@ void ABCConcreteInput::repeat(size_t n)
5150
{
5251
const size_t initialSize = _frames.size();
5352

54-
while (n--)
55-
{
56-
for (size_t i = 0; i < initialSize; i++)
57-
{
53+
while (n--) {
54+
for (size_t i = 0; i < initialSize; i++) {
5855
_frames.push_back(_frames[i].clone());
5956
}
6057
}

src/input/concrete/media/Image.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@ Image::Image(const std::string& inputName)
1818
{
1919
cv::Mat image = cv::imread(inputName);
2020

21-
if (image.empty())
22-
{
21+
if (image.empty()) {
2322
throw Error("Could not load Image: " + inputName);
2423
}
2524

26-
if (image.channels() != 4)
27-
{
25+
if (image.channels() != 4) {
2826
cv::cvtColor(image, image, cv::COLOR_BGR2BGRA);
2927
}
3028

src/input/concrete/media/Video.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,20 @@ Video::Video(const std::string &inputName)
2020
{
2121
cv::VideoCapture video(inputName, cv::CAP_FFMPEG);
2222

23-
if (!video.isOpened())
24-
{
23+
if (!video.isOpened()) {
2524
throw Error("Could not load Video: " + inputName);
2625
}
2726

28-
while (true)
29-
{
27+
while (true) {
3028
cv::Mat currentFrame;
3129

3230
video >> currentFrame;
3331

34-
if (currentFrame.empty())
35-
{
32+
if (currentFrame.empty()) {
3633
break;
3734
}
3835

39-
if (currentFrame.channels() != 4)
40-
{
36+
if (currentFrame.channels() != 4) {
4137
cv::cvtColor(currentFrame, currentFrame, cv::COLOR_BGR2BGRA);
4238
}
4339

src/input/concrete/text/Text.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ Text::Text(const std::string &text, double fontSize, int fontThickness, const st
2424

2525
cv::putText(bg, text, cv::Point(0, size.height), font, fontSize, cv::Scalar(color[0], color[1], color[2], color[3]), fontThickness, cv::LINE_AA);
2626

27-
for (size_t i = framerate * duration; i; i--)
28-
{
27+
for (size_t i = framerate * duration; i; i--) {
2928
_frames.push_back(Frame(bg.clone()));
3029
}
3130
}

0 commit comments

Comments
 (0)