Example #1
0
	void RuleEvaluator::extractSection_(INIFile& file, const String& symbol)
		
	{
		// assemble the section name
		String section_name(prefix_ + ":" + symbol);

		// abort if the INI file does not contain the requested section
		if (!file.hasSection(section_name))
		{
			return;
		}

		// create a new entry for symbol
		if (!rule_map_.has(symbol))
		{
			rule_map_.insert(symbol, list<pair<Expression, String> >());
		}

		// iterate over all lines of the respective section
		INIFile::LineIterator it = file.getSectionFirstLine(section_name);
		++it;//skip section line
		for (; +it ; it.getSectionNextLine())
		{
			String line(*it);
			// empty lines or comment lines (starting with ';' or '#') are ignored
			if (line.has('=') && (line[0] != ';') && (line[0] != '#'))
			{
				if (line[0] == '=')
				{
					Log.error() << "RuleEvaluator:: invalid rule in line: " << line << endl;
					continue;
				}

				String value = line.before("=");	
				String expression_string;
				if (line.after("=").isValid())
				{
					expression_string = line.after("=");
				}
				expression_string.trim();
				value.trim();

				// push the expression into the list
				rule_map_[symbol].push_back(pair<Expression, String>(Expression(expression_string), value));
			}
		}
	}
Example #2
0
	it = ini.getLine(4);
  TEST_EQUAL(ini.setLine(it, "test"), false)

	INIFile emptyFile;
	it = emptyFile.getLine(0);
  TEST_EQUAL(emptyFile.setLine(it, "test"), false)
RESULT

CHECK(bool deleteLine(LineIterator line_it))
	INIFile ini(BALL_TEST_DATA_PATH(INIFile_test.ini));
	ini.read();

	INIFile::LineIterator it;
	TEST_EQUAL(ini.deleteLine(it), false)
	
	it = ini.getSectionFirstLine("Section3");
  ++it;	++it;
	TEST_EQUAL(+it, true)
	TEST_EQUAL(*it, "test2=b")
	TEST_EQUAL(ini.deleteLine(it), true)

	TEST_EQUAL(ini.hasEntry("Section3", "test2"), false)
  TEST_EQUAL(ini.getValue("Section3", "test2"), ini.UNDEFINED)
  TEST_EQUAL(ini.getSectionLength("Section3"), 4)

	it = ini.getLine(4);
	TEST_EQUAL(ini.deleteLine(it), false)

	INIFile emptyFile;
	it = emptyFile.getLine(0);
  TEST_EQUAL(emptyFile.deleteLine(it), false)