Commit fd5fb88e authored by Ellen Dekkers's avatar Ellen Dekkers

INIFile: added: get_entry and add_entry for std::vector<bool>

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@10484 383ad7c9-94d9-4d36-a494-682f7c89f535
parent c9849ccb
......@@ -357,6 +357,25 @@ void INIFile::add_entry( const QString & _section,
}
// -----------------------------------------------------------------------------
void INIFile::add_entry( const QString & _section,
const QString & _key,
const std::vector<bool> & _value)
{
QString list;
std::vector<bool>::const_iterator viter;
for(viter = _value.begin();viter!=_value.end();++viter){
if (*viter == true)
list += "true;";
else
list += "false;";
}
m_iniData[ _section ][ _key ] = list;
}
// -----------------------------------------------------------------------------
void INIFile::add_entry( const QString & _section,
......@@ -636,6 +655,42 @@ bool INIFile::get_entry( std::vector<double> & _val,
// -----------------------------------------------------------------------------
bool INIFile::get_entry( std::vector<bool> & _val,
const QString & _section,
const QString & _key ) const
{
SectionMap::const_iterator sIter;
EntryMap::const_iterator eIter;
_val.clear();
// does the given section exist?
if( (sIter = m_iniData.find( _section )) == m_iniData.end() )
return false;
// does the given entry exist?
if( (eIter = sIter->second.find( _key )) == sIter->second.end() )
return false;
QStringList list = eIter->second.split(';');
bool ok = true;
for ( int i = 0 ; i < list.size(); ++i) {
if ( list[i].isEmpty() )
continue;
if (list[i] == "true")
_val.push_back(true);
else
_val.push_back(false);
}
return ok;
}
// -----------------------------------------------------------------------------
bool INIFile::get_entry( std::vector<int> & _val,
const QString & _section,
const QString & _key ) const
......@@ -668,9 +723,12 @@ bool INIFile::get_entry( std::vector<int> & _val,
}
// -----------------------------------------------------------------------------
bool INIFile::get_entry( std::vector<QString> & _val,
const QString & _section,
const QString & _key ) const
const QString & _section,
const QString & _key ) const
{
SectionMap::const_iterator sIter;
EntryMap::const_iterator eIter;
......@@ -697,9 +755,13 @@ bool INIFile::get_entry( std::vector<QString> & _val,
return ok;
}
// -----------------------------------------------------------------------------
bool INIFile::get_entry( QStringList & _val,
const QString & _section,
const QString & _key ) const
const QString & _section,
const QString & _key ) const
{
SectionMap::const_iterator sIter;
EntryMap::const_iterator eIter;
......@@ -722,3 +784,7 @@ bool INIFile::get_entry( QStringList & _val,
return ok;
}
// -----------------------------------------------------------------------------
......@@ -191,6 +191,11 @@ public :
void add_entry( const QString & _section,
const QString & _key ,
const std::vector<double> & _value);
//! Addition / modification of a bool vector
void add_entry( const QString & _section,
const QString & _key ,
const std::vector<bool> & _value);
//! Addition of a Vec_n_something
template < typename VectorT >
......@@ -282,6 +287,11 @@ public :
bool get_entry( std::vector<double> & _val,
const QString & _section,
const QString & _key) const;
//! Access to a bool vector
bool get_entry( std::vector<bool> & _val,
const QString & _section,
const QString & _key) const;
//! Access to an int vector
bool get_entry( std::vector<int> & _val,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment