Re: [Re: [libxml++] UTF8 support]



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Le Mercredi 19 Mars 2003 15:41, Murray Cumming Comneon com a écrit :
> > From: Christophe de VIENNE [mailto:cdevienne alphacent com]
> > It seems (unless I misanderstood the thing) that the
> > templates implementation
> > don't have to be included in client code as long as the
> > templated class
> > instanciation is not done by the client code but by the lib.
> >
> > This way we wouldn't have to a heavy wrapping : only a few
> > typedef, and
> > provide functions to instanciate the different classes (which
> > is already done
> > for Node).
>
> Do you mean that typedefs would be just prototypes.
> Surely we need the actual declaration of a class to use its API?

I'm not sure what you mean but we would have in the header (very simplified) :

node.h (could be splitted in node.h, node_qt.h and node_glib.h):
- -------

template<typename String_t>
class Node {  // or maybe BaseNode
	public:
		String_t get_content();
}

namespace qt {
	typedef xmlpp::Node<QString> Node;
}

namespace glib {
	typedef xmlpp::Node<Glib::ustring> Node;
}



node_impl.[h|cc|whatever you like]:
- -----------------------------------

template<typename String_t>
String_t Node<String_t>::get_content()
{
	// actual implementation.
}


This second file would be included only in the lib, not in the client code, 
unless the client wants another string type of course.

> Could you give us a small
> example of client code that would use DomParser to parse a file?

This would look like this, I think :

int main() {

  auto_ptr<libxmlpp::qt::DomParser> parser ( libxmlpp::qt::getDomParser() );

  parser->parse(filename);

  /* etc. */
  
}



If valid, this solution is, I think, lighter than maintaining two libs.


Before discussing it more, I'll try to make a small example with a library 
containing a templated class implementation. I want to be 100% sure.

Regards,

Christophe
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+eIZGB+sU3TyOQjARAsDYAJ9j1VRehBjor/qZsWQZkYSZ8K4GuQCfT08d
pM+As1jbr/xdEpLepZamsCM=
=STE6
-----END PGP SIGNATURE-----





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]