On Jul 24, 1:41 pm, Victor Bazarov <v.Abaza...@comAcast.net> wrote:
Christopher wrote:
I couldn't get my mind around those English sentences, perhaps you could
put it in C++ (don't worry about compilability of your code for now)?
V
Conceptual without error handling considered:
// Basic name value pair
class Attribute
{
public:
Attribute();
~Attribute();
const std::string & GetName() const;
void SetName(const std::string & name);
template<typename T>
void SetValue(const T & value)
{
// use boost's lexical cast
}
template<typename T>
void GetValue(const std::string & name, T & value_out)
{
// use boost's lexical cast
}
private:
std::string name;
std::string value;
}
// Group of name value pairs
class AttributeGroup
{
public:
AttributeGroup();
~AttributeGroup();
const std::string & GetName() const;
void SetName(const std::string & name);
void InsertAttribute(const Attribute & attribute);
void RemoveAttribute(const std::string & name);
const Attribute & GetAttribute(const std::string & name) const;
// Questionable Code
void InsertAttributeGroup(const AttributeGroup & group);
void RemoveAttributeGroup(const std::string & name);
const AttributeGroup & GetAttributeGroup(const std::string & name)
const;
private:
std::string name;
typedef std::map<std::string, Attribute> AttributeMap;
// Questionable Code
typedef std::map<std::string, AttributeGroup> AttributeGroupMap;
}
you can easily contain such maps in the objects.