Commit Graph

36 Commits

Author SHA1 Message Date
Peter Nelson 6ee31a2a22
Codechange: Use string_view in IniItem/IniGroup/IniFile. (#12535)
This avoids making extra copies of strings.
2024-04-19 13:54:22 +01:00
Peter Nelson 69e20e79ab Codechange: Add const versions of GetItem/GetGroup, and sprinkle liberally.
Non-const version of GetItem is not needed.
2023-10-20 18:37:27 +01:00
Peter Nelson 233aac567b Codechange: Use std::list instead of C-linked list for ini files.
This removes self-management of memory with new/delete and allows simpler iteration.
2023-10-20 18:37:27 +01:00
Peter Nelson ec1cf96b62 Codechange: Move initialization of group-type to CreateGroup function. 2023-10-20 18:37:27 +01:00
Peter Nelson 8bd06807e4 Codechange: Pass initializer list instead of null-terminated list of group types. 2023-10-20 18:37:27 +01:00
Peter Nelson 1fecbeff76 Codechange: Remove create parameter from IniLoadFile::GetGroup.
GetGroup now only returns nullptr if the group does not exist.
Use GetOrCreateGroup to create a group.

This avoids creating groups while reading ini files.
2023-10-20 18:37:27 +01:00
Peter Nelson 6ce7195ef1 Codechange: Split GetGroup into GetGroup/GetOrCreateGroup.
This follows the pattern used for GetItem/GetOrCreateItem, and allows use
of references where we know the group must exist.
2023-10-20 18:37:27 +01:00
Peter Nelson d3c5ae2648 Codechange: Add CreateGroup/CreateItem methods for ini files.
This abstracts the internals a bit.
2023-10-20 18:37:27 +01:00
Peter Nelson 3961318974 Codechange: Accept std::string in RemoveGroup(). 2023-10-20 18:37:27 +01:00
Peter Nelson 49dae08a3b Codechange: Add missing override specifiers. 2023-09-25 21:27:45 +01:00
PeterN 9fa1984ef0
Codechange: IniGroup::GetItem() can now be const. (#10966) 2023-06-06 22:39:37 +00:00
PeterN 64d6ad50f9
Codechange: Split GetItem with GetOrCreateItem. (#10952)
`IniGroup::GetItem()` returns nullptr if the item does not exist, but does not if the create parameter is set to true. Resolve CodeQL warnings with `GetOrCreateItem()` which returns a reference to the item instead.
2023-06-05 18:29:52 +00:00
Rubidium 68ff3fd062 Change: include fmt.h C++ headers in stdafx.h
This to prevent compilation issues between runs with and without precompiled
headers. Also remove the headers from the rest of the code base as they are
not needed there anymore, although they do relatively little harm.
2023-05-08 16:49:23 +02:00
Patric Stout 75b6051b7a Change: move sensitive information to secrets.cfg and private information to private.cfg
We often ask people for their openttd.cfg, which now includes their
passwords, usernames, etc. It is easy for people to overlook this,
unwillingly sharing information they shouldn't.

By splitting this information over either private.cfg or secrets.cfg,
we make it more obvious they shouldn't be sharing those files, and
hint to what is inside them.
2021-07-02 14:30:14 +02:00
rubidium42 a032714dc4 Codechange: move script settings to std::string 2021-05-13 23:13:17 +02:00
Michael Lutz 358056ec42 Codechange: Keep filenames of loaded Fio files in std::strings. 2020-12-27 13:19:25 +01:00
Michael Lutz dd138fc460 Codechange: Stringify config file paths. 2020-12-27 13:19:25 +01:00
frosch 484ea62a62 Cleanup: use std::optional instead of custom implementation. 2020-12-14 23:50:50 +01:00
Michael Lutz 715aa67a9c Codechange: Use std::string in INI file parsing. 2020-05-21 20:02:34 +02:00
S. D. Cloudt 13cc8a0cee Cleanup: Removed SVN headers 2019-11-10 17:59:20 +00:00
Henry Wilson 7c8e7c6b6e Codechange: Use null pointer literal instead of the NULL macro 2019-04-10 23:22:20 +02:00
Charles Pigott f5b1115039 Doc: Lots and lots of doxymentation fixes 2018-10-31 12:35:54 +01:00
rubidium 8960939b22 (svn r26499) -Codechange: replace strndup with stredup 2014-04-24 18:37:39 +00:00
rubidium 05300a00b1 (svn r22824) -Codechange: pass sub directory to ini loading 2011-08-24 13:38:26 +00:00
alberth fa9c193539 (svn r22170) -Add: Add IGT_SEQUENCE type for loading ini group lines without further interpretation. 2011-03-03 20:56:33 +00:00
alberth 6a88af662b (svn r22169) -Add: Add parameter to disable automatic group creation in IniLoadFile::GetGroup(). 2011-03-03 20:55:06 +00:00
alberth 722296e797 (svn r22168) -Codechange: Move ini file IO and file error reporting to virtual functions. 2011-03-03 20:53:09 +00:00
alberth d19a9f5df5 (svn r22167) -Codechange: Extract IniLoadFile base class for loading ini files out of IniFile. 2011-03-03 20:50:24 +00:00
rubidium 7efd7e19ed (svn r21845) -Codechange: move documentation towards the code to make it more likely to be updates [d-m]. 2011-01-18 22:31:06 +00:00
smatz 114d48e492 (svn r17596) -Codechange: constify some tables 2009-09-20 23:11:01 +00:00
rubidium 7fbc33dae1 (svn r17248) -Fix: add GPL license notice where appropriate 2009-08-21 20:21:05 +00:00
peter1138 7d70f0cd14 (svn r15085) -Fix (r14164): Clearing a settings group did not delete old items nor reset the last_item pointer, causing lists to not be saved unless they started blank. 2009-01-14 20:23:45 +00:00
rubidium 621a9b647a (svn r14167) -Fix: items in some ini-groups got duplicated on save. 2008-08-25 15:15:41 +00:00
rubidium 411c65e755 (svn r14164) -Codechange: simplify and unify the addition of ini items with value when not loading an ini file.
-Fix: wrong insertion management causing leaks.
2008-08-25 06:35:28 +00:00
smatz 0d4e7f9537 (svn r14156) -Fix (r14153): missing/wrong comments 2008-08-24 17:29:57 +00:00
rubidium ae32d158cb (svn r14153) -Codechange: split ini file reading/saving from settings.cpp. 2008-08-24 13:50:31 +00:00