ToruNiina
db1f42b5da
fix: enable to control macro definition
2021-04-02 17:21:25 +09:00
ToruNiina
14c6430dda
Merge branch 'master' into auto-conversion-macro
2021-04-02 16:25:41 +09:00
ToruNiina
a3b8dd6787
fix( #152 ): add newline btw kv-pair and subtables
2021-03-31 10:52:18 +09:00
ToruNiina
c121492071
fix: uneven spacing between tables
...
related: issue #152
2021-03-29 17:48:03 +09:00
ToruNiina
b924e70e3c
feat: add a simple way to disable <filesystem>
...
As jwillikers pointed out in #150 , there is a case where compiler
defines the corresponding feature test macro of <filesystem> but is
actually not available. The macro is a way to disable the feature
regardless of the status of feature test macro.
2021-03-25 11:44:11 +09:00
sneakypete81
08859c36d0
Fix typo in error message
2021-01-30 20:04:00 +00:00
Alex Merry
db2d33ca4b
Add missing header for std::out_of_range exception
...
Failure seen on GCC 4.8.5 when including "toml/value.hpp".
2020-12-09 10:39:10 +00:00
Alex Merry
935da51769
Add missing include for ostringstream
...
Since region.hpp no longer includes <iostream> (but only <iomanip>),
source_location.hpp no longer includes a header that provides
std::ostringstream. Including <sstream> fixes this.
2020-12-09 10:19:07 +00:00
ToruNiina
9b472a6c72
fix: check it is empty before calling back
2020-11-04 23:24:59 +09:00
ToruNiina
1ead14589e
fix: check if it is empty before calling back()
2020-11-04 23:24:02 +09:00
ToruNiina
a6581ee66b
fix: an empty array is not an array of table
2020-11-03 20:34:01 +09:00
ToruNiina
908b91079b
fix: distinguish the comments and try to keep it
...
If a value has a comment, we need to try to write it explicitly.
2020-10-18 20:43:33 +09:00
ToruNiina
fce6ff317e
refactor: distinguish the reason of failure
2020-10-18 18:36:05 +09:00
ToruNiina
fd50b11523
refactor: add write_comments()
2020-10-18 18:35:56 +09:00
ToruNiina
9090b8273c
refactor: move array-of-table stuff to a function
2020-10-18 17:20:06 +09:00
ToruNiina
88882b523f
feat: add a macro defines convertion automatically
2020-10-16 21:40:47 +09:00
ToruNiina
382e3dc3ab
refactor: use serializer::is_array_of_tables
2020-10-14 22:27:29 +09:00
ToruNiina
f7bfcdd7aa
fix: check all the elements in an array
...
while checking if the array is array-of-tables or not (heterogeneous
arrays are allowed, so there might be an array that has a table and
an integer at the same time)
2020-10-14 18:00:04 +09:00
ToruNiina
2e41a26785
Merge branch 'master' of github.com:ToruNiina/toml11 into master
2020-10-14 15:35:18 +09:00
ToruNiina
f283a257d2
Revert "quick temporary patch for comment dup"
...
This reverts commit a6d38c1ec0
.
Since the problem is solved, we don't need this patch any more.
2020-10-13 22:02:32 +09:00
ToruNiina
3d86f3a4e1
fix: avoid comment duplication in array of tables
2020-10-13 21:59:46 +09:00
ToruNiina
dc5a8069a9
refactor: require comments while construction
...
Note: at this commit, the code would not compile.
2020-10-13 21:58:08 +09:00
Ivan Shynkarenka
5d8c573357
Fixed: Compile toml11 with MinGW cause error in <filesystem> #136
2020-10-03 23:16:58 +03:00
Ivan Shynkarenka
6e1e5ccd84
Fixed: Compile toml11 with MinGW cause error in <filesystem> #136
2020-10-03 23:06:47 +03:00
Ivan Shynkarenka
f2d9fd1d1f
Fixed: Compile toml11 with MinGW cause error in <filesystem> #136
2020-10-03 22:36:59 +03:00
Ivan Shynkarenka
97c8cbdaf5
Fixed: Compile toml11 with MinGW cause error in <filesystem> #135
2020-10-02 19:10:04 +03:00
ToruNiina
05ceb5ae79
fix: workaround for error around SFINAE in MSVC
...
avoid lambda with template argument
2020-09-29 02:26:16 +09:00
ToruNiina
0fec125688
feat: remove default value from internal src
2020-09-29 01:40:49 +09:00
ToruNiina
a6d38c1ec0
fix: add a quick temporary patch for comment dup
...
first aid for #131
2020-09-22 17:36:24 +09:00
ToruNiina
670186fac7
Merge branch 'master' into allow-comment-before-comma
2020-09-19 18:10:45 +09:00
ToruNiina
a32cd6cb61
feat: enable to use u8""_toml literal in C++20
2020-09-16 21:24:03 +09:00
ToruNiina
003bc16c1b
fix: skip the last zero in the file
2020-09-14 16:35:51 +09:00
ToruNiina
5f38127692
feat: allow comments before comma
...
replace ws by ws_comment_newline, as suggested.
discussed here: toml-lang/toml/issues/766
2020-08-16 11:03:58 +09:00
ToruNiina
3c3ebd88b4
feat: improve error message about invalid keys
2020-08-09 18:38:50 +09:00
ToruNiina
08f7ea9c56
refactor: remove extraneous whitespaces in errmsg
2020-08-09 18:38:21 +09:00
ToruNiina
cde29399f4
fix: use 1 in source_location as the default pos
2020-08-07 22:24:01 +09:00
ToruNiina
4fa94d45b3
fix: use const char* instead of &char[N]
...
to enable to pass char*, not only string literal
2020-08-04 20:08:58 +09:00
ToruNiina
4e6ae9a994
refactor: avoid string construct in format_ul
2020-07-30 16:11:35 +09:00
ToruNiina
f23c003d2f
fix: add missing namespace specifier
2020-07-28 00:04:25 +09:00
ToruNiina
4b719f0806
refactor: use location() instead of get_region
2020-07-27 23:15:14 +09:00
ToruNiina
22ace027de
refactor: rm template from detail::change_region
2020-07-27 23:04:24 +09:00
ToruNiina
bc219af5b5
refactor: use location() member instead of ctor
2020-07-27 23:03:33 +09:00
ToruNiina
68e8a31659
refactor: remove needless addressof() call
2020-07-27 23:00:40 +09:00
ToruNiina
32a5341d09
refactor: use source_location, not region_base*
2020-07-27 22:29:18 +09:00
ToruNiina
ce68f6f4c2
refactor: check (always-valid) ptr before deref
2020-07-27 21:32:35 +09:00
ToruNiina
e696aabd11
refactor: change internal interface to reduce code
...
to remove `std::addressof` calls, get_region(toml::value) now
returns a pointer to region.
2020-07-27 00:48:04 +09:00
ToruNiina
7fb93e2f54
fix: add missing explicit
to detail::region
2020-07-27 00:20:26 +09:00
ToruNiina
19cc9a2edf
refactor: remove template from detail::region
2020-07-25 22:01:34 +09:00
ToruNiina
72f5afb6af
refactor: remove template from detail::location
2020-07-25 21:06:26 +09:00
ToruNiina
a8fa14d159
refactor: remove vec() method, use a constructor
2020-07-21 20:55:18 +09:00
ToruNiina
75999aa9ad
refactor: add a constructor to location
...
By adding the constructor, vec() would not be not needed. But inserting
Container = std::string makes the constructor ambiguous, so it breaks
the current code.
2020-07-21 20:53:44 +09:00
ToruNiina
259da54edb
refactor: always use vector<char> in location
...
`location` and `region` have a (shared_ptr to the) container of TOML
contents. Those take a template argument to allow both std::vector<char>
and std::string as an interanal container. But since those are internal
feature, i.e. it should not be used by a user directly, this template
can be removed by re-writing a parser a bit. This introduces a
complexity to toml11 error reporting system, so I'm removing this.
First, remove all the location<std::string> from the parser. Then the
template argument can be removed because everyone uses std::vector<char>
now.
2020-07-20 19:52:11 +09:00
ToruNiina
b461f363da
refactor: add a method to reduce complexity later
2020-07-20 19:40:55 +09:00
ToruNiina
4e0624aa60
feat: make sure the last null is removed
2020-07-19 16:56:31 +09:00
ToruNiina
3ac2c065eb
Merge branch 'reorder-headers' to master
2020-07-17 15:17:40 +09:00
ToruNiina
470f81dc94
fix : #123 merge branch 'windows-nominmax'
2020-07-10 20:55:53 +09:00
ToruNiina
761e576991
fix: workaround for windows.h that defines min/max
...
related to #123
2020-07-10 15:07:13 +09:00
ToruNiina
e6e84714c5
Merge branch 'master' into reorder-headers
2020-07-10 00:06:22 +09:00
Marius Maaß
92aa42a58e
Fix MSVC warning C4866
...
This fixes the warning "compiler may not enforce left-to-right
evaluation order for call to" that is caused by Visual Studio if this is
compiled with a target of C++17.
2020-07-03 08:00:47 +02:00
ToruNiina
b1c9df8998
feat: reorder headers following google c++ style
...
related to: #115
2020-06-28 00:58:20 +09:00
ToruNiina
57c6652360
Merge branch 'master' into std-filesystem
2020-06-06 17:25:26 +09:00
ToruNiina
defde33544
fix: avoid ambiguity in overload resolution
...
Since both `std::string` and `std::filesystem::path` can be convertible
from `const char &[N]` (like, `parse("file.toml")`), after adding
`parse(std::filesystem::path)`, the overload resolution of
`parse("file.toml")` becomes ambiguous. By adding `parse(...)` that
exactly matches to `parse("file.toml")`, we can remove this ambiguity.
2020-06-06 17:18:02 +09:00
ToruNiina
46ed051740
fix: pass path.string as a filename
2020-06-05 23:15:19 +09:00
ToruNiina
2963d9a25b
feat: add std::filesystem::path support
2020-06-05 19:43:23 +09:00
Scott McCaskill
57d4e196a3
when parsing a local_time, parse up to 9 digits worth (nanoseconds) of fractional seconds
2020-05-10 16:06:52 -05:00
ToruNiina
125f608fa5
feat: remove TOML11_UNRELEASED_FEATURES.
...
v1.0.0-rc.1 has been released
2020-04-03 23:42:58 +09:00
ToruNiina
79594709fe
fix: don't use default ctor when converting to map
2020-03-30 15:02:26 +09:00
ToruNiina
95c3b5f538
feat: use push_back instead of resize
2020-03-27 18:06:26 +09:00
ToruNiina
9b52dc0131
feat: remove resize and add try_reserve
2020-03-27 18:05:31 +09:00
ToruNiina
5212992f05
feat: add is_std_forward_list
...
std::forward_list does not have push_back, insert, or emplace but
push_front, insert_after, and emplace_after. We need to distinguish it
from other continers.
2020-03-27 18:02:37 +09:00
ToruNiina
fcd6e47500
feat: add meta funcs, has_reserve/push_back_method
2020-03-27 18:01:47 +09:00
ToruNiina
31826b55ce
feat: avoid double checking in helper methods
2020-03-25 22:49:19 +09:00
ToruNiina
d7662347f2
refactor: shorten switch_cast definition by macro
2020-03-21 17:44:23 +09:00
ToruNiina
5f5539d402
feat: throw informative error from value.at(...)
2020-03-21 17:09:04 +09:00
ToruNiina
c2151cab0b
refactor: show func name in bad_cast from helpers
2020-03-21 17:06:34 +09:00
ToruNiina
653c87592c
feat: enable to show function name in bad_cast
2020-03-21 17:04:05 +09:00
ToruNiina
bdf4e75122
refactor: move helper function from get to value
2020-03-21 16:57:12 +09:00
ToruNiina
af8cf9ddc5
refactor: remove redundant functions in serializer
2020-03-13 13:55:14 +09:00
ToruNiina
f125cca010
refactor: simplify serializer's template argument
2020-03-12 13:46:17 +09:00
ToruNiina
d11e42ca7e
fix: explicitly say the table is top-level
...
The top-level table has its region at the first character of the file.
That means that, in the case when a key is not found in the top-level
table, the error message points to the first character. If the file has
its first table at the first line, the error message would be like this.
```console
[error] key "a" not found
--> example.toml
|
1 | [table]
| ^------ in this table
```
It actually points to the top-level table at the first character,
not `[table]`. But it is too confusing. To avoid the confusion, the
error message should explicitly say "key not found in the top-level
table".
2020-02-29 22:56:29 +09:00
ToruNiina
128b66bda9
refactor: add missing whitespace
2020-02-29 22:54:50 +09:00
ToruNiina
d1af42f151
refactor: add throw_key_not_found_error
...
and replace related throw statements with it
2020-02-29 22:23:15 +09:00
ToruNiina
5e3ffb70dd
fix: check clang macro when checking gcc is used
2020-02-19 17:00:22 +09:00
ToruNiina
82fec38e37
refactor: simplify internally-used function
2020-02-19 15:46:25 +09:00
ToruNiina
189b910384
fix: solve #97 in the naivest way, macros
2020-02-19 15:44:38 +09:00
Jordan Williams
6b5944e839
fix -Wundef warnings
2020-02-11 06:30:18 -06:00
Jordan Williams
3b6417de00
fix clang range-loop-analysis warnings
2020-02-11 06:13:55 -06:00
ToruNiina
f6a41d986c
feat: handle quotes in strings in the better way
...
- if a basic string contains any double quote, make it multiline.
- because 1 or 2 consecutive "s do not require escape sequence in it.
- if a basic string will be sufficiently long, make it multiline.
- if 3 consecutive "s appeared, insert backslash to break it down.
2020-02-05 22:42:10 +09:00
ToruNiina
16fc172b21
feat: check string length before adding newline
...
In literal strings, only the first newline will be trimmed.
```toml
str = '''
The first newline will be trimmed.'''
```
The previous code always adds this first-newline, but after this commit
it checks the length of the string and adds newline if the string is
sufficiently long.
2020-02-05 22:39:08 +09:00
ToruNiina
0582e1535b
fix: handle edge-cases with quotes in ml-string
...
See comments in the code for detail.
2020-02-04 22:36:39 +09:00
ToruNiina
5ca3a3c262
refactor: change ifdef UNRELEASED_FEATURE region
...
to eliminate dead code after returning from a function
2020-02-04 21:05:03 +09:00
ToruNiina
49fdb61731
refactor: add explicit to ctors of internal types
2020-01-24 15:58:24 +09:00
ToruNiina
0c58549fc6
Merge branch 'master' of github.com:ToruNiina/toml11
2020-01-22 12:20:34 +09:00
ToruNiina
22d630fec1
feat: replace detail::stuff by std if possible
2020-01-20 12:18:05 +09:00
ToruNiina
f7bf341452
fix: add missing noexcept specifier
2020-01-19 21:06:10 +09:00
ToruNiina
0934d90f90
refactor: move ctors that are only used internally
2020-01-19 18:30:27 +09:00
ToruNiina
f2c8d0e279
refactor: add missing explicit to toml::exception
2020-01-19 17:51:24 +09:00
ToruNiina
8b737dc21f
feat: add member methods to toml::value
2020-01-16 20:58:10 +09:00
ToruNiina
9bef715ccd
fix: use u32 as a result of binary operation
2020-01-13 11:26:53 +09:00
ToruNiina
d2b1cf5123
refactor: just use a constructor
...
to remove conversions
2020-01-13 11:26:29 +09:00
ToruNiina
9f92916d1d
fix: suppress -Wuseless-conversion
...
`{integer} + 1` will automatically be an int, so static_cast<int>(a+1)
will be useless conversion.
2020-01-13 11:24:48 +09:00
ToruNiina
666e4cf9dc
fix: suppress sign-conversion warnings
2020-01-13 00:46:21 +09:00
ToruNiina
490abe04fd
refactor: remove redundant template argument
2020-01-12 23:07:17 +09:00
ToruNiina
81ed4c0e9d
Merge branch 'master' of github.com:ToruNiina/toml11
2020-01-10 21:17:17 +09:00
ToruNiina
55260654bf
feat: get user-defined value by constructor
...
If a user-defined constructor has constructor(const toml::value&),
then it should be convertible in `toml::get` and `toml::find`.
2020-01-10 20:38:52 +09:00
ToruNiina
c54a03f189
Merge branch 'master' into find-idx
2020-01-09 00:27:51 +09:00
ToruNiina
7f020f3f44
refactor: remove error prefix
...
that will automatically be added in format_underline
2020-01-07 22:27:13 +09:00
ToruNiina
827b433389
Merge branch 'master' into find-idx
2020-01-07 22:13:15 +09:00
ToruNiina
18f84088b4
perf: avoid tmp str construction while checking
2019-12-19 22:13:47 +09:00
ToruNiina
c199bd8b49
feat: enable to access the 1st char of region
2019-12-19 22:13:33 +09:00
ToruNiina
5b35c1a74e
fix: prohibit modification on inline table
...
According to toml-lang/toml:36d3091b3 "Clarify that inline tables are
immutable", check if it adds key-value pair to an inline table.
This is one of the unreleased (after-0.5.0) toml feature. But this is
marked as "Clarify", so TOML-lang intended that inline tables are
immutable in all version.
2019-12-19 22:02:17 +09:00
ToruNiina
d3513c0f84
fix: fmt line num in err msg correctly
2019-12-17 19:35:26 +09:00
ToruNiina
4688c235f5
refactor: rename internal macro value
2019-12-12 17:38:29 +09:00
ToruNiina
5c146857a3
Merge branch 'master' into colorize-err-msg
2019-12-11 22:49:38 +09:00
ToruNiina
bc51699415
Merge branch 'bracket-operator'
2019-12-11 19:36:21 +09:00
OGAWA KenIchi
3190c1da9f
fix: suppress warning on Intel C++ Compiler
2019-12-11 17:47:16 +09:00
ToruNiina
8fbeaabfd9
feat: add operator[] to access table/array
2019-12-10 00:00:05 +09:00
ToruNiina
331de4ea5d
fix: use datetime info while getting time offset
...
to convert offset_datetime to system_clock::time_point.
2019-12-08 22:44:12 +11:00
ToruNiina
b246f5ac5c
fix: combine date and time to convert loc datetime
...
Normally DST begins at A.M. 3 or 4. If we re-use conversion operator
of local_date and local_time independently, the conversion fails if
it is the day when DST begins or ends. Since local_date considers the
time is 00:00 A.M. and local_time does not consider DST because it
does not have any date information. We need to consider both date and
time information at the same time to convert it correctly.
2019-12-08 22:38:49 +11:00
ToruNiina
62c01f9826
fix: consider timezone correctly
...
explicitly set tm.tm_isdst = 0 and use UTC offset
2019-12-06 20:57:51 +09:00
ToruNiina
5a8d368927
feat: add thread-safe detail::gmtime_s
2019-12-06 20:33:15 +09:00
blockparty
6d41a1adb9
Suppress unused variable warning
2019-11-22 05:59:55 -06:00
blockparty
7e62dad6dc
Check if features are defined
2019-11-21 05:51:31 -06:00
ToruNiina
2fd466a3c3
fix: skip only the prefix, keep spaces
2019-11-14 15:32:17 +09:00
ToruNiina
6f7539dc6a
fix: deduplicate [error] prefix in the messages
2019-11-14 15:31:27 +09:00
ToruNiina
f290390c63
fix: consider the no-space cases like [error]:
2019-11-13 18:14:42 +09:00
ToruNiina
571baa2c26
refactor: remove nocolor:: operations
...
since color can be on-off at runtime
2019-11-13 18:08:31 +09:00
ToruNiina
bbe33e87d9
feat: detect [error] prefix duplication
2019-11-13 18:05:37 +09:00
ToruNiina
4c5076f263
feat: add runtime colorize flag
2019-11-13 18:01:47 +09:00
ToruNiina
d47174954f
feat: colorize user-defined msg by format_error
2019-11-13 18:00:55 +09:00
ToruNiina
821eb9632b
feat: add a macro-dependent constant
2019-11-13 17:59:47 +09:00
ToruNiina
af116991b6
fix: remove overlapping [error] sign
2019-11-13 17:35:23 +09:00
ToruNiina
87bebbc37d
feat: put color to the internal error messages
2019-11-13 17:35:05 +09:00
ToruNiina
c2d0351e69
feat: add (ANSI) terminal colorize operators
2019-11-13 17:24:51 +09:00
ToruNiina
1526b9feee
Merge branch 'heterogeneous-array'
2019-11-09 11:03:18 +09:00
ToruNiina
adf8fa9234
fix: fix typos in an error message in toml::get
...
when converting toml::value to std::tuple
2019-11-08 16:12:18 +09:00
ToruNiina
9af2d65417
feat: allow heterogenous array
...
if TOML11_USE_UNRELEASED_TOML_FEATURES is activated.
In TOML v0.5.0, heterogenous arrays are not allowed. But after some
discussions in toml-lang/toml, it is decided to allow it in the next
release (toml-lang/toml/pull/676).
To support it, disable type check in parse_array function.
2019-11-08 15:36:58 +09:00
ToruNiina
8240fffeca
Merge branch 'master' into add-src-loc-to-exception
2019-11-02 12:53:16 +09:00
ToruNiina
047611764c
fix: silly typo
2019-11-01 21:15:20 +09:00
ToruNiina
bc3eb9d967
feat: add src_loc to all the exceptions
...
including internal_error.
2019-11-01 21:14:33 +09:00
ToruNiina
6862264bde
feat: use the first char as the top-level region
...
A bit related to #89
2019-11-01 20:47:25 +09:00
ToruNiina
2ee69fc420
fix: improve error messages about strings a bit
2019-11-01 13:34:15 +09:00
ToruNiina
6a15e8360f
refactor: remove redundant namespace specifier
2019-10-31 23:13:49 +09:00
ToruNiina
41eb1d6887
feat: pass source_location to exception
2019-10-31 22:23:31 +09:00
ToruNiina
3ca712a8da
feat: check line_num before converting it to int
2019-10-31 22:21:24 +09:00
ToruNiina
8e589ff4d7
feat: add source_location to (syntax_|type_)error
2019-10-31 22:04:16 +09:00
ToruNiina
56812114c3
refactor: simplify inclusion dependencies
2019-10-31 21:58:28 +09:00
ToruNiina
f98615d0df
fix: check file content is empty or not
2019-10-30 16:49:49 +09:00
ToruNiina
37769e28f0
fix #88 : check if input is null-terminated or not
2019-10-30 16:33:22 +09:00
ToruNiina
258e62f8f3
feat: add operator+= to toml::string
2019-10-09 21:51:14 +09:00