Merge branch 'master' into jgrpp

# Conflicts:
#	projects/openttd_vs140.vcxproj.filters
#	projects/openttd_vs141.vcxproj.filters
#	projects/openttd_vs142.vcxproj.filters
#	src/base_consist.h
#	src/company_base.h
#	src/newgrf_config.cpp
#	src/newgrf_config.h
#	src/openttd.cpp
#	src/saveload/saveload.cpp
#	src/saveload/saveload.h
#	src/saveload/station_sl.cpp
#	src/settings.cpp
#	src/signs_base.h
#	src/string.cpp
#	src/string_func.h
#	src/table/misc_settings.ini
#	src/table/settings.h.preamble
#	src/town_cmd.cpp
#	src/vehicle.cpp
#	src/vehicle_cmd.cpp
#	src/video/cocoa/cocoa_v.mm
#	src/video/null_v.cpp
This commit is contained in:
Jonathan G Rennison
2020-05-21 20:19:57 +01:00
162 changed files with 2519 additions and 1448 deletions

View File

@@ -11,6 +11,8 @@
#define INI_TYPE_H
#include "fileio_type.h"
#include <string>
#include "3rdparty/optional/ottd_optional.h"
#include <string>
@@ -23,12 +25,12 @@ enum IniGroupType {
/** A single "line" in an ini file. */
struct IniItem {
IniItem *next; ///< The next item in this group
char *name; ///< The name of this item
char *value; ///< The value of this item
char *comment; ///< The comment associated with this item
IniItem *next; ///< The next item in this group
std::string name; ///< The name of this item
opt::optional<std::string> value; ///< The value of this item
std::string comment; ///< The comment associated with this item
IniItem(struct IniGroup *parent, const char *name, const char *last = nullptr);
IniItem(struct IniGroup *parent, const std::string &name);
~IniItem();
void SetValue(const char *value);
@@ -40,13 +42,13 @@ struct IniGroup {
IniGroupType type; ///< type of group
IniItem *item; ///< the first item in the group
IniItem **last_item; ///< the last item in the group
char *name; ///< name of group
char *comment; ///< comment for group
std::string name; ///< name of group
std::string comment; ///< comment for group
IniGroup(struct IniLoadFile *parent, const char *name, const char *last = nullptr);
IniGroup(struct IniLoadFile *parent, const std::string &name);
~IniGroup();
IniItem *GetItem(const char *name, bool create);
IniItem *GetItem(const std::string &name, bool create);
void Clear();
};
@@ -54,14 +56,14 @@ struct IniGroup {
struct IniLoadFile {
IniGroup *group; ///< the first group in the ini
IniGroup **last_group; ///< the last group in the ini
char *comment; ///< last comment in file
std::string comment; ///< last comment in file
const char * const *list_group_names; ///< nullptr terminated list with group names that are lists
const char * const *seq_group_names; ///< nullptr terminated list with group names that are sequences.
IniLoadFile(const char * const *list_group_names = nullptr, const char * const *seq_group_names = nullptr);
virtual ~IniLoadFile();
IniGroup *GetGroup(const char *name, size_t len = 0, bool create_new = true);
IniGroup *GetGroup(const std::string &name, bool create_new = true);
void RemoveGroup(const char *name);
void LoadFromDisk(const char *filename, Subdirectory subdir, std::string *save = nullptr);