Skip to content

Commit 1baad21

Browse files
committed
removed <fstream> requirement for parse_file
also: - fixed false-positive char_8 support detection on older compilers - removed extraneous `TOML_API` declarations
1 parent ac923d8 commit 1baad21

23 files changed

+420
-459
lines changed

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ cpp = 17
4747
Reading it in C++ is easy with toml++:
4848
```cpp
4949
#include <toml.hpp>
50-
#include <fstream> //required for toml::parse_file()
5150

5251
auto config = toml::parse_file( "configuration.toml" );
5352

@@ -98,14 +97,13 @@ You'll find some more code examples in the `examples` directory, and plenty more
9897
2. `#include <toml++/toml.h>`
9998
10099
### Conan
101-
Add `tomlplusplus/2.3.0` to your conanfile.<br>
102-
This adds the single-header version by default, but you can specify the regular version using `"multiple_headers": True`.
100+
Add `tomlplusplus/2.4.0` to your conanfile.
103101
104102
### DDS
105103
Add `tomlpp` to your `package.json5`, e.g.:
106104
```
107105
depends: [
108-
'tomlpp^2.3.0',
106+
'tomlpp^2.4.0',
109107
]
110108
```
111109
> ℹ&#xFE0F; _[What is DDS?](https://dds.pizza/)_
@@ -121,7 +119,7 @@ include(FetchContent)
121119
FetchContent_Declare(
122120
tomlplusplus
123121
GIT_REPOSITORY https://github.com/marzer/tomlplusplus.git
124-
GIT_TAG 0fcbfbe655917738c39321fcbcbdc7b048a40e33
122+
GIT_TAG v2.4.0
125123
)
126124
FetchContent_MakeAvailable(tomlplusplus)
127125
```

docs/pages/main_page.dox

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
///
3535
/// \cpp
3636
/// #include <iostream>
37-
/// #include <fstream> //required for parse_file()
3837
/// #include <toml++/toml.h>
3938
///
4039
/// int main(int argc, char** argv)
@@ -56,15 +55,6 @@
5655
///
5756
/// \ecpp
5857
///
59-
/// \m_class{m-note m-warning}
60-
///
61-
/// \parblock
62-
/// <h3>Don't forget [code]\#include &lt;fstream&gt;[/code]!</h3>
63-
/// Not everyone who uses the library is going to work directly from files, so not everybody is forced to pay
64-
/// the compilation overhead of including `<fstream>`. You need to explicitly include it if you're going to be calling
65-
/// toml::parse_file().
66-
/// \endparblock
67-
///
6858
/// \see
6959
/// - toml::parse_file()
7060
/// - toml::table
@@ -144,7 +134,6 @@
144134
///
145135
/// \cpp
146136
/// #include <iostream>
147-
/// #include <fstream>
148137
///
149138
/// #define TOML_EXCEPTIONS 0 // only necessary if you've left them enabled in your compiler
150139
/// #include <toml++/toml.h>
@@ -437,16 +426,15 @@
437426
//////////////////////////////////
438427
///
439428
/// \subsection mainpage-adding-lib-conan Conan
440-
/// Add `tomlplusplus/2.3.0` to your conanfile. This adds the single-header version by default, but you can specify the
441-
/// regular version using `"multiple_headers": True`.
429+
/// Add `tomlplusplus/2.4.0` to your conanfile.
442430
///
443431
//////////////////////////////////
444432
///
445433
/// \subsection mainpage-adding-lib-dds DDS
446434
/// Add `tomlpp` to your `package.json5`, e.g.:
447435
/// \bash
448436
/// depends: [
449-
/// 'tomlpp^2.3.0',
437+
/// 'tomlpp^2.4.0',
450438
/// ]
451439
/// \ebash
452440
///
@@ -472,7 +460,7 @@
472460
/// FetchContent_Declare(
473461
/// tomlplusplus
474462
/// GIT_REPOSITORY https://github.com/marzer/tomlplusplus.git
475-
/// GIT_TAG 0fcbfbe655917738c39321fcbcbdc7b048a40e33
463+
/// GIT_TAG v2.4.0
476464
/// )
477465
/// FetchContent_MakeAvailable(tomlplusplus)
478466
/// \ebash

docs/poxy.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# https://github.com/marzer/poxy
33

44
name = 'toml++'
5+
author = 'Mark Gillard'
56
description = 'TOML for modern C++'
67
cpp = 17
78
github = 'marzer/tomlplusplus'

examples/simple_parser.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
1010
*/
1111
#include <iostream>
12-
#include <fstream>
1312
#include "utf8_console.h"
1413

1514
#define TOML_UNRELEASED_FEATURES 1

examples/toml_to_json_transcoder.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
1010
*/
1111
#include <iostream>
12-
#include <fstream>
1312
#include "utf8_console.h"
1413

1514
#define TOML_UNRELEASED_FEATURES 1

include/toml++/toml.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ TOML_POP_WARNINGS; // TOML_DISABLE_SPAM_WARNINGS
9393
#undef TOML_GCC
9494
#undef TOML_HAS_ATTR
9595
#undef TOML_HAS_CUSTOM_OPTIONAL_TYPE
96+
#undef TOML_HAS_CHAR8
9697
#undef TOML_HAS_INCLUDE
9798
#undef TOML_ICC
9899
#undef TOML_ICC_CL

include/toml++/toml_array.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ TOML_NAMESPACE_START
238238
return index < elements.size() ? elements[index].get() : nullptr;
239239
}
240240

241-
TOML_API
242241
TOML_EXTERNAL_LINKAGE
243242
bool operator == (const array& lhs, const array& rhs) noexcept
244243
{
@@ -264,7 +263,6 @@ TOML_NAMESPACE_START
264263
return true;
265264
}
266265

267-
TOML_API
268266
TOML_EXTERNAL_LINKAGE
269267
bool operator != (const array& lhs, const array& rhs) noexcept
270268
{

include/toml++/toml_common.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,25 @@ TOML_DISABLE_WARNINGS;
2424
#include <vector>
2525
#include <map>
2626
#include <iosfwd>
27+
#include <new>
2728
#if !TOML_HAS_CUSTOM_OPTIONAL_TYPE
2829
#include <optional>
2930
#endif
30-
#if TOML_HAS_INCLUDE(<version>)
31-
#include <version>
32-
#endif
3331
TOML_ENABLE_WARNINGS;
3432

35-
#ifdef __cpp_lib_launder
33+
#if defined(__cpp_lib_launder) && __cpp_lib_launder >= 201606
3634
#define TOML_LAUNDER(x) std::launder(x)
3735
#else
3836
#define TOML_LAUNDER(x) x
3937
#endif
4038

39+
#if defined(__cpp_char8_t) && __cpp_char8_t >= 201811 \
40+
&& defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201907
41+
#define TOML_HAS_CHAR8 1
42+
#else
43+
#define TOML_HAS_CHAR8 0
44+
#endif
45+
4146
//#====================================================================================================================
4247
//# ENVIRONMENT GROUND-TRUTHS
4348
//#====================================================================================================================
@@ -174,7 +179,7 @@ TOML_NAMESPACE_START // abi namespace
174179
#if TOML_WINDOWS_COMPAT
175180
[[nodiscard]] TOML_API std::string narrow(std::wstring_view) noexcept;
176181
[[nodiscard]] TOML_API std::wstring widen(std::string_view) noexcept;
177-
#ifdef __cpp_lib_char8_t
182+
#if TOML_HAS_CHAR8
178183
[[nodiscard]] TOML_API std::wstring widen(std::u8string_view) noexcept;
179184
#endif
180185
#endif // TOML_WINDOWS_COMPAT
@@ -460,7 +465,7 @@ TOML_IMPL_NAMESPACE_START
460465
template <size_t N> struct value_traits<const char[N]> : string_value_traits<const char[N]> {};
461466
template <> struct value_traits<char*> : string_value_traits<char*> {};
462467
template <size_t N> struct value_traits<char[N]> : string_value_traits<char[N]> {};
463-
#ifdef __cpp_lib_char8_t
468+
#if TOML_HAS_CHAR8
464469
template <> struct value_traits<std::u8string> : string_value_traits<std::u8string> {};
465470
template <> struct value_traits<std::u8string_view> : string_value_traits<std::u8string_view> {};
466471
template <> struct value_traits<const char8_t*> : string_value_traits<const char8_t*> {};
@@ -795,8 +800,6 @@ TOML_NAMESPACE_START
795800
/// \brief A source document region.
796801
///
797802
/// \detail \cpp
798-
/// #include <fstream>
799-
///
800803
/// auto tbl = toml::parse_file("config.toml"sv);
801804
/// if (auto server = tbl.get("server"))
802805
/// {

include/toml++/toml_default_formatter.hpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ TOML_IMPL_NAMESPACE_START
2424
{
2525
inline constexpr size_t default_formatter_line_wrap = 120_sz;
2626

27-
TOML_API
2827
TOML_EXTERNAL_LINKAGE
2928
std::string default_formatter_make_key_segment(const std::string& str) noexcept
3029
{
@@ -69,7 +68,6 @@ TOML_IMPL_NAMESPACE_START
6968
}
7069
}
7170

72-
TOML_API
7371
TOML_EXTERNAL_LINKAGE
7472
size_t default_formatter_inline_columns(const node& node) noexcept
7573
{
@@ -153,7 +151,6 @@ TOML_IMPL_NAMESPACE_START
153151
TOML_UNREACHABLE;
154152
}
155153

156-
TOML_API
157154
TOML_EXTERNAL_LINKAGE
158155
bool default_formatter_forces_multiline(const node& node, size_t starting_column_bias) noexcept
159156
{
@@ -230,7 +227,6 @@ extern "C"
230227

231228
TOML_IMPL_NAMESPACE_START
232229
{
233-
TOML_API
234230
TOML_EXTERNAL_LINKAGE
235231
std::string narrow(std::wstring_view str) noexcept
236232
{
@@ -249,7 +245,6 @@ TOML_IMPL_NAMESPACE_START
249245
return s;
250246
}
251247

252-
TOML_API
253248
TOML_EXTERNAL_LINKAGE
254249
std::wstring widen(std::string_view str) noexcept
255250
{
@@ -266,9 +261,8 @@ TOML_IMPL_NAMESPACE_START
266261
return s;
267262
}
268263

269-
#ifdef __cpp_lib_char8_t
264+
#if TOML_HAS_CHAR8
270265

271-
TOML_API
272266
TOML_EXTERNAL_LINKAGE
273267
std::wstring widen(std::u8string_view str) noexcept
274268
{
@@ -278,7 +272,7 @@ TOML_IMPL_NAMESPACE_START
278272
return widen(std::string_view{ reinterpret_cast<const char*>(str.data()), str.length() });
279273
}
280274

281-
#endif // __cpp_lib_char8_t
275+
#endif // TOML_HAS_CHAR8
282276
}
283277
TOML_IMPL_NAMESPACE_END;
284278

0 commit comments

Comments
 (0)