diff --git a/src/ini_type.h b/src/ini_type.h --- a/src/ini_type.h +++ b/src/ini_type.h @@ -11,6 +11,8 @@ #define INI_TYPE_H #include "fileio_type.h" +#include +#include "3rdparty/optional/ottd_optional.h" /** Types of groups */ enum IniGroupType { @@ -21,12 +23,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 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); @@ -38,13 +40,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(); }; @@ -52,14 +54,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);