From 1e01da451b279943ed51999ee06d64aba7c8faa2 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 4 Oct 2006 04:47:30 +0000 Subject: Bug fixes. Added copy to ingen (no cut or paste yet). Serialization work. git-svn-id: http://svn.drobilla.net/lad/ingen@153 a436a847-0d15-0410-975c-d299462d15a1 --- src/common/util/RedlandAtom.h | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/common/util') diff --git a/src/common/util/RedlandAtom.h b/src/common/util/RedlandAtom.h index df55affb..8d2456a5 100644 --- a/src/common/util/RedlandAtom.h +++ b/src/common/util/RedlandAtom.h @@ -17,6 +17,7 @@ #ifndef REDLAND_ATOM_H #define REDLAND_ATOM_H +#include #include #include #include "util/Atom.h" @@ -34,37 +35,35 @@ public: * Caller is responsible for calling free(triple->object). */ static void atom_to_triple_object(raptor_statement* triple, const Atom& atom) { - static const size_t STR_LENGTH = 32; // FIXME ? - char* str = (char*)malloc(sizeof(char) * STR_LENGTH); + std::ostringstream os; + + triple->object_literal_language = NULL; switch (atom.type()) { case Atom::INT: - snprintf(str, 32, "%d", atom.get_int32()); - triple->object = (unsigned char*)str; + os << atom.get_int32(); + triple->object = (unsigned char*)strdup(os.str().c_str()); triple->object_type = RAPTOR_IDENTIFIER_TYPE_LITERAL; triple->object_literal_datatype = raptor_new_uri( U("http://www.w3.org/2001/XMLSchema#integer")); break; case Atom::FLOAT: - snprintf(str, 32, "%f", atom.get_float()); - triple->object = (unsigned char*)str; + os << atom.get_float(); + triple->object = (unsigned char*)strdup(os.str().c_str()); triple->object_type = RAPTOR_IDENTIFIER_TYPE_LITERAL; triple->object_literal_datatype = raptor_new_uri( U("http://www.w3.org/2001/XMLSchema#float")); break; case Atom::STRING: - snprintf(str, 32, "%f", atom.get_float()); - triple->object = (unsigned char*)str; + triple->object = strdup(atom.get_string()); triple->object_type = RAPTOR_IDENTIFIER_TYPE_LITERAL; break; case Atom::BLOB: case Atom::NIL: default: - cerr << "WARNING: Unserializable atom!" << endl; - // FIXME: what to do? + cerr << "WARNING: Unserializable Atom!" << endl; triple->object = NULL; triple->object_type = RAPTOR_IDENTIFIER_TYPE_UNKNOWN; - free(str); // FIXME: ew } } -- cgit v1.2.1