Skip to content

Commit

Permalink
cleaned up some compiler warning management spam
Browse files Browse the repository at this point in the history
also:
- removed `std::endl` from example code in documentation
- trimmed some fat from the toml.hpp generator
  • Loading branch information
marzer committed Aug 11, 2020
1 parent 2ac7350 commit 40d87de
Show file tree
Hide file tree
Showing 31 changed files with 351 additions and 487 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ for (auto&& [k, v] : config)
{
v.visit([](auto& node) noexcept
{
std::cout << node << std::endl;
std::cout << node << "\n";
if constexpr (toml::is_string<decltype(node)>)
do_something_with_string_values(node);
});
}

// re-serialize as TOML
std::cout << config << std::endl;
std::cout << config << "\n";

// re-serialize as JSON
std::cout << toml::json_formatter{ config } << std::endl;
std::cout << toml::json_formatter{ config } << "\n";


```
Expand Down
1 change: 0 additions & 1 deletion docs/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ PREDEFINED = \
"TOML_DISABLE_SPAM_WARNINGS=" \
"TOML_DISABLE_ARITHMETIC_WARNINGS=" \
"TOML_DISABLE_SHADOW_WARNINGS=" \
"TOML_DISABLE_SUGGEST_WARNINGS=" \
"TOML_DISABLE_WARNINGS=" \
"TOML_ENABLE_WARNINGS=" \
"TOML_POP_WARNINGS=" \
Expand Down
32 changes: 23 additions & 9 deletions docs/main_page.dox
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
/// try
/// {
/// tbl = toml::parse_file(argv[1]);
/// std::cout << tbl << std::endl;
/// std::cout << tbl << "\n";
/// }
/// catch (const toml::parse_error& err)
/// {
/// std::cerr << "Parsing failed:\n" << err << std::endl;
/// std::cerr << "Parsing failed:\n" << err << "\n";
/// return 1;
/// }
///
Expand Down Expand Up @@ -436,19 +436,33 @@
///
//////////////////////////////////
///
/// \subsection mainpage-adding-lib-meson Meson
/// The library supports being added as a subproject in the meson build system.
///
//////////////////////////////////
///
/// \subsection mainpage-adding-lib-conan Conan
/// Add `tomlplusplus/2.0.0` to your conanfile. This adds the single-header version by default, but you can specify the
/// Add `tomlplusplus/2.1.0` to your conanfile. This adds the single-header version by default, but you can specify the
/// regular version using `"multiple_headers": True`.
///
//////////////////////////////////
///
/// \subsection mainpage-adding-lib-dds DDS
/// Add `tomlpp` to your `package.json5`, e.g.:
/// \bash
/// depends: [
/// 'tomlpp^2.1.0',
/// ]
/// \ebash
///
/// \see [What is DDS?](https://dds.pizza/)
///
//////////////////////////////////
///
/// \subsection mainpage-adding-lib-meson Meson
/// The library supports being added as a subproject in the meson build system.
///
//////////////////////////////////
///
/// \subsection mainpage-adding-lib-vcpkg Vcpkg
/// <em>\gh2{microsoft/vcpkg/pull/10786, coming soon...}</em>
/// \bash
/// vcpkg install tomlplusplus
/// \ebash
///
//////////////////////////////////
///
Expand Down
4 changes: 2 additions & 2 deletions examples/simple_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ int main(int argc, char** argv)
try
{
const auto tbl = toml::parse_file(path);
std::cout << tbl << std::endl;
std::cout << tbl << "\n";
}
catch (const toml::parse_error& err)
{
std::cerr << err << std::endl;
std::cerr << err << "\n";
return 1;
}
return 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/toml_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,6 @@ int main(int argc, char** argv)
}
}

std::cout << root << std::endl;
std::cout << root << "\n";
return 0;
}
8 changes: 4 additions & 4 deletions examples/toml_to_json_transcoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ int main(int argc, char** argv)
try
{
const auto table = toml::parse_file(argv[1]);
std::cout << toml::json_formatter{ table } << std::endl;
std::cout << toml::json_formatter{ table } << "\n";
}
catch (const toml::parse_error& err)
{
std::cerr << err << std::endl;
std::cerr << err << "\n";
return 1;
}
}
Expand All @@ -43,11 +43,11 @@ int main(int argc, char** argv)
try
{
const auto table = toml::parse(std::cin, "stdin"sv);
std::cout << toml::json_formatter{ table } << std::endl;
std::cout << toml::json_formatter{ table } << "\n";
}
catch (const toml::parse_error& err)
{
std::cerr << err << std::endl;
std::cerr << err << "\n";
return 1;
}
}
Expand Down
6 changes: 6 additions & 0 deletions include/toml++/toml.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
//# is used as the source for generate_single_header.py.

#include "toml_preprocessor.h"

TOML_PUSH_WARNINGS
TOML_DISABLE_SPAM_WARNINGS

#include "toml_common.h"
#include "toml_date_time.h"
#include "toml_print_to_stream.h"
Expand Down Expand Up @@ -46,6 +50,8 @@

#endif // TOML_IMPLEMENTATION

TOML_POP_WARNINGS // TOML_DISABLE_SPAM_WARNINGS

// macro hygiene
#if TOML_UNDEF_MACROS
#undef TOML_ABI_NAMESPACES
Expand Down
5 changes: 0 additions & 5 deletions include/toml++/toml_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
#pragma once
#include "toml_value.h"

TOML_PUSH_WARNINGS
TOML_DISABLE_SPAM_WARNINGS

TOML_IMPL_NAMESPACE_START
{
template <bool IsConst>
Expand Down Expand Up @@ -1036,5 +1033,3 @@ TOML_NAMESPACE_START
};
}
TOML_NAMESPACE_END

TOML_POP_WARNINGS //TOML_DISABLE_SPAM_WARNINGS
7 changes: 0 additions & 7 deletions include/toml++/toml_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@

#include "toml_array.h"

TOML_PUSH_WARNINGS
TOML_DISABLE_SUGGEST_WARNINGS
TOML_DISABLE_SPAM_WARNINGS

TOML_NAMESPACE_START
{
TOML_EXTERNAL_LINKAGE
Expand Down Expand Up @@ -323,6 +319,3 @@ TOML_NAMESPACE_START
}
}
TOML_NAMESPACE_END

TOML_POP_WARNINGS // TOML_DISABLE_SUGGEST_WARNINGS, TOML_DISABLE_SPAM_WARNINGS

18 changes: 7 additions & 11 deletions include/toml++/toml_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
#pragma once
#include "toml_preprocessor.h"

TOML_PUSH_WARNINGS
TOML_DISABLE_SPAM_WARNINGS

//#====================================================================================================================
//# INCLUDES
//#====================================================================================================================
Expand Down Expand Up @@ -274,8 +271,8 @@ TOML_NAMESPACE_START // abi namespace
/// // desired result: [ [ 42 ] ]
/// auto bad = toml::array{ toml::array{ 42 } }
/// auto good = toml::array{ toml::inserter{ toml::array{ 42 } } }
/// std::cout << "bad: " << bad << std::endl;
/// std::cout << "good:" << good << std::endl;
/// std::cout << "bad: " << bad << "\n";
/// std::cout << "good:" << good << "\n";
/// \ecpp
///
/// \out
Expand Down Expand Up @@ -733,7 +730,7 @@ TOML_NAMESPACE_START
/// auto table = toml::parse_file("config.toml"sv);
/// std::cout << "The node 'description' was defined at "sv
/// << table.get("description")->source().begin()
/// << std::endl;
/// << "\n";
///
/// \ecpp
///
Expand Down Expand Up @@ -807,9 +804,9 @@ TOML_NAMESPACE_START
/// auto tbl = toml::parse_file("config.toml"sv);
/// if (auto server = tbl.get("server"))
/// {
/// std::cout << "begin: "sv << server->source().begin << std::endl;
/// std::cout << "end: "sv << server->source().end << std::endl;
/// std::cout << "path: "sv << *server->source().path << std::endl;
/// std::cout << "begin: "sv << server->source().begin << "\n";
/// std::cout << "end: "sv << server->source().end << "\n";
/// std::cout << "path: "sv << *server->source().path << "\n";
/// }
///
/// \ecpp
Expand Down Expand Up @@ -874,7 +871,7 @@ TOML_NAMESPACE_START
/// \detail \cpp
/// auto arr = toml::array{ 1, 2.0, "3", false };
/// for (size_t i = 0; i < arr.size() i++)
/// std::cout << "Element ["sv << i << "] is: "sv << arr[i].type() << std::endl;
/// std::cout << "Element ["sv << i << "] is: "sv << arr[i].type() << "\n";
///
/// \ecpp
///
Expand Down Expand Up @@ -906,4 +903,3 @@ TOML_NAMESPACE_START
}
TOML_NAMESPACE_END

TOML_POP_WARNINGS // TOML_DISABLE_SPAM_WARNINGS
35 changes: 15 additions & 20 deletions include/toml++/toml_date_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
#pragma once
#include "toml_common.h"

TOML_PUSH_WARNINGS
TOML_DISABLE_SPAM_WARNINGS

TOML_NAMESPACE_START
{
/// \brief A local date.
Expand Down Expand Up @@ -82,7 +79,7 @@ TOML_NAMESPACE_START

/// \brief Prints a date out to a stream as `YYYY-MM-DD` (per RFC 3339).
/// \detail \cpp
/// std::cout << toml::date{ 1987, 3, 16 } << std::endl;
/// std::cout << toml::date{ 1987, 3, 16 } << "\n";
/// \ecpp
///
/// \out
Expand Down Expand Up @@ -173,8 +170,8 @@ TOML_NAMESPACE_START

/// \brief Prints a time out to a stream as `HH:MM:SS.FFFFFF` (per RFC 3339).
/// \detail \cpp
/// std::cout << toml::time{ 10, 20, 34 } << std::endl;
/// std::cout << toml::time{ 10, 20, 34, 500000000 } << std::endl;
/// std::cout << toml::time{ 10, 20, 34 } << "\n";
/// std::cout << toml::time{ 10, 20, 34, 500000000 } << "\n";
/// \ecpp
///
/// \out
Expand Down Expand Up @@ -207,10 +204,10 @@ TOML_NAMESPACE_START
/// \brief Constructs a timezone offset from separate hour and minute totals.
///
/// \detail \cpp
/// std::cout << toml::time_offset{ 2, 30 } << std::endl;
/// std::cout << toml::time_offset{ -2, 30 } << std::endl;
/// std::cout << toml::time_offset{ -2, -30 } << std::endl;
/// std::cout << toml::time_offset{ 0, 0 } << std::endl;
/// std::cout << toml::time_offset{ 2, 30 } << "\n";
/// std::cout << toml::time_offset{ -2, 30 } << "\n";
/// std::cout << toml::time_offset{ -2, -30 } << "\n";
/// std::cout << toml::time_offset{ 0, 0 } << "\n";
///
/// \ecpp
///
Expand Down Expand Up @@ -273,11 +270,11 @@ TOML_NAMESPACE_START

/// \brief Prints a time_offset out to a stream as `+-HH:MM or Z` (per RFC 3339).
/// \detail \cpp
/// std::cout << toml::time_offset{ 2, 30 } << std::endl;
/// std::cout << toml::time_offset{ 2, -30 } << std::endl;
/// std::cout << toml::time_offset{} << std::endl;
/// std::cout << toml::time_offset{ -2, 30 } << std::endl;
/// std::cout << toml::time_offset{ -2, -30 } << std::endl;
/// std::cout << toml::time_offset{ 2, 30 } << "\n";
/// std::cout << toml::time_offset{ 2, -30 } << "\n";
/// std::cout << toml::time_offset{} << "\n";
/// std::cout << toml::time_offset{ -2, 30 } << "\n";
/// std::cout << toml::time_offset{ -2, -30 } << "\n";
/// \ecpp
///
/// \out
Expand Down Expand Up @@ -405,9 +402,9 @@ TOML_NAMESPACE_START

/// \brief Prints a date_time out to a stream in RFC 3339 format.
/// \detail \cpp
/// std::cout << toml::date_time{ { 1987, 3, 16 }, { 10, 20, 34 } } << std::endl;
/// std::cout << toml::date_time{ { 1987, 3, 16 }, { 10, 20, 34 }, { -2, -30 } } << std::endl;
/// std::cout << toml::date_time{ { 1987, 3, 16 }, { 10, 20, 34 }, {} } << std::endl;
/// std::cout << toml::date_time{ { 1987, 3, 16 }, { 10, 20, 34 } } << "\n";
/// std::cout << toml::date_time{ { 1987, 3, 16 }, { 10, 20, 34 }, { -2, -30 } } << "\n";
/// std::cout << toml::date_time{ { 1987, 3, 16 }, { 10, 20, 34 }, {} } << "\n";
/// \ecpp
///
/// \out
Expand All @@ -427,5 +424,3 @@ TOML_NAMESPACE_START
#endif
}
TOML_NAMESPACE_END

TOML_POP_WARNINGS // TOML_DISABLE_SPAM_WARNINGS
7 changes: 3 additions & 4 deletions include/toml++/toml_default_formatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

TOML_PUSH_WARNINGS
TOML_DISABLE_SWITCH_WARNINGS
TOML_DISABLE_SPAM_WARNINGS

TOML_IMPL_NAMESPACE_START
{
Expand All @@ -37,8 +36,8 @@ TOML_NAMESPACE_START
/// }};
///
/// // these two lines are equivalent:
/// std::cout << toml::default_formatter{ tbl } << std::endl;
/// std::cout << tbl << std::endl;
/// std::cout << toml::default_formatter{ tbl } << "\n";
/// std::cout << tbl << "\n";
///
/// \ecpp
///
Expand Down Expand Up @@ -401,5 +400,5 @@ TOML_NAMESPACE_START
}
TOML_NAMESPACE_END

TOML_POP_WARNINGS // TOML_DISABLE_SWITCH_WARNINGS, TOML_DISABLE_SPAM_WARNINGS
TOML_POP_WARNINGS // TOML_DISABLE_SWITCH_WARNINGS

3 changes: 1 addition & 2 deletions include/toml++/toml_default_formatter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ TOML_ENABLE_WARNINGS
TOML_PUSH_WARNINGS
TOML_DISABLE_SWITCH_WARNINGS
TOML_DISABLE_ARITHMETIC_WARNINGS
TOML_DISABLE_SPAM_WARNINGS

TOML_IMPL_NAMESPACE_START
{
Expand Down Expand Up @@ -268,4 +267,4 @@ TOML_IMPL_NAMESPACE_END

#endif // TOML_WINDOWS_COMPAT

TOML_POP_WARNINGS // TOML_DISABLE_SWITCH_WARNINGS, TOML_DISABLE_ARITHMETIC_WARNINGS, TOML_DISABLE_SPAM_WARNINGS
TOML_POP_WARNINGS // TOML_DISABLE_SWITCH_WARNINGS, TOML_DISABLE_ARITHMETIC_WARNINGS
3 changes: 1 addition & 2 deletions include/toml++/toml_formatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

TOML_PUSH_WARNINGS
TOML_DISABLE_SWITCH_WARNINGS
TOML_DISABLE_SPAM_WARNINGS

TOML_NAMESPACE_START
{
Expand Down Expand Up @@ -251,4 +250,4 @@ TOML_IMPL_NAMESPACE_START
}
TOML_IMPL_NAMESPACE_END

TOML_POP_WARNINGS // TOML_DISABLE_SWITCH_WARNINGS, TOML_DISABLE_SPAM_WARNINGS
TOML_POP_WARNINGS // TOML_DISABLE_SWITCH_WARNINGS
Loading

0 comments on commit 40d87de

Please sign in to comment.