Update to 12.0-beta1

This commit is contained in:
dP
2021-08-15 14:57:29 +03:00
parent ac7d3eba75
commit 9df4f2c4fc
666 changed files with 61302 additions and 20466 deletions
+29 -9
View File
@@ -22,7 +22,7 @@
*/
IniItem::IniItem(IniGroup *parent, const std::string &name) : next(nullptr)
{
this->name = str_validate(name);
this->name = StrMakeValid(name);
*parent->last_item = this;
parent->last_item = &this->next;
@@ -38,13 +38,9 @@ IniItem::~IniItem()
* Replace the current value with another value.
* @param value the value to replace with.
*/
void IniItem::SetValue(const char *value)
void IniItem::SetValue(const std::string_view value)
{
if (value == nullptr) {
this->value.reset();
} else {
this->value.emplace(value);
}
this->value.emplace(value);
}
/**
@@ -54,7 +50,7 @@ void IniItem::SetValue(const char *value)
*/
IniGroup::IniGroup(IniLoadFile *parent, const std::string &name) : next(nullptr), type(IGT_VARIABLES), item(nullptr)
{
this->name = str_validate(name);
this->name = StrMakeValid(name);
this->last_item = &this->item;
*parent->last_group = this;
@@ -104,6 +100,30 @@ IniItem *IniGroup::GetItem(const std::string &name, bool create)
return new IniItem(this, name);
}
/**
* Remove the item with the given name.
* @param name Name of the item to remove.
*/
void IniGroup::RemoveItem(const std::string &name)
{
IniItem **prev = &this->item;
for (IniItem *item = this->item; item != nullptr; prev = &item->next, item = item->next) {
if (item->name != name) continue;
*prev = item->next;
/* "last_item" is a pointer to the "real-last-item"->next. */
if (this->last_item == &item->next) {
this->last_item = prev;
}
item->next = nullptr;
delete item;
return;
}
}
/**
* Clear all items in the group
*/
@@ -292,7 +312,7 @@ void IniLoadFile::LoadFromDisk(const std::string &filename, Subdirectory subdir)
if (!quoted && e == t) {
item->value.reset();
} else {
item->value = str_validate(std::string(t));
item->value = StrMakeValid(std::string(t));
}
} else {
/* it's an orphan item */