52 Commits

Author SHA1 Message Date
pentarctagon
970163813d 2024 copyright update 2024-01-20 22:22:23 -06:00
Pentarctagon
c44cc2742e Copyright update.. 2023-04-29 10:48:11 -05:00
gfgtdf
f8bd32eb15 Deploy and refactor config::optional_child
Previously the config class had an operator bool and
it was a common pattern to use if(const config& = cfg.child(..)).
While this pattern was nice to use. It has severe drawbacks, in
particular it was unclear whether a function that took a config&
parameter allowed "invalid" configs, while most functions
did not, there were some that did. Furtheremore it lead to a few
buggy codes that were unconvered by this change (Not fixed though!),
in particular codes that tested local config objects that were
not references to being invalid, which could never be the case.
This commits replaces those with just `true` in order to not
change behaviour.

Some obvious cases were also removed including for example
things like `assert(config());` There is ony case in the ai code
that i'm not 100% sure of where one implementation of a virtual
function checked for an invalid config and another one that didn't.

With this, all code that check for a config child to be
present now uses config::optional_child which returns an object
that behaves similar to optional<(const) config&>, so it throws
on invalid dereferencing. But it also has operator[string] for
convinience, in particular to make is similary
easy to use the the previous `if (config& = .. child())`.
Also it has a tool DEBUG_CONFIG which tests whether all
optional_config values are checked before they are derefereneced.

Another method manditory_child was
added that throws when the key is not found, which replaces all
occurances of child() that did not check whether the result was
valid. This was neccecary (this= adding a new method instead of
renaming .child) to keep track of converted changes, and be sure
no occurances of child() were accidentally changed to the
throwing version.

We might want to rename one of mandatory_child or optional_child
to just child later. Not sure which one yet. I think it's better
to keep it in the current state (no config::child() ) for a while
though, so that people that currently used child() in their open
prs or other work get an error and not wrongly rely on the previous
behviour of config::child.

The interface of vconfig was not changed in this commit.
2023-04-03 00:39:12 +02:00
Pentarctagon
340023921d
2022 copyright update. 2022-03-06 19:07:13 -06: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
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
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
Gregory A Lundberg
b5f76eff79
Bump copyright to 2018 2018-01-19 00:02:20 -06:00
Charles Dang
2101353d36 Convert include guards to the shorter #pragma once
Turns out I mistook @celticminstrel's opinion that we should use include guards over pragma (737916e).
Since all major compilers support `#pragma once`, there's no reason not to use it.

For future mergability reasons, this excludes src/spirit_po and src/xBRZ. It also excludes src/boost-patched.
2017-05-09 19:41:37 +11:00
Celtic Minstrel
b4dc11ce36 Belated 2017 copyright update 2017-03-19 10:05:38 -04:00
Celtic Minstrel
3ac7f8d970 NULL -> nullptr
A few cases of NULL were missed, since changing them led to errors
(Mainly instances where it was passed to a boost::function)
2016-03-31 00:42:38 -04:00
Chris Beck
ba51524f6e update copyright to year 2016
using this shell script:

find src -type f -print0 | xargs -0 sed -i "s|Copyright (C) \([[:digit:]]*\)\([ ]*\)-\([ ]*\)2015|Copyright (C) \1\2-\32016|g"
2016-01-02 23:59:31 -05:00
Ignacio R. Morelle
57ae45387a New Year copyright update 2015-01-01 19:07:35 -03:00
Mark de Wever
e35f4bb501 Strip trailing whitespace. 2014-06-09 15:26:19 +02:00
Mark de Wever
a2b8589143 Adds -Wextra-semi to pedantic compilation.
Also fixes all warning messages.
2014-01-26 14:24:12 +01:00
Ignacio R. Morelle
a4f47a63c7 New Year copyright update 2014-01-01 02:08:52 -03:00
upthorn
c6da4fcbd0 Refactor persist_context to correct subnamespace crash and avoid holding stale config references in general. 2013-04-13 12:21:51 -03:00
Eric S. Raymond
043c4f9fd3 Remove $Id$ cookies. 2013-03-26 21:41:37 -04:00
Mark de Wever
43b71f2ff0 New year copyright update. 2013-01-01 09:22:03 +00:00
Ignacio R. Morelle
6ca69b2df5 New year copyright update 2012-01-07 02:35:17 +00:00
Alexander van Gessel
81e0a2007f Revert token t_token commits from 2011-09-08T19:15:40Z!thonsew@yahoo.com on. 2011-10-10 03:43:29 +01:00
Thonsew
d2690e0cc6 Move anonymous namespace static const t_token...
...into function local scope in order make sure control flows over
them and initializes in the correct order.
2011-09-11 18:21:49 +00:00
Thonsew
2bf6377351 Changed config and vconfig to use a token representation...
...t_token in place of std::string.  t_token compares, copies, copy
constructs and hashes in 1 operation instead of proportional to the
length of the string.
2011-09-08 19:16:01 +00:00
Mark de Wever
5c6b51a6e1 Pre instead of post increment a variable.
Issue found by cppcheck.
2011-07-31 16:56:31 +00:00
Mark de Wever
ecbabea838 New year copyright update. 2011-01-01 15:57:50 +00:00
Guillaume Melquiond
5debb21bcd Removed unused function persist_context::add_child. 2010-10-30 09:02:22 +00:00
Mark de Wever
1aa4151632 Pre instead of post increment a variable.
Issue found by cppcheck.
2010-10-24 18:11:04 +00:00
Guillaume Melquiond
eeb047de55 Fixed file headers so that they match the content of the COPYING file. 2010-09-01 21:12:38 +00:00
Jody Northup
84938e08c1 Added boolean attribute "immediate" to [set_global_variable]...
...and [clear_global_variable]. If yes, the changes will be written to
file immediately, independently of any ongoing transaction. Defaults
to no.
2010-08-16 05:56:05 +00:00
Jody Northup
eb92bc0a47 resolve log naming conflict between persist_variable...
...functionality and savegame functionality.
2010-08-15 22:25:26 +00:00
Jody Northup
5b908efe66 Persist_context and persist_manager now support transactions. 2010-08-15 19:43:35 +00:00
Mark de Wever
b1250b0a37 Change a function signature to fix compilation.
The signature difference caused the function to be pure virtual, not
allowing an object to be created.
2010-08-02 08:15:47 +00:00
Jody Northup
040e1bc1b5 updated set_global_variable and get_global_variable handlers...
...to support arrays as intended.
2010-08-02 06:40:23 +00:00
Mark de Wever
1f9cfd63be Add a virtual destructor. 2010-07-30 17:44:15 +00:00
Ali El Gariani
aa835d4db0 2010-07-29T20:28:49Z!upthorn@gmail.com broke trunk, quick fix
Just remove an unused variable seems enough. Upthorn, please review this.
2010-07-29 22:36:53 +00:00
Jody Northup
8817971614 Refactored persist_context and persist_manager...
...as per crab_'s request... I think.
2010-07-29 20:28:49 +00:00
Mark de Wever
dd09a963da Make a member function a const member function.
Issue found by cppcheck.
2010-07-18 16:29:05 +00:00
Mark de Wever
7badda3692 Make a member function a const member function.
Issue found by cppcheck.
2010-07-18 16:29:01 +00:00
Mark de Wever
faf390f9d0 Strip trailing whitespace. 2010-07-18 14:44:37 +00:00
Jody Northup
b8d1d23306 fixed regression in removal of empty config nodes...
...which would cause access of invalid memory if those nodes would
later need to be created again.
2010-06-23 11:52:06 +00:00
Jody Northup
55f1280b07 Added persist_manager class to handle saving,
...loading, caching and (not yet implemented) atomic transactions of
data.
2010-06-23 05:01:24 +00:00
Jody Northup
b2073a1be1 Minor changes to initialization order...
...and better separation of member types (object/data/function) in
persist_context class and member structs.
2010-06-16 13:47:53 +00:00
Mark de Wever
3788f1cc9e Initialize all members. 2010-06-12 19:35:19 +00:00
Mark de Wever
c5c43815ac Strip trailing whitespace. 2010-06-12 16:03:58 +00:00
Ali El Gariani
bcc19d502b Fix a typo/error and several warnings in 2010-06-12T10:24:09Z!upthorn@gmail.com 2010-06-12 13:24:58 +00:00
Jody Northup
cee02c3714 Re-engineered persist_context struct...
...to simplify structure, initialization, and garbage collection as
well as reducing data duplication. Additionally, empty nodes are now
removed from the structure when the last child or attribute is
removed.
2010-06-12 10:24:09 +00:00
Jody Northup
724f447fa9 encapsulated functions related to namespace parsing...
...namespace parsing now basically accurate to spec (inaccuracies
reflect pending changes to spec).
2010-06-02 14:42:51 +00:00
Jody Northup
4b123e5ab9 Feels kind of hackish, but persist_context now performs...
...proper garbage collection.
2010-05-30 22:57:16 +00:00
Jody Northup
3235ef47bf Implementation might not be robust,
...but persist_context now correctly populates parent and child nodes
based on persist config file contents.
2010-05-29 11:00:21 +00:00