Hi,
Below is the snippet code,
class Fcif;
class FcifNode {
public:
FcifNode (const string& val): value (val) {};
FcifNode (const Fcif& fcif): value (fcif) {};
FcifNode (const FcifNode& node): value (node.value) {};
FcifNode& operator= (const string& val)
{ value = val; return *this; };
FcifNode& operator= (const Fcif& val)
{ value = val; return *this; };
FcifNode& operator= (const FcifNode& val)
{ value = val.value; return *this; };
bool isValue () const
{ return (value.type () == typeid (string)); };
bool isFcif () const;
type_info const& type () const { return value.type (); };
string& getValue () const;
Fcif& getFcif () const;
string toString () const;
protected:
any value;
};
class Fcif: public map<string,FcifNode> {
public:
Fcif () { };
Fcif (const Fcif& fcif): map<string,FcifNode> (fcif) { };
Fcif (const string& fcifString);
string getValue (string const& name, bool required = true) const;
bool checkValue (string const& name, string& value) const;
bool setValue (string const& name, string const& value, bool escapeIt = true);
void setValue (Fcif const& fcif);
bool removeNode (string const& name, type_info const& type = typeid (void));
bool removeValue (string const& name)
{ return removeNode (name, typeid (string)); };
bool removeAggregate (string const& name)
{ return removeNode (name, typeid (Fcif)); };
bool setAggregate (string const& name, Fcif const& fcif);
Fcif* getAggregate (string const& name) const {
// auto-append '|' to name as needed
return const_cast<Fcif*>(this)->addAggregate (
name + ((name.empty () || name[name.size()-1] == '|') ? "" : "|") , false);
};
string toString () const;
void parseFcif (string const& fcifString);
private:
Fcif* addAggregate (string const& name, bool create = true);
Fcif parsePreFcif (string::const_iterator begin_pos, string::const_iterator& end_pos);
string extractTag (string const& name) const {
string::size_type tagpos = name.find_last_of ('|');
return name.substr (tagpos == string::npos ? 0 : tagpos + 1);
};
string extractAgg (string const& name) const {
string::size_type tagpos = name.find_last_of ('|');
return name.substr (0, tagpos == string::npos ? 0 : tagpos);
};
};
Regards,
Vijay
Can you please post at least a self-consisting code snippet which allows to
reproduce it...
Otherwise I doubt someone will help you with this...
Best Regards,
Ovanes
On Sun, Aug 28, 2011 at 7:57 AM, Vijay <v2k.sweet_at_[hidden]> wrote: