[redland-dev] librdf_node_get_type

Dave Beckett dave.beckett at bristol.ac.uk
Wed Oct 27 10:43:09 BST 2004


On Tue, 26 Oct 2004 16:47:41 +1300, Rodney Tamblyn <rodney at stonebow.otago.ac.nz> wrote:

> http://librdf.org/docs/api/r3762.html
> >librdf_node_type librdf_node_get_type (librdf_node* node);
> 
> The API docs say this returns the type of the node, does it return type
> information as a string?

The API says:
librdf_node_type librdf_node_get_type(librdf_node* node);

and the return is an enum.

> When I call following, where node is a valid node, I get a crash:
> 
> *retstring = (char *) librdf_node_get_type(node);

Yes, that would be why - turning a small integer into a char*

I suggest you use librdf_node_is_resource, librdf_node_is_literal for testing
since it's more common you want to just check one thing.

If you want to use the node type enum, you can.  The other
thing that you might want to do is print out a node for debugging,
and there is 
  void librdf_node_print(librdf_node* node, FILE *fh)
and
  unsigned char *librdf_node_to_string(librdf_node* node)
for that.

Dave



More information about the redland-dev mailing list