Skip to content

Commit

Permalink
style: add columnlimit to clang-format and format all files
Browse files Browse the repository at this point in the history
also a few other changes to clang-format
  • Loading branch information
f0e committed Nov 25, 2024
1 parent 91ed525 commit fbfbd2e
Show file tree
Hide file tree
Showing 23 changed files with 420 additions and 159 deletions.
18 changes: 15 additions & 3 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

# align stuff inside () semi decently
AlignAfterOpenBracket: BlockIndent
ColumnLimit: 0

ColumnLimit: 120

# fix indentation (use tabs)
ContinuationIndentWidth: 4
Expand Down Expand Up @@ -51,9 +52,9 @@ AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Inline
AllowShortLambdasOnASingleLine: Empty
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
Expand Down Expand Up @@ -102,3 +103,14 @@ SpacesInParentheses: false
SpacesInSquareBrackets: false

InsertNewlineAtEOF: true

PenaltyReturnTypeOnItsOwnLine: 99999 # fuck off mate
# stops
# ```void function(...)```
# from becoming
# ```
# void
# function(
# ...
# )
# ```
21 changes: 10 additions & 11 deletions src/cli/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ bool cli::run(

bool manual_output_files = !outputs.empty();
if (manual_output_files && inputs.size() != outputs.size()) {
std::wcout << L"Input/output filename count mismatch ("
<< inputs.size() << L" inputs, "
<< outputs.size() << L" outputs)." << std::endl;
std::wcout << L"Input/output filename count mismatch (" << inputs.size() << L" inputs, " << outputs.size()
<< L" outputs)." << std::endl;
return false;
}

bool manual_config_files = !config_paths.empty();
if (manual_config_files && inputs.size() != config_paths.size()) {
std::wcout << L"Input filename/config paths count mismatch ("
<< inputs.size() << L" inputs, "
std::wcout << L"Input filename/config paths count mismatch (" << inputs.size() << L" inputs, "
<< config_paths.size() << L" config paths)." << std::endl;
return false;
}
Expand All @@ -32,9 +30,7 @@ bool cli::run(
for (const auto& path : config_paths) {
if (!std::filesystem::exists(path)) {
// TODO: test printing works with unicode
std::cout << "Specified config file path '"
<< path
<< "' not found." << std::endl;
std::cout << "Specified config file path '" << path << "' not found." << std::endl;
return false;
}
}
Expand All @@ -45,8 +41,7 @@ bool cli::run(

if (!std::filesystem::exists(input_path)) {
// TODO: test with unicode
std::wcout << L"Video '" << input_path.wstring()
<< L"' was not found (wrong path?)" << std::endl;
std::wcout << L"Video '" << input_path.wstring() << L"' was not found (wrong path?)" << std::endl;
return false;
}

Expand All @@ -70,7 +65,11 @@ bool cli::run(
rendering.queue_render(render);

if (blur.verbose) {
wprintf(L"Queued '%s' for render, outputting to '%s'\n", render->get_video_name().c_str(), render->get_output_video_path().wstring().c_str());
wprintf(
L"Queued '%s' for render, outputting to '%s'\n",
render->get_video_name().c_str(),
render->get_output_video_path().wstring().c_str()
);
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ int main(int argc, char* argv[]) {
bool preview = false;
bool verbose = false;

app.add_option("-i,--input", inputs, "Input file name(s)")
->required();
app.add_option("-i,--input", inputs, "Input file name(s)")->required();
app.add_option("-o,--output", outputs, "Output file name(s) (optional)");
app.add_option("-c,--config-path", configPaths, "Manual configuration file path(s) (optional)");
app.add_flag("-p,--preview", preview, "Enable preview");
Expand Down
3 changes: 2 additions & 1 deletion src/common/blur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

bool c_blur::initialise(bool _verbose, bool _using_preview) {
path = std::filesystem::path(helpers::get_executable_path()).parent_path(); // folder the exe is in
used_installer = std::filesystem::exists(path / "lib\\vapoursynth\\vspipe.exe") && std::filesystem::exists(path / "lib\\ffmpeg\\ffmpeg.exe");
used_installer = std::filesystem::exists(path / "lib\\vapoursynth\\vspipe.exe") &&
std::filesystem::exists(path / "lib\\ffmpeg\\ffmpeg.exe");

if (!used_installer) {
// didn't use installer, check if dependencies are installed
Expand Down
13 changes: 9 additions & 4 deletions src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ void c_config::create(const std::filesystem::path& filepath, s_blur_settings cur
output << "- timescale" << "\n";
output << "input timescale: " << current_settings.input_timescale << "\n";
output << "output timescale: " << current_settings.output_timescale << "\n";
output << "adjust timescaled audio pitch: " << (current_settings.output_timescale_audio_pitch ? "true" : "false") << "\n";
output << "adjust timescaled audio pitch: " << (current_settings.output_timescale_audio_pitch ? "true" : "false")
<< "\n";

output << "\n";
output << "- filters" << "\n";
Expand All @@ -47,7 +48,8 @@ void c_config::create(const std::filesystem::path& filepath, s_blur_settings cur
output << "\n";
output << "- advanced blur" << "\n";
output << "blur weighting gaussian std dev: " << current_settings.blur_weighting_gaussian_std_dev << "\n";
output << "blur weighting triangle reverse: " << (current_settings.blur_weighting_triangle_reverse ? "true" : "false") << "\n";
output << "blur weighting triangle reverse: "
<< (current_settings.blur_weighting_triangle_reverse ? "true" : "false") << "\n";
output << "blur weighting bound: " << current_settings.blur_weighting_bound << "\n";

output << "\n";
Expand Down Expand Up @@ -96,7 +98,8 @@ s_blur_settings c_config::parse(const std::filesystem::path& config_filepath) {
value = helpers::trim(value);

if (key != "custom ffmpeg filters") {
// remove all spaces in values (it breaks stringstream string parsing, this is a dumb workaround) todo: better solution
// remove all spaces in values (it breaks stringstream string parsing, this is a dumb workaround) todo:
// better solution
std::string::iterator end_pos = std::remove(value.begin(), value.end(), ' ');
value.erase(end_pos, value.end());
}
Expand Down Expand Up @@ -204,7 +207,9 @@ s_blur_settings c_config::get_config(const std::filesystem::path& config_filepat
if (!local_cfg_exists) {
config.create(config_filepath);

wprintf(L"Configuration file not found, default config generated at %s\n", config_filepath.wstring().c_str());
wprintf(
L"Configuration file not found, default config generated at %s\n", config_filepath.wstring().c_str()
);
}

cfg_path = config_filepath;
Expand Down
21 changes: 14 additions & 7 deletions src/common/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@
namespace helpers {
template<typename container_type>
struct enumerate_wrapper {
using iterator_type = std::conditional_t<std::is_const_v<container_type>, typename container_type::const_iterator, typename container_type::iterator>;
using pointer_type = std::conditional_t<std::is_const_v<container_type>, typename container_type::const_pointer, typename container_type::pointer>;
using reference_type = std::conditional_t<std::is_const_v<container_type>, typename container_type::const_reference, typename container_type::reference>;

constexpr enumerate_wrapper(container_type& c)
: container(c) {
}
using iterator_type = std::conditional_t<
std::is_const_v<container_type>,
typename container_type::const_iterator,
typename container_type::iterator>;
using pointer_type = std::conditional_t<
std::is_const_v<container_type>,
typename container_type::const_pointer,
typename container_type::pointer>;
using reference_type = std::conditional_t<
std::is_const_v<container_type>,
typename container_type::const_reference,
typename container_type::reference>;

constexpr enumerate_wrapper(container_type& c) : container(c) {}

struct enumerate_wrapper_iter {
size_t index;
Expand Down
Loading

0 comments on commit fbfbd2e

Please sign in to comment.