Variables can be automatically moved when a function returns. However,
declaring a variable as const prevents that move from occuring (as the
move modifies the moved-from variable).
This makes attribute_value and lexical_cast use the "new" to/from_chars api.
Its main advantages are:
- It's guaranteed to be locale independent, hopefully fixing all cases of #3945 and similar
- It fixes some cases config serialization, in particular the test
```
cfg["x"] = "9.87654321";
BOOST_CHECK_EQUAL(cfg["x"], 9.87654321);
```
- Previously the lexical_cast implementation used exception
handling for invalid formats (catching std::invalid_argument)
which made noise during debugging (and is also slower if it
is not optimized out).
- It's faster
So far afaik the only compiler which has a complete and proper to/from_chars implementation is msvc, gccs implementation of from_chars sometimes uses strtod under the hood and clang simply hasn't implemented from_chars for floating point numbers yet at all (actually the upcomig clang 20 will have it). Luckily for us, there is now also boost::charconv that can be used. So this raises to minimum build requirement to have at least one of:
- msvc 2019 update 5
- gcc 11
- clang 14 (i have added a fallback implementation of from_chars for this case, that doesn't support all of its features, and is probably certainly not as fast as the boost version, but supports the features that we use from it)
- boost 1.85
Since in particular the gcc implementation isn't that good (at least it on gcc11), boost charconv is the preferred implementation that is used if available.
This also removes a strange overload for
pointers to integers in lexical_cast while changing lexical_cast to use the new api.
This also adjusts the periods for years and months. Previously, we were using values of 30 days for a month and 12 months for year. Now, we use the chrono values of a month as 1/12 of a year and a year as 365.2425 days.
Internal escaping causing markup failure when tags are nested.
See #9569 and #9572 for example. Functions in markup will no longer
escape their contents, and those should be escaped by caller if needed.
Since we're relying on free functions to parse and serialize time_points, it makes more sense to do likewise for durations rather than relying on a config_attribute_value member function. Leaves the assignment support for now.
Includes adjustments to client code to likewise use chrono types. I decided to keep using time_t
(which is just an alias for long_long) for serializing time points. This avoids compatibility issues,
since we keep the same resolution (seconds since Unix epoch), and unless we're going to "properly"
store time points in config, the time_t's unitless value is a good a representation as any.
These aren't used anymore as of #9332 (save one place, which has been inlined here), and they're not good to rely on, since they don't handle utf8 properly.
Resolves#9009, closes#9384. Besides the issues that came from having both int and bool conversions (even with bool marked explicit), it doesn't make sense to use int for all numeric assignments. I didn't test whether it would be an issue in practice, but it seems better to let callers be explicit about what type they want for numeric values than risking overflow or wrapping for very large values.
Since the detection happens after loading the config tree, it is necessary to expose the links and subtypes of the types alias and composite, respectively.
This implementation builds a graph of all links to detect cycles, ignoring all other types.
To handle links in elements of lists, all subtypes of composite types are visited, keeping the type name of the parent composite type.
Signed-off-by: Rafael Fillipe Silva <rfsc.mori@gmail.com>
This pattern presents the same infinite loop issue as the find_key and find_tag calls on wml_tag. The solution is the same, to use a helper to keep track of the already seen tags and stop when a cycle is detected.
Note that this is only detected if the tag referencing the missing super is used in a .cfg file. The super element itself doesn't need to be used for the detection to work.
The schema self validator should already catch this, but it deserves a warning of its own as the schema self validator can be disabled.
Note that if the .cfg file does not use the tags that causes a cycle, those won't be detected.
This change exposes the super_refs_ so the schema validator does not need to reinvent wml_tag::expand when detecting super cycles.
The super dependency graph is built during the validation of each tag, finishing and reporting cycles at the end of the root tag.
A super cycle may be found during the validation, leading to an infinite loop. For example, calling find_key on an unknown key defined in the .cfg file may trigger this behavior if a cycle exists.
To handle this, a new version of these functions was introduced, keeping the original in the class' private scope. During the search there is a bookkeeping helper that will cause the routine to return nullptr if the search goes back to the initial tag context.
The super tag dependency forms a directed graph. Boost Graph's depth first search implementation was used with a back edge detector to find the cycles.
This is a preparation for enumerating all keys that a tag can use, including the keys from the super tags. If cycles aren't handled, it is impossible to validate mandatory keys without entering an infinite loop.
When reverting this revert (after 1.18 has branched), the
new .hpp file should be added to XCode and CodeBlocks.
This reverts PR #8396, PR #8407 and the "Small fixup" commit;
they bumped the minimum compiler version from GCC 7 to 8 or 11.
This reverts commit 870eeff8e68de000bbe6608c2b6f982b28a2200f.
This reverts commit 029136b19acf9627170e9ab9383cea48b7d70a81.
This reverts commit d74ff6f31b3668d07236ffaa4059f31c373d4996.
This reverts commit 8a6de95d489b4e96d2c9a368b25a0c20e249cdf6.
This reverts commit d14d233d79957ddfcbe200d21f16ab78915c883b.
This reverts commit 698f5c115c1546e3fcf1c52be90d72a5a841abb6.