diff options
author | David Robillard <d@drobilla.net> | 2006-10-04 04:47:30 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2006-10-04 04:47:30 +0000 |
commit | 1e01da451b279943ed51999ee06d64aba7c8faa2 (patch) | |
tree | f97067381f13b11a9e8f90284ac429b302f4d7a7 /src/common | |
parent | 91d5cb109563c67bdad5f3ebeaafc8e1e8f7e14a (diff) | |
download | ingen-1e01da451b279943ed51999ee06d64aba7c8faa2.tar.gz ingen-1e01da451b279943ed51999ee06d64aba7c8faa2.tar.bz2 ingen-1e01da451b279943ed51999ee06d64aba7c8faa2.zip |
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
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/util/RedlandAtom.h | 21 |
1 files changed, 10 insertions, 11 deletions
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 <sstream> #include <cstring> #include <raptor.h> #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 } } |