Commit 1c8b0446 authored by schurade's avatar schurade
Browse files

[CHANGE] replaced vector with map in properties

parent 837c16cd
......@@ -41,55 +41,55 @@ WProperties::~WProperties()
void WProperties::addBool( std::string name, bool value, std::string shortDesc, std::string longDesc )
{
WProperty* prop = new WProperty( name, value, shortDesc, longDesc );
m_propertyList.push_back( prop );
m_propertyList[name] = prop;
}
void WProperties::addChar( std::string name, char value, std::string shortDesc, std::string longDesc )
{
WProperty* prop = new WProperty( name, value, shortDesc, longDesc );
m_propertyList.push_back( prop );
m_propertyList[name] = prop;
}
void WProperties::addInt( std::string name, int value, std::string shortDesc, std::string longDesc )
{
WProperty* prop = new WProperty( name, value, shortDesc, longDesc );
m_propertyList.push_back( prop );
m_propertyList[name] = prop;
}
void WProperties::addFloat( std::string name, float value, std::string shortDesc, std::string longDesc )
{
WProperty* prop = new WProperty( name, value, shortDesc, longDesc );
m_propertyList.push_back( prop );
m_propertyList[name] = prop;
}
void WProperties::addDouble( std::string name, double value, std::string shortDesc, std::string longDesc )
{
WProperty* prop = new WProperty( name, value, shortDesc, longDesc );
m_propertyList.push_back( prop );
m_propertyList[name] = prop;
}
void WProperties::addString( std::string name, std::string value, std::string shortDesc, std::string longDesc )
{
WProperty* prop = new WProperty( name, value, shortDesc, longDesc );
m_propertyList.push_back( prop );
m_propertyList[name] = prop;
}
WProperty* WProperties::findProp( std::string name )
{
for ( size_t i = 0 ; i < m_propertyList.size(); ++i)
if ( m_propertyList.count( name) != 0)
{
if ( m_propertyList[i]->getName() == name )
{
return m_propertyList[i];
}
return m_propertyList[name];
}
else
{
std::string msg( "Property doesn't exist: " + name );
WLogger::getLogger()->addLogMessage( msg, "Properties", LL_ERROR );
return 0;
}
WLogger::getLogger()->addLogMessage( "Property doesn't exist", "Properties", LL_ERROR );
std::cout << name << std::endl;
return 0;
}
......
......@@ -25,6 +25,7 @@
#ifndef WPROPERTIES_H
#define WPROPERTIES_H
#include <map>
#include <string>
#include <vector>
......@@ -74,7 +75,7 @@ public:
private:
WProperty* findProp( std::string name );
std::vector < WProperty* >m_propertyList;
std::map < std::string, WProperty* >m_propertyList;
};
#endif // WPROPERTIES_H
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