34 Commits

Author SHA1 Message Date
gfgtdf
5801b5bcdb
use to/from_chars in attribute_value and lexical_cast (#8790)
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.
2024-12-08 22:28:10 +01:00
Charles Dang
187f10ea84 Config: added assignment to string&& 2024-10-03 23:40:41 -04:00
Charles Dang
7a665d0959 Config Attribute Value: let compiler handle default special functions (rule of 5) 2024-08-01 00:05:54 -04:00
Charles Dang
e36b675ec4 New config_attribute_value::operator== implementation 2024-07-30 22:48:40 -04:00
Celtic Minstrel
ac431ca9dd Revert "Remove macOS compat path for std::variant and std::any"
This reverts commit c2decdfb585b9f3551fb4f0eaa41d42c9fe14422.
2024-07-23 08:23:38 -04:00
Charles Dang
156630d314 Use std::numeric_limits instead of C macros 2024-07-12 02:49:27 -04:00
Charles Dang
c2decdfb58 Remove macOS compat path for std::variant and std::any 2024-07-08 22:02:32 -04:00
shijie.chen
d88ddec6f1
Remove unnecessary header files (#8531)
Co-authored-by: shijie.chen <shijie.chen@goland.cn>
2024-03-12 00:07:48 -04:00
shijie.chen
5d7479b0e1
Remove unnecessary includes (#8347) 2024-02-08 09:40:17 -06:00
pentarctagon
970163813d 2024 copyright update 2024-01-20 22:22:23 -06:00
Subhraman Sarkar
f1f67ae5df
Add functionality to Time Schedule Editor (#8066)
selected schedule will write to utils/schedule.cfg on scenario save

HOTKEY_EDITOR_CUSTOM_TODS is disabled unless user loads scenario

custom_tod:Preview button and associated callback added.

editor:translatable attributes now written with leading underscore

editor:support for multiple custom time schedules
2023-12-14 17:12:07 -06:00
Pentarctagon
c44cc2742e Copyright update.. 2023-04-29 10:48:11 -05:00
Pentarctagon
d98d5bea2f Add some more tests for config's attribute handling. 2022-11-01 13:28:21 -05:00
Pentarctagon
340023921d
2022 copyright update. 2022-03-06 19:07:13 -06:00
Charles Dang
d37824f9e4 Support config assignment from std::string_view 2022-01-14 14:12:59 -05:00
Pentarctagon
57ce449af8
Re-add attribution to copyright notices.
These are mostly useless and outdated/wrong, but apparently it's probably illegal to remove them.
2021-07-27 20:21:38 -05:00
Pentarctagon
ba75e1af50
Copyright update.
This additionally:
* Makes all copyright notices identical aside from the starting year for Wesnoth-specific source files. Files not included: mariadbpp, lua, spirit po, xbrz, and bcrypt (crypt_blowfish).
* Removes all attribution from the files, since the vast majority of them are outdated or seemingly just outright incorrect. For example, I would guess that Dave is no longer the sole author of the majority of Wesnoth's current code.
2021-07-26 11:38:03 -05:00
Charles Dang
f061eaa6e4 Removed two unnecessary includes
general.hpp was accidentally added in e31b327
2021-01-20 14:34:10 +11:00
Charles Dang
e31b327a90 Converted config_attribute_value to use utils::variant
All visitors that are used with apply_visitor have had their boost::static_visitor inheritance
made conditional as well.
2021-01-20 14:23:46 +11:00
Pentarctagon
74d914f45f Convert relevant cases of lexical_cast to std::to_string().
In general I think it's best to use std implementations unless there's a functional or performance reason not to, but also in a few cases this also allows removing the include of lexical_cast.hpp.
2021-01-18 00:51:41 -06:00
Pentarctagon
4c2b725ec0 Change all doxygen comments to the same format. 2020-12-31 23:59:28 -06:00
Charles Dang
5714deebba Cleaned up some boost::variant includes 2020-12-20 02:01:06 +11:00
Charles Dang
6e2f3e099e Removed utils/functional.hpp 2020-12-04 15:30:46 +11:00
Charles Dang
30c7a747ab Explicitly specify std::placeholders namespace for all bind placeholders
Apparently, even on Boost 1.73 without Boost placeholders specialized as is_placeholder, they were somehow
getting used in the global namespace. Would explain all the "Boost placeholders in the global namespace is
deprecated" warnings I was getting after 23d1db043f9f8266c77c6270ed4ef3eafbc0cf67.

When testing with BOOST_BIND_NO_PLACEHOLDERS, even though I had `using namespace std::placeholders` in utils/functional.hpp,
compilation still failed in places. This confirms even more that Boost global placeholders were being used. Honestly,
it was simplest just to specify std::placeholders for everything. This also means we can remove the hack in utils/functional.hpp
designed to allow Boost placeholders to work with `std::bind`.
2020-12-04 15:28:15 +11:00
gfgtdf
89e56d8fb9 add utils::split_set and move split_foreach
this also improves the perfromance of utils::split because
it no longer uses stringstreams.
2020-07-29 01:09:06 +02:00
Martin Hrubý (hrubymar10)
674fda85b7 Migrate links to https if available - Fwd c18537edc0678f40a209797d72dfaba3e5e88545
(cherry-picked from commit bc4d22dc72e79c3d6a3364ac896e473afd298246)
2018-10-07 03:23:36 +00:00
Charles Dang
21580d3ef1 Use std::time_t instead of plain C time_t
(cherry-picked from commit ccbb736a180d37f2640cd56331b91f855c728464)
2018-10-07 03:21:00 +00:00
Charles Dang
45f871067f Use std::size_t everywhere instead of plain size_t
Excludes:
* spirit_po/
* xBRZ/

(cherry-picked from commit fc2a58f6935176b70a035d3e1c03080f79687f94)
2018-10-07 03:17:59 +00:00
Matthias Krüger
a2168d2e24 codespell fixes to /src 2018-02-08 21:54:09 +11:00
Charles Dang
d98093ebba Config Attribute Value: added write_if_not_empty helper
Takes a string and assigns a value only if that string is not empty.
2018-01-25 18:13:27 +11:00
Charles Dang
f23305f7e2 Formatting cleanup: T const& -> const T& 2018-01-23 01:26:23 +11:00
Gregory A Lundberg
b5f76eff79
Bump copyright to 2018 2018-01-19 00:02:20 -06:00
Charles Dang
1707070d6f Reformat config and config attribute code 2017-05-22 10:49:13 +11:00
gfgtdf
13b00f73ff move config::attribte_value out of config.?pp
this has 2 advantages:
1) we can now forwaed declare the class config_attribute_value without
including config.hpp
2) the config.?pp files are a little easier to read.
2017-05-15 02:27:18 +02:00