Merge branch 'master' into jgrpp
# Conflicts: # regression/regression/result.txt # src/aircraft_cmd.cpp # src/airport_gui.cpp # src/articulated_vehicles.cpp # src/console_cmds.cpp # src/date_gui.cpp # src/engine.cpp # src/genworld_gui.cpp # src/gfx_layout_fallback.cpp # src/group_gui.cpp # src/hotkeys.cpp # src/network/core/tcp_connect.cpp # src/network/core/tcp_listen.h # src/newgrf.cpp # src/newgrf.h # src/newgrf_engine.cpp # src/newgrf_gui.cpp # src/newgrf_station.cpp # src/openttd.cpp # src/order_gui.cpp # src/os/macosx/osx_main.cpp # src/pathfinder/yapf/yapf_node_rail.hpp # src/rail_gui.cpp # src/saveload/afterload.cpp # src/saveload/cargopacket_sl.cpp # src/saveload/linkgraph_sl.cpp # src/saveload/station_sl.cpp # src/script/api/script_industrytype.cpp # src/settings.cpp # src/settings_gui.cpp # src/settings_table.cpp # src/settingsgen/settingsgen.cpp # src/station.cpp # src/station_cmd.cpp # src/strings.cpp # src/timer/timer_game_calendar.cpp # src/timer/timer_game_calendar.h # src/timer/timer_manager.h # src/timer/timer_window.cpp # src/timetable_cmd.cpp # src/toolbar_gui.cpp # src/town_cmd.cpp # src/town_gui.cpp # src/train_gui.cpp # src/vehicle_cmd.h # src/vehicle_gui.cpp # src/viewport.cpp # src/widgets/dropdown.cpp # src/window_func.h # src/window_gui.h
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#define INI_TYPE_H
|
||||
|
||||
#include "fileio_type.h"
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <optional>
|
||||
|
||||
@@ -23,48 +24,48 @@ enum IniGroupType {
|
||||
|
||||
/** A single "line" in an ini file. */
|
||||
struct IniItem {
|
||||
IniItem *next; ///< The next item in this group
|
||||
std::string name; ///< The name of this item
|
||||
std::optional<std::string> value; ///< The value of this item
|
||||
std::string comment; ///< The comment associated with this item
|
||||
|
||||
IniItem(struct IniGroup *parent, const std::string &name);
|
||||
~IniItem();
|
||||
IniItem(const std::string &name);
|
||||
|
||||
void SetValue(const std::string_view value);
|
||||
};
|
||||
|
||||
/** A group within an ini file. */
|
||||
struct IniGroup {
|
||||
IniGroup *next; ///< the next group within this file
|
||||
std::list<IniItem> items; ///< all items in the group
|
||||
IniGroupType type; ///< type of group
|
||||
IniItem *item; ///< the first item in the group
|
||||
IniItem **last_item; ///< the last item in the group
|
||||
std::string name; ///< name of group
|
||||
std::string comment; ///< comment for group
|
||||
|
||||
IniGroup(struct IniLoadFile *parent, const std::string &name);
|
||||
~IniGroup();
|
||||
IniGroup(const std::string &name, IniGroupType type);
|
||||
|
||||
IniItem *GetItem(const std::string &name) const;
|
||||
const IniItem *GetItem(const std::string &name) const;
|
||||
IniItem &GetOrCreateItem(const std::string &name);
|
||||
IniItem &CreateItem(const std::string &name);
|
||||
void RemoveItem(const std::string &name);
|
||||
void Clear();
|
||||
};
|
||||
|
||||
/** Ini file that only supports loading. */
|
||||
struct IniLoadFile {
|
||||
IniGroup *group; ///< the first group in the ini
|
||||
IniGroup **last_group; ///< the last group in the ini
|
||||
using IniGroupNameList = std::initializer_list<std::string_view>;
|
||||
|
||||
std::list<IniGroup> groups; ///< all groups in the ini
|
||||
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.
|
||||
const IniGroupNameList list_group_names; ///< list of group names that are lists
|
||||
const IniGroupNameList seq_group_names; ///< list of group names that are sequences.
|
||||
|
||||
IniLoadFile(const char * const *list_group_names = nullptr, const char * const *seq_group_names = nullptr);
|
||||
virtual ~IniLoadFile();
|
||||
IniLoadFile(const IniGroupNameList &list_group_names = {}, const IniGroupNameList &seq_group_names = {});
|
||||
virtual ~IniLoadFile() { }
|
||||
|
||||
IniGroup *GetGroup(const std::string &name, bool create_new = true);
|
||||
void RemoveGroup(const char *name);
|
||||
const IniGroup *GetGroup(const std::string &name) const;
|
||||
IniGroup *GetGroup(const std::string &name);
|
||||
IniGroup &GetOrCreateGroup(const std::string &name);
|
||||
IniGroup &CreateGroup(const std::string &name);
|
||||
void RemoveGroup(const std::string &name);
|
||||
|
||||
void LoadFromDisk(const std::string &filename, Subdirectory subdir, std::string *save = nullptr);
|
||||
|
||||
@@ -88,7 +89,7 @@ struct IniLoadFile {
|
||||
|
||||
/** Ini file that supports both loading and saving. */
|
||||
struct IniFile : IniLoadFile {
|
||||
IniFile(const char * const *list_group_names = nullptr);
|
||||
IniFile(const IniGroupNameList &list_group_names = {});
|
||||
|
||||
bool SaveToDisk(const std::string &filename);
|
||||
|
||||
|
Reference in New Issue
Block a user