Skip to content

Commit

Permalink
Format code according to clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
kleisauke committed Jan 18, 2025
1 parent e9527c4 commit 5ee5b69
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
15 changes: 5 additions & 10 deletions src/api/parsers/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ class Query {
public:
explicit Query(const std::string &value);

template <typename E,
typename = std::enable_if_t<std::is_enum_v<E>>>
template <typename E, typename = std::enable_if_t<std::is_enum_v<E>>>
/**
* This is the only function that can pass enums, the other functions do not
* allow this.
Expand All @@ -35,22 +34,19 @@ class Query {
return static_cast<E>(get(key, casted));
}

template <typename T,
typename = std::enable_if_t<!std::is_enum_v<T>>>
template <typename T, typename = std::enable_if_t<!std::is_enum_v<T>>>
const inline T &get(const std::string &key, const T &default_val) const {
auto it = query_map_.find(key);
return it != query_map_.end() ? std::get<T>(it->second) : default_val;
}

template <typename T,
typename = std::enable_if_t<!std::is_enum_v<T>>>
template <typename T, typename = std::enable_if_t<!std::is_enum_v<T>>>
const inline T &get(const std::string &key) const {
const auto &val = query_map_.at(key);
return std::get<T>(val);
}

template <typename T,
typename = std::enable_if_t<!std::is_enum_v<T>>,
template <typename T, typename = std::enable_if_t<!std::is_enum_v<T>>,
typename Predicate>
const inline T &get_if(const std::string &key, Predicate predicate,
const T &default_val) const {
Expand All @@ -66,8 +62,7 @@ class Query {
return query_map_.find(key) != query_map_.end();
}

template <typename T,
typename = std::enable_if_t<!std::is_enum_v<T>>>
template <typename T, typename = std::enable_if_t<!std::is_enum_v<T>>>
inline void update(const std::string &key, const T &val) {
query_map_[key] = val;
}
Expand Down
4 changes: 2 additions & 2 deletions src/api/processors/rotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ using parsers::Color;

VImage Rotation::process(const VImage &image) const {
// Only arbitrary angles are valid
auto rotation = query_->get_if<int>(
"ro", [](int r) { return r % 90 != 0; }, 0);
auto rotation =
query_->get_if<int>("ro", [](int r) { return r % 90 != 0; }, 0);

// Should we process the image?
// Skip for multi-page images
Expand Down
6 changes: 3 additions & 3 deletions src/api/processors/sharpen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ VImage Sharpen::process(const VImage &image) const {
// Slow, accurate sharpen in LAB colour space,
// with control over flat vs jagged areas
return image.sharpen(VImage::option()
->set("sigma", sigma)
->set("m1", flat)
->set("m2", jagged));
->set("sigma", sigma)
->set("m1", flat)
->set("m2", jagged));
}

} // namespace weserv::api::processors
3 changes: 1 addition & 2 deletions src/nginx/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -895,8 +895,7 @@ ngx_int_t ngx_weserv_image_body_filter(ngx_http_request_t *r, ngx_chain_t *in) {
Status status = mc->weserv->process(
ngx_str_to_std(r->args),
std::make_unique<NgxSource>(ctx->image, ctx->last - ctx->image),
std::make_unique<NgxTarget>(r, upstream_ctx, &out),
lc->api_conf);
std::make_unique<NgxTarget>(r, upstream_ctx, &out), lc->api_conf);

// Memory is released immediately after the image output is complete,
// without waiting for the entire response to be sent to the client
Expand Down
3 changes: 2 additions & 1 deletion test/api/exceptions/unit-invalid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ TEST_CASE("invalid image", "[invalid]") {
SECTION("source") {
class InvalidSource : public SourceInterface {
int64_t read(void *data, size_t length) override {
int64_t available = std::min(length, buffer_.size() - read_pos_);
int64_t available =
std::min(length, buffer_.size() - read_pos_);
if (available <= 0) {
return 0;
}
Expand Down

0 comments on commit 5ee5b69

Please sign in to comment.