implement the remaining attribute handling functions for Record<GenNode>
There is no generic implementation for these functions, since they are highly dependent on the payload used within Record<TY> Here we use Record<GenNode>, which turns the whole setup into an recursive data type; we especially rely on the fact that each GenNode has an embedded symbolic ID, and we use this ID to encode the 'key' for named attributes
This commit is contained in:
parent
96791d4a45
commit
33a6294a9b
1 changed files with 9 additions and 7 deletions
|
|
@ -366,44 +366,46 @@ namespace diff{
|
|||
|
||||
template<>
|
||||
inline bool
|
||||
Rec::isAttribute (GenNode const& v)
|
||||
Rec::isAttribute (GenNode const& attrib)
|
||||
{
|
||||
return false; ////TODO
|
||||
return attrib.isNamed();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline bool
|
||||
Rec::isTypeID (GenNode const& v)
|
||||
{
|
||||
return false; ////TODO
|
||||
return "type" == v.idi.getSym();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline string
|
||||
Rec::extractTypeID (GenNode const& v)
|
||||
{
|
||||
return "todo"; ////TODO
|
||||
return isTypeID(v)? v.data.get<string>()
|
||||
: Rec::TYPE_NIL;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline string
|
||||
Rec::extractKey (GenNode const& v)
|
||||
{
|
||||
return v.idi.getSym();
|
||||
return isAttribute(v)? v.idi.getSym()
|
||||
: "";
|
||||
}
|
||||
|
||||
template<>
|
||||
inline GenNode const&
|
||||
Rec::extractVal (GenNode const& v)
|
||||
{
|
||||
return GenNode(v); ///TODO
|
||||
return v;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline string
|
||||
Rec::renderAttribute (GenNode const& a)
|
||||
{
|
||||
return "notyet = todo"; ////TODO
|
||||
return a.idi.getSym() +" = "+string(a.data);
|
||||
}
|
||||
|
||||
template<>
|
||||
|
|
|
|||
Loading…
Reference in a new issue