mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-10 08:00:05 +00:00
(svn r22169) -Add: Add parameter to disable automatic group creation in IniLoadFile::GetGroup().
This commit is contained in:
parent
722296e797
commit
6a88af662b
@ -132,13 +132,14 @@ IniLoadFile::~IniLoadFile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the group with the given name, and if it doesn't exist
|
* Get the group with the given name. If it doesn't exist
|
||||||
* create a new group.
|
* and \a create_new is \c true create a new group.
|
||||||
* @param name name of the group to find.
|
* @param name name of the group to find.
|
||||||
* @param len the maximum length of said name.
|
* @param len the maximum length of said name (\c 0 means length of the string).
|
||||||
* @return the requested group.
|
* @param create_new Allow creation of group if it does not exist.
|
||||||
|
* @return The requested group if it exists or was created, else \c NULL.
|
||||||
*/
|
*/
|
||||||
IniGroup *IniLoadFile::GetGroup(const char *name, size_t len)
|
IniGroup *IniLoadFile::GetGroup(const char *name, size_t len, bool create_new)
|
||||||
{
|
{
|
||||||
if (len == 0) len = strlen(name);
|
if (len == 0) len = strlen(name);
|
||||||
|
|
||||||
@ -149,6 +150,8 @@ IniGroup *IniLoadFile::GetGroup(const char *name, size_t len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!create_new) return NULL;
|
||||||
|
|
||||||
/* otherwise make a new one */
|
/* otherwise make a new one */
|
||||||
IniGroup *group = new IniGroup(this, name, len);
|
IniGroup *group = new IniGroup(this, name, len);
|
||||||
group->comment = strdup("\n");
|
group->comment = strdup("\n");
|
||||||
|
@ -57,7 +57,7 @@ struct IniLoadFile {
|
|||||||
IniLoadFile(const char * const *list_group_names = NULL);
|
IniLoadFile(const char * const *list_group_names = NULL);
|
||||||
virtual ~IniLoadFile();
|
virtual ~IniLoadFile();
|
||||||
|
|
||||||
IniGroup *GetGroup(const char *name, size_t len = 0);
|
IniGroup *GetGroup(const char *name, size_t len = 0, bool create_new = true);
|
||||||
void RemoveGroup(const char *name);
|
void RemoveGroup(const char *name);
|
||||||
|
|
||||||
void LoadFromDisk(const char *filename);
|
void LoadFromDisk(const char *filename);
|
||||||
|
Loading…
Reference in New Issue
Block a user