Mercurial > hg > openttd
changeset 17419:e5e0ef0a24f5 draft
(svn r22169) -Add: Add parameter to disable automatic group creation in IniLoadFile::GetGroup().
author | alberth <alberth@openttd.org> |
---|---|
date | Thu, 03 Mar 2011 20:55:06 +0000 |
parents | 7aacec42611c |
children | 652df6e854ed |
files | src/ini_load.cpp src/ini_type.h |
diffstat | 2 files changed, 9 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ini_load.cpp +++ b/src/ini_load.cpp @@ -132,13 +132,14 @@ } /** - * Get the group with the given name, and if it doesn't exist - * create a new group. + * Get the group with the given name. If it doesn't exist + * and \a create_new is \c true create a new group. * @param name name of the group to find. - * @param len the maximum length of said name. - * @return the requested group. + * @param len the maximum length of said name (\c 0 means length of the string). + * @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); @@ -149,6 +150,8 @@ } } + if (!create_new) return NULL; + /* otherwise make a new one */ IniGroup *group = new IniGroup(this, name, len); group->comment = strdup("\n");
--- a/src/ini_type.h +++ b/src/ini_type.h @@ -57,7 +57,7 @@ IniLoadFile(const char * const *list_group_names = NULL); 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 LoadFromDisk(const char *filename);