Exemple #1
0
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);
}
Exemple #2
0
bool FQTermConfig::deleteSection(const QString &szSection) {
  if (hasSection(szSection)) {
    data.remove(szSection);
    return true;
  }
  return false;
}
Exemple #3
0
bool FQTermConfig::addSection(const QString &szSection) {
  if (hasSection(szSection)) {
    return false;
  }
  Section sec;
  data[szSection] = sec;
  return true;
}
Exemple #4
0
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;
}
Exemple #5
0
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 "";
}
Exemple #6
0
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;
}
Exemple #7
0
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);
}
Exemple #8
0
    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;
    }
Exemple #9
0
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;
}
Exemple #10
0
	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;
	}