|
Boost : |
From: Reece Dunn (msclrhd_at_[hidden])
Date: 2005-11-05 16:43:15
Stefan Seefeld wrote:
> So we agree then, fine. I suggest 'append_comment("foo")' while someone else
> proposed to overload the 'append' name, using something like 'append(comment("foo"))'
> instead, which would imply explicit node creation, as opposed to nodes being
> created by factories (such as document and element).
It is possible to support append( comment( "foo" )) *and* factories:
template< typename NodeType >
struct node_constructor
{
typedef NodeType type;
std::string value;
node_constructor( const std::string & str ): value( str )
{
}
};
node_constructor< comment_factory > comment( const std::string & str )
{
return node_constructor< comment_factory >( str );
}
node_constructor< cdata_factory > cdata( const std::string & str )
{
return node_constructor< cdata_factory >( str );
}
struct element
{
template< typename Factory >
void append( const node_constructor< Factory > & cons )
{
// call the factory here...
Factory::make_node( ..., cons.value );
}
};
This would make it easier to support push_back( cdata( "foo<bar>" )),
etc. without having _comment, _cdata, etc. variants for each insertion
function.
- Reece
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk