Skip to content

Commit

Permalink
Update vendor
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed Jun 22, 2024
1 parent 7f852c5 commit 2d2489b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

// pqrs::json v1.6
// pqrs::json v1.7

// (C) Copyright Takayama Fumihiko 2019.
// Distributed under the Boost Software License, Version 1.0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ namespace pqrs_formatter {
// ```

struct options {
int indent_size;
std::optional<int> indent_size;
std::optional<nlohmann::json::error_handler_t> error_handler;
std::unordered_set<std::string> force_multi_line_array_object_keys;
};

Expand Down Expand Up @@ -116,7 +117,7 @@ inline bool multi_line(const T& json,
inline void indent(std::ostringstream& ss,
const options& options,
int indent_level) {
for (int i = 0; i < options.indent_size * indent_level; ++i) {
for (int i = 0; i < options.indent_size.value_or(4) * indent_level; ++i) {
ss << ' ';
}
}
Expand Down Expand Up @@ -243,7 +244,10 @@ inline void format(std::ostringstream& ss,
ss << ']';
}
} else {
ss << json;
ss << json.dump(0,
' ',
false,
options.error_handler.value_or(nlohmann::json::error_handler_t::strict));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

// pqrs::json v1.6
// pqrs::json v1.7

// (C) Copyright Takayama Fumihiko 2019.
// Distributed under the Boost Software License, Version 1.0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ namespace pqrs_formatter {
// ```

struct options {
int indent_size;
std::optional<int> indent_size;
std::optional<nlohmann::json::error_handler_t> error_handler;
std::unordered_set<std::string> force_multi_line_array_object_keys;
};

Expand Down Expand Up @@ -116,7 +117,7 @@ inline bool multi_line(const T& json,
inline void indent(std::ostringstream& ss,
const options& options,
int indent_level) {
for (int i = 0; i < options.indent_size * indent_level; ++i) {
for (int i = 0; i < options.indent_size.value_or(4) * indent_level; ++i) {
ss << ' ';
}
}
Expand Down Expand Up @@ -243,7 +244,10 @@ inline void format(std::ostringstream& ss,
ss << ']';
}
} else {
ss << json;
ss << json.dump(0,
' ',
false,
options.error_handler.value_or(nlohmann::json::error_handler_t::strict));
}
}

Expand Down

0 comments on commit 2d2489b

Please sign in to comment.