Esempio n. 1
0
/**
 * raptor_new_iostream_from_handler:
 * @context: pointer to context information to pass in to calls
 * @handler: pointer to handler methods
 *
 * Create a new iostream over a user-defined handler.
 *
 * @deprecated: Use raptor_new_iostream_from_handler2() instead
 *
 * Return value: new #raptor_iostream object or NULL on failure
 **/
raptor_iostream*
raptor_new_iostream_from_handler(void *user_data,
                                 const raptor_iostream_handler *handler)
{
  raptor_iostream* iostr=NULL;
  raptor_iostream_handler2 *handler2;

  if(!handler)
    return NULL;

  handler2=(raptor_iostream_handler2*)RAPTOR_CALLOC(raptor_iostream_handler2, 1,
                                                   sizeof(raptor_iostream_handler2*));
  if(!handler2)
    return NULL;
  
  /* Copy V1 functions to V2 structure */
  handler2->init        = handler->init;
  handler2->finish      = handler->finish;
  handler2->write_byte  = handler->write_byte;
  handler2->write_bytes = handler->write_bytes;
  handler2->write_end   = handler->write_end;

  iostr=raptor_new_iostream_from_handler2(user_data, handler2);
  if(iostr) {
    /* Ensure newly alloced structure is freed on iostream destruction */
    iostr->flags |= RAPTOR_IOSTREAM_FLAGS_FREE_HANDLER;
  } else
    /* failure: so delete it now */
    RAPTOR_FREE(raptor_iostream_handler2, handler2);

  return iostr;
}
    bool UTOPIASerializer::serialize(Serializer::Context& ctx, QIODevice& stream_, Node* node_) const
    {
        QMap< Node*, int > nodeIDs;

        raptor_iostream_handler2 QIODeviceHandler = {
            2,
            qiodevice_iostream_init,
            qiodevice_iostream_finish,
            qiodevice_iostream_write_byte,
            qiodevice_iostream_write_bytes,
            qiodevice_iostream_write_end,
            0,
            0
        };

        // FIXME base uri?
//        raptor_uri* base_uri = raptor_new_uri((const unsigned char*) "HAHAHA");

//         raptor_serializer* rdf_serializer = raptor_new_serializer("rdfxml");
        raptor_serializer* rdf_serializer = raptor_new_serializer("ntriples");
        raptor_iostream* qiodevice_iostream = raptor_new_iostream_from_handler2(&stream_, &QIODeviceHandler);
        raptor_serialize_set_namespace(rdf_serializer, raptor_new_uri((const unsigned char*) "http://utopia.cs.manchester.ac.uk/2007/03/utopia-system#"), (const unsigned char*) "system");
        raptor_serialize_set_namespace(rdf_serializer, raptor_new_uri((const unsigned char*) "http://utopia.cs.manchester.ac.uk/2007/03/utopia-domain#"), (const unsigned char*) "domain");
        raptor_serialize_start(rdf_serializer, 0 /*base_uri*/, qiodevice_iostream);

        serialiseNode(rdf_serializer, nodeIDs, node_, true);

        raptor_serialize_end(rdf_serializer);

        return true;
    }
Esempio n. 3
0
/**
 * raptor_new_iostream_from_sink:
 *
 * Create a new read iostream from a sink.
 * 
 * Return value: new #raptor_iostream object or NULL on failure
 **/
raptor_iostream*
raptor_new_iostream_from_sink(void)
{
  return raptor_new_iostream_from_handler2(NULL, &raptor_iostream_sink_handler);
}