Commit graph

17 commits

Author SHA1 Message Date
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
Martin Hrubý (hrubymar10)
6f468a3757
Migrate links to https if available
Closes #3343
2019-09-08 07:53:28 +02:00
Martin Hrubý (hrubymar10)
674fda85b7 Migrate links to https if available - Fwd c18537edc0
(cherry-picked from commit bc4d22dc72)
2018-10-07 03:23:36 +00:00
Charles Dang
3a90f86674 Addressed more whitespace issues from #2613
[ci skip]
2018-03-12 03:48:59 +11:00
Charles Dang
471c9e876a Addressed a large chunk of the whitespace issues from #2613
[ci skip]
2018-03-09 11:37:00 +11:00
Mark de Wever
5da495122a Add a new GUI2 tooltip.
The placement of tooltip is controlled by the WML of the GUI engine. The
code is not used yet, only available with a proof-of-concept define named
DEBUG_TOOLTIP.
2014-02-08 21:13:08 +01:00
Mark de Wever
7fbfe57b36 Fix documentation errors/typos and grammar.
Errors found by zaroth while reading the document. (patch #2613).
2011-04-09 16:00:26 +00:00
Mark de Wever
634051f7e2 Clarify the documentation a bit.
Issue spotted by zaroth.
2011-04-09 16:00:23 +00:00
Mark de Wever
54ceda8497 Improve linking to references.
Use cleveref and add some helper macros for references it can't handle
(yet). Support for listings is in a newer version, so look at that in
the future.
2011-02-26 08:54:02 +00:00
Mark de Wever
65dca6e323 Fix some references for the gui2 design document. 2011-02-26 08:53:59 +00:00
Mark de Wever
6da140a22a Seperate gui2 design document in several files. 2011-02-09 19:15:22 +00:00
Ignacio R. Morelle
d6a3de1938 Apply patch #2213 by stikonas, using file #11274 2010-11-21 01:56:29 +00:00
Mark de Wever
e2b886dfa6 Add the window part to the design document. 2010-04-30 14:21:02 +00:00
Mark de Wever
92b1c831e5 Fix some formatting in the design documentation. 2010-04-30 13:59:39 +00:00
Mark de Wever
3aa3f9d914 Fix some references in the design document. 2010-04-30 13:52:45 +00:00
Mark de Wever
8607604a71 Update design documentation. 2010-04-12 19:26:09 +00:00
Mark de Wever
dcfd8bea24 Update design document. 2010-04-05 09:51:00 +00:00