使用Properties类带来的好处(二)

2014-11-23 20:14:35 · 作者: · 浏览: 8
cond.m_strValue;

else

throw properties_exception(

"Cound not get property value for " + convert_string< char_type, char>( strPropertyName) +

", since this property does not exist.");

}

void set_property( const string_type & strProperty, const string_type & strPropertyValue)

{

PropertiesCollection::iterator itFound = m_collProperties.find( strProperty);

if ( itFound == m_collProperties.end())

// 它是一个新的属性

m_aProperties.push_back( strProperty);

m_collProperties[ strProperty].m_strValue = strPropertyValue;

m_bIsDirty = true;

}

const string_type & get_property_comment( const string_type & strPropertyName) const

{

PropertiesCollection::const_iterator itFound = m_collProperties.find( strPropertyName);

if ( itFound != m_collProperties.end())

return itFound->second.m_strComment;

else

throw properties_exception(

"Cound not get property comment for " + convert_string< char_type, char>( strPropertyName) +

", since this property does not exist.");

}

void set_property_comment( const string_type & strPropertyName, const string_type & strPropertyComment)

{

PropertiesCollection::iterator itFound = m_collProperties.find( strPropertyName);

if ( itFound != m_collProperties.end())

itFound->second.m_strComment = strPropertyComment;

else

throw properties_exception(

"Cound not set property comment for " + convert_string< char_type, char>( strPropertyName) +

", since this property does not exist.");

m_bIsDirty = true;

}

private:

static const char_type get_delimeter() { return =; }

static const char_type get_comment() { return #; }

void read_properties()

{

const char DELIMETER = get_delimeter();

const char COMMENT = get_comment();

std::basic_ifstream< char_type> streamIn( m_strFileName.c_str());

string_type strLine;

string_type strComment;

while ( std::getline( streamIn, strLine))

{

strLine = trim_spaces( st