Esempio n. 1
0
void FifoIndex::remove(RowHandle *rh)
{
    RhSection *rs = getSection(rh);

    if (first_ == rh) {
        if (last_ == rh) {
            first_ = last_ = NULL; // that was the last row
        } else {
            first_ = rs->next_;
            RhSection *nextrs = getSection(first_);
            nextrs->prev_ = NULL;
        }
    } else if (last_ == rh) {
        last_ = rs->prev_;
        RhSection *prevrs = getSection(last_);
        prevrs->next_ = NULL;
    } else {
        RhSection *nextrs = getSection(rs->next_);
        RhSection *prevrs = getSection(rs->prev_);
        prevrs->next_ = rs->next_;
        nextrs->prev_ = rs->prev_;
    }
    rs->prev_ = rs->next_ = NULL;
    --size_;
}
Esempio n. 2
0
	void Parser::scan_section()
	{
		if (current_char != L_SECTION)
			return;

		std::string line = "";
		while (scan_char() && current_char != R_SECTION && current_char != NEWLINE)
		{
			line += current_char;
		}

		//Remember:
		// Section takes care of freeing the resources of its siblings
		// so new is actually safe here

		Section *section = new Section(line);

		//current_section might be a section, but if not, our ctor guarantees it to be NULL.
		section->previous = current_section;

        //Use current_section rather than the getter since we don't want it to instantiate.
		if (current_section)
		{
			section->previous = getSection();
			getSection()->next = section;
		}

		setSection(section);
	};
Esempio n. 3
0
File: INIFile.C Progetto: HeyJJ/ball
	INIFile::LineIterator INIFile::getSectionFirstLine(const String& section_name)
	{
		if (!section_index_.has(section_name)) 
		{
			return LineIterator();
		}

		return LineIterator(sections_, getSection(section_name), 
												 getSection(section_name)->lines_.begin());
	}
Esempio n. 4
0
File: INIFile.C Progetto: HeyJJ/ball
	INIFile::LineIterator INIFile::getSectionLastLine(const String& section_name)
	{
		if (!section_index_.has(section_name)) 
		{
			return LineIterator();
		}

		SectionIterator sit = getSection(section_name);
		list<String >::iterator	line_it(sit->lines_.end());
		if (sit->lines_.size() > 0) line_it--;
		return LineIterator(sections_, getSection(section_name), line_it);
	}
INIFile::Section* INIFile::getSectionOrCreate(const std::string& sectionname) {
	Section* curSection = getSection(sectionname);

	if(curSection == NULL) {
		// create new section

		if(isValidSectionName(sectionname) == false) {
			std::cerr << "INIFile: Cannot create section with name " << sectionname << "!" << std::endl;
			return NULL;
		}

		curSection = new Section(sectionname);

		if(FirstLine == NULL) {
			FirstLine = curSection;
		} else {
            INIFileLine* curLine = FirstLine;
			while(curLine->nextLine != NULL) {
				curLine = curLine->nextLine;
			}

			curLine->nextLine = curSection;
			curSection->prevLine = curLine;
		}

		InsertSection(curSection);
	}
    return curSection;
}
Esempio n. 6
0
void Config::loadData(char *pbData, int iDatasize){
	int pointer = 0;
	while (pointer < iDatasize){
		char *line = GetNextLine(pbData, iDatasize, &pointer);
		//printf("Line: %s\r\n", line);
		/**/
		if (lineContainSection(line) == true){
			char *section = getSection(line);
			//printf("Section: [%s]\r\n", section);
			do{
				char *sectionDataLine = GetNextLine(pbData, iDatasize, &pointer);
				char *key = NULL;
				char *value = NULL;
				if (sectionDataLine != NULL){
					key = getKey(sectionDataLine);
					value = getValue(sectionDataLine);
					if (key != NULL && value != NULL){
						config.put(section, key, value);
						//printf(" (%s) = |%s|\r\n", key, value);
						//printf()
					}
						
				}
				
				if (sectionDataLine != NULL) delete[] sectionDataLine;
				//if (key != NULL) delete[] key;
				//if (value != NULL) delete[] value;
			}
			while (lineInCurrentSection(pbData, iDatasize, &pointer) == true);
			//if(section != NULL) delete[] section;

		}
		if(line!=NULL) delete[]line;
	}
}
Esempio n. 7
0
std::vector<Section> File::sections(const util::Filter<Section>::type &filter) const
{
    auto f = [this] (ndsize_t i) { return getSection(i); };
    return getEntities<Section>(f,
                                sectionCount(),
                                filter);
}
Esempio n. 8
0
bool FifoIndex::replacementPolicy(RowHandle *rh, RhSet &replaced)
{
    size_t limit = type_->getLimit();
    if (limit == 0)
        return true; // no limit, nothing replaced

    // Check if there is any row already marked for replacement and present in this index,
    // then don't push out another one.
    size_t subtract = 0;
    for (RhSet::iterator it = replaced.begin(); it != replaced.end(); ++it) {
        Index *rind = type_->findInstance(table_, *it);
        if (rind == this)
            ++subtract; // it belongs here, so a record will be already pushed out
    }

    if (size_ - subtract >= limit && size_ >= subtract) { // this works well only with one-at-a-time inserts
        if (type_->isJumping()) {
            RowHandle *curh = first_;
            while(curh != NULL) {
                replaced.insert(curh);

                RhSection *rs = getSection(curh);
                curh = rs->next_;
            }
        } else {
            replaced.insert(first_);
        }
    }

    return true;
}
Esempio n. 9
0
/* ==========================================================================
	Function Name	: (HKEY) RegCreate()
	Outline			: 指定したレジストリキーを作成(またはオープン)する
	Arguments		: HKEY		hCurrentKey		(in)	現在のオープンキー
					: LPCTSTR	lpszKeyName		(in)	オープンするサブキーの
					: 									名前
	Return Value	: 成功	オープンまたは作成されたキーのハンドル
					: 失敗	NULL
	Reference		: 
	Renewal			: 
	Notes			: 
	Attention		: 
	Up Date			: 
   ======1=========2=========3=========4=========5=========6=========7======= */
HKEY RegCreate(HKEY hCurrentKey, LPCTSTR lpszKeyName)
{
	if(bUseINI){
		getSection(lpszKeyName);
		return ERROR_SUCCESS;
	}else{
		long	lError;
		HKEY	hkResult;
		DWORD	dwDisposition;

		lError = ::RegCreateKeyEx(hCurrentKey,
								lpszKeyName,
								0,
								NULL,
								REG_OPTION_NON_VOLATILE,
								KEY_ALL_ACCESS,
								NULL,
								&hkResult,
								&dwDisposition);
		if (lError != ERROR_SUCCESS) {
			::SetLastError(lError);
			return (HKEY) INVALID_HANDLE_VALUE;
		}

		return hkResult;
	}
}
INIFile::Key* INIFile::getKey(const std::string& sectionname, const std::string& keyname) const {
    INIFile::Section* curSection = getSection(sectionname);
    if(curSection == NULL) {
        return NULL;
    }

    return curSection->getKey(keyname);
}
/**
    This method returns a key iterator pointing at the first key in the specified section.
    \param  section the section to iterate over
    \return the iterator
*/
INIFile::KeyIterator INIFile::begin(const std::string& section) const {
	Section* curSection = getSection(section);
	if(curSection == NULL) {
		return KeyIterator(NULL);
	} else {
		return KeyIterator(curSection->KeyRoot);
	}
}
Esempio n. 12
0
void FifoIndex::insert(RowHandle *rh)
{
    RhSection *rs = getSection(rh);

    if (first_ == NULL) {
        rs->next_ = NULL;
        rs->prev_ = NULL;
        first_ = last_ = rh;
    } else {
        rs->next_ = NULL;
        rs->prev_ = last_;
        RhSection *lastrs = getSection(last_);
        lastrs->next_ = rh;
        last_ = rh;
    }
    ++size_;
}
Esempio n. 13
0
/**
	A IniFile::KeyListHandle can be used to list all keys of one section. This method opens the #IniFile::KeyListHandle.
	To iterate all keys use KeyList_GetNextKey(). #IniFile::KeyListHandle should be closed by KeyList_Close().
	If the section is empty IniFile::KeyList_EOF on the returned handle of IniFile::KeyList_Open(sectionname) is true.<br>
	<br>
	Example:<br>
	&nbsp;&nbsp;IniFile::KeyListHandle myHandle;<br>
	&nbsp;&nbsp;myHandle = myIniFile.KeyList_Open("Section1");<br>
	<br>
	&nbsp;&nbsp;while(!myIniFile.KeyList_EOF(myHandle)) {<br>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout << myIniFile.KeyList_GetNextKey(&myHandle) << std::endl;<br>
	&nbsp;&nbsp;}<br>
	<br>
	&nbsp;&nbsp;myIniFile.KeyList_Close(&myHandle);
	\param	sectionname	The name of the section
	\return	handle to this section
	\see	KeyList_Close, KeyList_GetNextKey, KeyList_EOF
*/
IniFile::KeyListHandle IniFile::KeyList_Open(std::string sectionname) {
	SectionEntry *curSection = getSection(sectionname);
	if(curSection == nullptr) {
		return nullptr;
	} else {
		return curSection->KeyRoot;
	}
}
Esempio n. 14
0
void CDirectiveConditional::Execute()
{
	bool b;

	switch (type)
	{
	case ConditionType::IFARM:
		b = Value == 1;
		Global.conditionData.addIf(b);
		break;
	case ConditionType::IFTHUMB:
		b = Value == 3;
		Global.conditionData.addIf(b);
		break;
	case ConditionType::IF:
		b = Value != 0;
		Global.conditionData.addIf(b);
		break;
	case ConditionType::ELSE:
		Global.conditionData.addElse();
		break;
	case ConditionType::ELSEIF:
		b = Value != 0;
		Global.conditionData.addElseIf(b);
		break;
	case ConditionType::ENDIF:
		Global.conditionData.addEndIf();
		break;
	case ConditionType::IFDEF:
		b = checkLabelDefined(labelName,getSection());
		Global.conditionData.addIf(b);
		break;
	case ConditionType::IFNDEF:
		b = !checkLabelDefined(labelName,getSection());
		Global.conditionData.addIf(b);
		break;
	case ConditionType::ELSEIFDEF:	
		b = checkLabelDefined(labelName,getSection());
		Global.conditionData.addElseIf(b);
		break;
	case ConditionType::ELSEIFNDEF:
		b = !checkLabelDefined(labelName,getSection());
		Global.conditionData.addElseIf(b);
		break;
	}
}
Esempio n. 15
0
bool ConfFile::hasSection(const std::string& section) {

    ConfSection* sec = getSection(section);

    if(sec==0) return false;

    return true;
}
Esempio n. 16
0
void ConfigFile::removeKey(const String &key, const String &section) {
	assert(isValidName(key));
	assert(isValidName(section));

	Section *s = getSection(section);
	if (s)
		 s->removeKey(key);
}
Esempio n. 17
0
/* Copy variant which takes an IVal */
void
copy(Uint32* dst, Uint32 srcFirstIVal)
{
  SegmentedSectionPtr p;
  getSection(p, srcFirstIVal);

  copy(dst, p);
}
Esempio n. 18
0
bool ConfigFile::hasKey(const String &key, const String &section) const {
	assert(isValidName(key));
	assert(isValidName(section));

	const Section *s = getSection(section);
	if (!s)
		return false;
	return s->hasKey(key);
}
Esempio n. 19
0
bool KLUPD::IniFile::createSection(const NoCaseString &sectionName, const NoCaseString &comment)
{
    if(getSection(sectionName))
        return false;

    m_sections.push_back(Section(sectionName, comment));
    m_dirty = true;
    return true;
}
Esempio n. 20
0
size_t IniReader::getKeyCount(const std::string & sectionName) const {
	
	const IniSection * section = getSection(sectionName);
	if(section) {
		return section->size();
	} else {
		return 0;
	}
}
/**
    This method checks whether the specified key exists in the specified section.
	\param	section			sectionname
	\param  key             keyname
	\return true, if the key exists, false otherwise
*/
bool INIFile::hasKey(const std::string& section, const std::string& key) const
{
	Section* curSection = getSection(section);
	if(curSection == NULL) {
		return false;
	} else {
        return curSection->hasKey(key);
	}
}
Esempio n. 22
0
RandomTileData::Section *RandomTileData::getSection(const char *name) {
	for (int i = 0; i < sectionCount; i++) {
		RandomTileData::Section *sect = getSection(i);

		if (sect->getNameList()->contains(name))
			return sect;
	}

	return 0;
}
Esempio n. 23
0
//get first entry in a section with a particular name
ConfEntry* ConfFile::getEntry(const std::string& section, const std::string& key) {

    ConfSection* sec = getSection(section);

    if(sec==0) return 0;

    ConfEntry* entry = sec->getEntry(key);

    return entry;
}
Esempio n. 24
0
//returns a list of all entries in a section with a particular name
ConfEntryList* ConfFile::getEntries(const std::string& section, const std::string& key) {

    ConfSection* sec = getSection(section);

    if(sec==0) return 0;

    ConfEntryList* entryList = sec->getEntries(key);

    return entryList;
}
Esempio n. 25
0
//returns the first section with a particular name
void ConfFile::setEntry(const std::string& section, const std::string& key, const std::string& value) {

    ConfSection* sec = getSection(section);

    if(sec==0) {
        sec = addSection(section);
    }

    sec->setEntry(key, value);
}
Esempio n. 26
0
void ConfigFile::renameSection(const String &oldName, const String &newName) {
	assert(isValidName(oldName));
	assert(isValidName(newName));

	Section *os = getSection(oldName);
	const Section *ns = getSection(newName);
	if (os) {
		// HACK: For now we just print a warning, for more info see the TODO
		// below.
		if (ns)
			warning("ConfigFile::renameSection: Section name \"%s\" already used", newName.c_str());
		else
			os->name = newName;
	}
	// TODO: Check here whether there already is a section with the
	// new name. Not sure how to cope with that case, we could:
	// - simply remove the existing "newName" section
	// - error out
	// - merge the two sections "oldName" and "newName"
}
void SettingsComponent::updatePossibleValues(const QString &sectionID, const QString &key, const QVariantList &possibleValues)
{
  SettingsSection* section = getSection(sectionID);
  if (!section)
  {
    QLOG_ERROR() << "Section" << sectionID << "is unknown";
    return;
  }
  section->updatePossibleValues(key, possibleValues);
  QLOG_DEBUG() << "Updated possible values for:" << key << "to" << possibleValues;
}
Esempio n. 28
0
RowHandle *FifoIndex::next(const RowHandle *cur) const
{
    if (cur == NULL || !cur->isInTable())
        return NULL;

    RhSection *rs = getSection(cur);
    if (type_->isReverse())
        return rs->prev_;
    else
        return rs->next_;
}
Esempio n. 29
0
void test_getSection(void)
{
   char* content = " echo \"\
[TcpClient] \n\
LogicName   = tcpClient1 \n\
DestIp      = 127.0.0.1 \n\
DestPort    = 1111 \n\
LocalPort   = 8888 \n\
\n\
[TcpClient] \n\
LogicName   = tcpClient2 \n\
DestIp      = 127.0.0.1 \n\
DestPort    = 2222 \n\
LocalPort   = 9999 \n\
\n\
[TcpClient] \n\
LogicName   = tcpClient3 \n\
DestIp      = 127.0.0.1 \n\
DestPort    = 3333 \n\
LocalPort   = 1234 \n\"        > commModule.conf";
   system(content);
   char section[MAX_LEN_SECTION] = {0};
   int ret = getSection("./commModule.conf", 0, "TcpClient", section);
   TEST_ASSERT_EQUAL_INT(3, ret);

   memset(section, 0, MAX_LEN_SECTION);
   ret = getSection("./commModule.conf", 1, "TcpClient", section);
   TEST_ASSERT_EQUAL_INT(TOOLS_SUCCESS, ret);
   TEST_ASSERT_EQUAL_STRING("[TcpClient] \nLogicName   = tcpClient1 \nDestIp      = 127.0.0.1 \nDestPort    = 1111 \nLocalPort   = 8888 \n\n", section);

   memset(section, 0, MAX_LEN_SECTION);
   ret = getSection("./commModule.conf", 2, "TcpClient", section);
   TEST_ASSERT_EQUAL_INT(TOOLS_SUCCESS, ret);
   TEST_ASSERT_EQUAL_STRING("[TcpClient] \nLogicName   = tcpClient2 \nDestIp      = 127.0.0.1 \nDestPort    = 2222 \nLocalPort   = 9999 \n\n", section);

   memset(section, 0, MAX_LEN_SECTION);
   ret = getSection("./commModule.conf", 3, "TcpClient", section);
   TEST_ASSERT_EQUAL_INT(TOOLS_SUCCESS, ret);
   TEST_ASSERT_EQUAL_STRING("[TcpClient] \nLogicName   = tcpClient3 \nDestIp      = 127.0.0.1 \nDestPort    = 3333 \nLocalPort   = 1234 \n\n", section);
}
Esempio n. 30
0
bool ConfigFile::getKey(const String &key, const String &section, String &value) const {
	assert(isValidName(key));
	assert(isValidName(section));

	const Section *s = getSection(section);
	if (!s)
		return false;
	const KeyValue *kv = s->getKey(key);
	if (!kv)
		return false;
	value = kv->value;
	return true;
}