Changeset - r28006:7835d82043ea
[Not reviewed]
master
0 2 0
Peter Nelson - 11 months ago 2023-10-11 11:31:12
peter1138@openttd.org
Codechange: Accept std::string in RemoveGroup().
2 files changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/ini_load.cpp
Show inline comments
 
@@ -180,27 +180,27 @@ IniGroup *IniLoadFile::GetGroup(const st
 
	if (!create_new) return nullptr;
 

	
 
	/* otherwise make a new one */
 
	IniGroup *group = new IniGroup(this, name);
 
	group->comment = "\n";
 
	return group;
 
}
 

	
 
/**
 
 * Remove the group with the given name.
 
 * @param name name of the group to remove.
 
 */
 
void IniLoadFile::RemoveGroup(const char *name)
 
void IniLoadFile::RemoveGroup(const std::string &name)
 
{
 
	size_t len = strlen(name);
 
	size_t len = name.length();
 
	IniGroup *prev = nullptr;
 
	IniGroup *group;
 

	
 
	/* does it exist already? */
 
	for (group = this->group; group != nullptr; prev = group, group = group->next) {
 
		if (group->name.compare(0, len, name) == 0) {
 
			break;
 
		}
 
	}
 

	
 
	if (group == nullptr) return;
 

	
src/ini_type.h
Show inline comments
 
@@ -53,25 +53,25 @@ struct IniGroup {
 
/** 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
 
	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 std::string &name, bool create_new = true);
 
	void RemoveGroup(const char *name);
 
	void RemoveGroup(const std::string &name);
 

	
 
	void LoadFromDisk(const std::string &filename, Subdirectory subdir);
 

	
 
	/**
 
	 * Open the INI file.
 
	 * @param filename Name of the INI file.
 
	 * @param subdir The subdir to load the file from.
 
	 * @param[out] size Size of the opened file.
 
	 * @return File handle of the opened file, or \c nullptr.
 
	 */
 
	virtual FILE *OpenFile(const std::string &filename, Subdirectory subdir, size_t *size) = 0;
 

	
0 comments (0 inline, 0 general)