diff options
author | David Robillard <d@drobilla.net> | 2012-04-11 23:43:57 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-04-11 23:43:57 +0000 |
commit | b716b49fd9e6943f8f6555931bb5997423de3fe5 (patch) | |
tree | 2117c11eb5dc372aaf9d624ebbc61370879f0720 /src/sratom.c | |
parent | d69e1fb5c865b09d134eb671a626165a019908d9 (diff) | |
download | sratom-b716b49fd9e6943f8f6555931bb5997423de3fe5.tar.gz sratom-b716b49fd9e6943f8f6555931bb5997423de3fe5.tar.bz2 sratom-b716b49fd9e6943f8f6555931bb5997423de3fe5.zip |
Save/restore atom:Chunk as base64Binary literals (not blank nodes).
git-svn-id: http://svn.drobilla.net/lad/trunk/sratom@4167 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/sratom.c')
-rw-r--r-- | src/sratom.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/sratom.c b/src/sratom.c index 556d4ed..7896e1b 100644 --- a/src/sratom.c +++ b/src/sratom.c @@ -157,12 +157,12 @@ list_end(SerdStatementSink sink, } static void -start_object(Sratom* sratom, - uint32_t flags, - const SerdNode* subject, - const SerdNode* predicate, - const SerdNode* node, - const char* type) +start_object(Sratom* sratom, + uint32_t flags, + const SerdNode* subject, + const SerdNode* predicate, + const SerdNode* node, + const char* type) { sratom->write_statement(sratom->handle, flags|SERD_ANON_O_BEGIN, NULL, subject, predicate, node, NULL, NULL); @@ -206,6 +206,9 @@ sratom_write(Sratom* sratom, object = serd_node_from_string(SERD_URI, USTR(NS_RDF "nil")); } else if (type_urid == sratom->forge.String) { object = serd_node_from_string(SERD_LITERAL, (const uint8_t*)body); + } else if (type_urid == sratom->forge.Chunk) { + datatype = serd_node_from_string(SERD_URI, NS_XSD "base64Binary"); + object = serd_node_new_blob(body, size, true); } else if (type_urid == sratom->forge.Literal) { LV2_Atom_Literal_Body* lit = (LV2_Atom_Literal_Body*)body; const uint8_t* str = USTR(lit + 1); @@ -531,6 +534,12 @@ read_node(Sratom* sratom, lv2_atom_forge_double(forge, serd_strtod(str, &endptr)); } else if (!strcmp(type_uri, (char*)NS_XSD "boolean")) { lv2_atom_forge_bool(forge, !strcmp(str, "true")); + } else if (!strcmp(type_uri, (char*)NS_XSD "base64Binary")) { + size_t size = 0; + void* body = serd_base64_decode(USTR(str), len, &size); + lv2_atom_forge_atom(forge, size, forge->Chunk); + lv2_atom_forge_write(forge, body, size); + free(body); } else if (!strcmp(type_uri, LV2_ATOM__Path)) { lv2_atom_forge_path(forge, str, len); } else if (!strcmp(type_uri, (char*)NS_MIDI "MidiEvent")) { |