Skip to content

Commit f9ee400

Browse files
committed
Format code.
Signed-off-by: LebJe <51171427+LebJe@users.noreply.github.com>
1 parent 30598e4 commit f9ee400

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

CHANGELOG.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [0.4.1](https://github.com/LebJe/toml.lua/releases/tag/0.4.1) - 2024-11-19
99

1010
### Fixed
11-
- The formatting options that were passed as a parameter to `toml.encode`, `toml.encodeToFile`, `toml.toJSON`, and `toml.toYAML` previously had no effect when overriding values.
12-
- Resolved CMake `FetchContent_Populate` warning.
11+
12+
- The formatting options that were passed as a parameter to `toml.encode`, `toml.encodeToFile`, `toml.toJSON`, and `toml.toYAML` previously had no effect when overriding values.
13+
- Resolved CMake `FetchContent_Populate` warning.
1314

1415
### Changed
16+
1517
- Updated to magic_enum v0.9.7.
1618

1719
### Added
18-
- Added tests for encoding options.
20+
21+
- Added tests for encoding options.
1922

2023
## [0.4.0](https://github.com/LebJe/toml.lua/releases/tag/0.4.0) - 2024-01-02
2124

src/utilities/utilities.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,26 +106,27 @@ toml::format_flags tableToFormatFlags(sol::optional<sol::table> t) {
106106

107107
// User passed an empty table to clear all flags.
108108
if (table.empty()) return flags;
109-
109+
110110
// Set default flags, and allow user to override
111111
std::map<format_flags, bool> userFlags = defaultFlags;
112-
112+
113113
for (auto [flag, enabled] : userFlags) {
114114
std::string camelCaseFlagName = camelCase(magic_enum::enum_name(flag));
115115
if (table[camelCaseFlagName].valid()) {
116116
userFlags[flag] = table[camelCaseFlagName].get<bool>();
117117
}
118118
}
119-
120-
// `format_flags::indentation` is returned as an empty string from `magic_enum::enum_name`, so we must handle it separately.
119+
120+
// `format_flags::indentation` is returned as an empty string from `magic_enum::enum_name`, so
121+
// we must handle it separately.
121122
if (table["indentation"].valid()) {
122123
userFlags[toml::format_flags::indentation] = table["indentation"].get<bool>();
123124
}
124-
125+
125126
for (auto [flag, enabled] : userFlags) {
126127
if (enabled) flags |= flag;
127128
}
128-
129+
129130
return flags;
130131
}
131132

src/utilities/utilities.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ std::string parseErrorToString(toml::parse_error e);
3636
/// Inserts the values in `e` into `table`.
3737
void parseErrorToTable(toml::parse_error e, sol::table & table);
3838

39-
/// Takes a Lua table, with keys representing flag names, and values, and converts it to `toml::format_flags`.
40-
/// If the table is nil, all format flags are set to their default value, if the table is empty, `toml::format_flags` is set to none.
39+
/// Takes a Lua table, with keys representing flag names, and values, and converts it to
40+
/// `toml::format_flags`. If the table is nil, all format flags are set to their default value, if
41+
/// the table is empty, `toml::format_flags` is set to none.
4142
toml::format_flags tableToFormatFlags(sol::optional<sol::table> t);
4243

4344
Options tableToOptions(sol::optional<sol::table> t);
@@ -56,9 +57,8 @@ std::optional<std::string> keyToString(sol::object key);
5657
/// If a string is not on the stack, then an integer from `luaL_argerror` is returned.
5758
std::variant<int, toml::table *> getTableFromStringInState(sol::state_view state, int index = 1);
5859

59-
template <>
60-
struct magic_enum::customize::enum_range<toml::format_flags> {
61-
static constexpr bool is_flags = true;
60+
template <> struct magic_enum::customize::enum_range<toml::format_flags> {
61+
static constexpr bool is_flags = true;
6262
};
6363

6464
#endif /* UTILITIES_H */

tests/tests.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ end
3232
function TestEncoder:testEncodingOptions()
3333
local terseKeysToml = read("tests/test-data/encoding/terseKeys+qoutedTimestamps.toml")
3434

35-
lu.assertEquals(toml.encode(toml.decode(terseKeysToml), { terseKeyValuePairs = true, quoteDatesAndTimes = true }), terseKeysToml)
35+
lu.assertEquals(
36+
toml.encode(toml.decode(terseKeysToml), { terseKeyValuePairs = true, quoteDatesAndTimes = true }),
37+
terseKeysToml
38+
)
3639

3740
local noIndentationJSON = read("tests/test-data/encoding/noIndentation.json")
3841

3942
lu.assertEquals(toml.toJSON(toml.decode(terseKeysToml), { indentation = false }), noIndentationJSON)
40-
4143
end
4244

4345
function TestDecoder:testDecodeSamples()

0 commit comments

Comments
 (0)