bool FQTermConfig::renameSection(const QString &szSection, const QString &szNewName) { if (hasSection(szNewName) || !hasSection(szSection)) { return false; } if (!addSection(szNewName)) { return false; } data[szNewName] = data[szSection]; return deleteSection(szSection); }
bool FQTermConfig::deleteSection(const QString &szSection) { if (hasSection(szSection)) { data.remove(szSection); return true; } return false; }
bool FQTermConfig::addSection(const QString &szSection) { if (hasSection(szSection)) { return false; } Section sec; data[szSection] = sec; return true; }
bool FQTermConfig::deleteItem(const QString &szSection, const QString &szItemName) { if (hasSection(szSection)) if (data[szSection].find(szItemName) != data[szSection].end()) { data[szSection].remove(szItemName); return true; } return false; }
QString FQTermConfig::getItemValue(const QString &szSection, const QString &szItemName) const { if (hasSection(szSection)) if (data[szSection].find(szItemName) != data[szSection].end()) if (!data[szSection][szItemName].isEmpty()) { return data[szSection][szItemName]; } return ""; }
bool FQTermConfig::setItemValue(const QString &szSection, const QString &szItemName, const QString &szItemValue) { if (!hasSection(szSection)) if (!addSection(szSection)) { return false; } data[szSection][szItemName] = szItemValue; return true; }
std::shared_ptr<base::ISection> FileFS::createSection(const std::string &name, const std::string &type) { if (name.empty()) { throw EmptyString("Trying to create a Section with an empty name!"); } if (hasSection(name)) { throw DuplicateName("Section with the specified name altready exists!"); } std::string id = util::createId(); SectionFS s(file(), metadata_dir.location(), id, type, name); return std::make_shared<SectionFS>(s); }
ClassList<std::string> * Ini::keysinsection(std::string sec) { if(!hasSection(sec)) return NULL; CSimpleIniA::TNamesDepend keys; ini.GetAllKeys(sec.c_str(), keys); ClassList<std::string> * ret = new ClassList<std::string>(); CSimpleIniA::TNamesDepend::iterator it; for ( it = keys.begin(); it != keys.end(); it++ ) ret->add(std::string(it->pItem)); return ret; }
bool FileHDF5::deleteSection(const std::string &name_or_id) { bool deleted = false; // call deleteSection on sections to trigger recursive call to all sub-sections if (hasSection(name_or_id)) { // get instance of section about to get deleted Section section = getSection(name_or_id); // loop through all child sections and call deleteSection on them for(auto &child : section.sections()) { section.deleteSection(child.id()); } // if hasSection is true then section_group always exists deleted = metadata.removeAllLinks(section.name()); } return deleted; }
bool INIFile::appendLine(const String& sectionName, const String& line) { String section_name(sectionName); if (section_name == "") { SectionIterator it(sections_.end()); it--; section_name = it->getName(); } if (!hasSection(section_name) || line[0] == '[') { Log.error() << "In INIFile " << filename_ << " , error while appending line: " << line << " . Illegal section-name: " << sectionName << endl; return false; } Section& section(*getSection(section_name)); // key? if (line.hasSubstring("=", 1)) { String key(line.before("=")); key.trim(); if (section.key_map_.has(key) && check_duplicate_keys_) { Log.error() << "In INIFile " << filename_ << " , error while appending line: " << line << " . Key '" << key << "' already exists in section." << endl; return false; } section.lines_.push_back(line); list<String >::iterator line_it(section.lines_.end()); line_it--; section.key_map_[key] = line_it; return true; } section.lines_.push_back(line); return true; }