From bd6e5f17c38e0e0291fa40ad57a83b1009b76c08 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 5 Apr 2011 23:12:07 +0000 Subject: Make atom:String a simple C string (in UTF-8), and atom:Literal a full RDF literal. Bump version number. --- ext/atom.lv2/atom.h | 11 ++++---- ext/atom.lv2/atom.ttl | 69 ++++++++++++++++++++++++++++++++--------------- ext/atom.lv2/manifest.ttl | 2 ++ 3 files changed, 55 insertions(+), 27 deletions(-) (limited to 'ext/atom.lv2') diff --git a/ext/atom.lv2/atom.h b/ext/atom.lv2/atom.h index b39844b..d3fd7cf 100644 --- a/ext/atom.lv2/atom.h +++ b/ext/atom.lv2/atom.h @@ -88,12 +88,13 @@ typedef struct _LV2_Atom { typedef LV2_Atom LV2_Atom_Reference; /** - The body of an atom:String. + The body of an atom:Literal. */ -typedef struct _LV2_Atom_String { - uint32_t lang; /**< The ID of the language of this string */ - uint8_t str[]; /**< Null-terminated string data in UTF-8 encoding */ -} LV2_Atom_String; +typedef struct _LV2_Atom_Literal { + uint32_t datatype; /**< The ID of the datatype of this literal */ + uint32_t lang; /**< The ID of the language of this literal */ + uint8_t str[]; /**< Null-terminated string data in UTF-8 encoding */ +} LV2_Atom_Literal; /** The body of an atom:Vector. diff --git a/ext/atom.lv2/atom.ttl b/ext/atom.lv2/atom.ttl index 10b2aac..25318d9 100644 --- a/ext/atom.lv2/atom.ttl +++ b/ext/atom.lv2/atom.ttl @@ -1,6 +1,5 @@ - # LV2 Atom Extension -# Copyright (C) 2007-2010 David Robillard +# Copyright (C) 2007-2011 David Robillard # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -31,6 +30,10 @@ a lv2:Specification ; doap:name "LV2 Atom" ; + doap:release [ + doap:revision "0.1" ; + doap:created "2011-04-05" + ] ; doap:maintainer [ a foaf:Person ; foaf:name "David Robillard" ; @@ -125,41 +128,63 @@ atom:String a rdfs:Class ; rdfs:subClassOf atom:Atom ; rdfs:label "String" ; lv2:documentation """ -

A UTF-8 encoded string, with an optional language tag. An -LV2_Atom_String has an ID -lang followed by the string data in UTF-8 encoding. The length of the -string data in bytes is size - sizeof(uint32_t), including the -terminating NULL character. The lang may be any URI; to -describe a human language, use http://lexvo.org/id/term/LANG where LANG is -an ISO 693-2 or -ISO 693-3 language code.

+

A UTF-8 encoded string.

+ +

The body of an atom:String is a C string in UTF-8 encoding, i.e. an array of +bytes (uint8_t) terminated with a NULL byte ('\\0').

+ +

This type can be used for free-form strings, but in most cases it is better to +use atom:Literal since this supports a language tag or datatype. Implementations +SHOULD NOT use atom:String unless translating the string does not make sense and +the string has no meaningful datatype.

+""" . + + +atom:Literal a rdfs:Class ; + rdfs:subClassOf atom:Atom ; + rdfs:label "String Literal" ; + lv2:documentation """ +

A UTF-8 encoded string literal, with an optional language tag or datatype.

+ +

This type is compatible with an RDF literal and is capable of expressing a +string in any language, or a value of any type. An LV2_Atom_Literal has an ID lang and datatype followed by the +string data in UTF-8 encoding. The length of the string data in bytes is +size - (2 * sizeof(uint32_t)), including the terminating NULL +character. The lang field SHOULD be a URI of the form +<http://lexvo.org/id/term/LANG> where LANG is an ISO 693-2 or ISO 693-3 language code.

For example, "Hello" in English:

 struct LV2_Atom {
-    uint16_t type = uri_to_id(atom:String);
-    uint16_t size = 10;
+    uint16_t type = uri_to_id(atom:Literal);
+    uint16_t size = 14;
 }
-uint32_t lang  = uri_to_id("http://lexvo.org/id/term/en");
-char     str[] = "Hello";
+uint32_t datatype = 0;
+uint32_t lang     = uri_to_id("http://lexvo.org/id/term/en");
+char     str[]    = "Hello";
 
and French:
 struct LV2_Atom {
-    uint16_t type = uri_to_id(atom:String);
-    uint16_t size = 12;
+    uint16_t type = uri_to_id(atom:Literal);
+    uint16_t size = 16;
 }
-uint32_t lang  = uri_to_id("http://lexvo.org/id/term/fr");
-char     str[] = "Bonjour";
+uint32_t datatype = 0;
+uint32_t lang     = uri_to_id("http://lexvo.org/id/term/fr");
+char     str[]    = "Bonjour";
 

or a Turtle string:

 struct LV2_Atom {
-    uint16_t type = uri_to_id(atom:String);
-    uint16_t size = 60;
+    uint16_t type = uri_to_id(atom:Literal);
+    uint16_t size = 64;
 }
-uint32_t lang  = uri_to_id("http://www.w3.org/2008/turtle#turtle");
-char     str[] = "<http://example.org/foo> a <http://example.org/Thing> ."
+uint32_t datatype = uri_to_id("http://www.w3.org/2008/turtle#turtle");
+uint32_t lang     = 0;
+char     str[]    = "<http://example.org/foo> a <http://example.org/Thing> ."
 
""" . diff --git a/ext/atom.lv2/manifest.ttl b/ext/atom.lv2/manifest.ttl index 65a4e6e..d8488b1 100644 --- a/ext/atom.lv2/manifest.ttl +++ b/ext/atom.lv2/manifest.ttl @@ -3,5 +3,7 @@ a lv2:Specification ; + lv2:minorVersion 0 ; + lv2:microVersion 1 ; rdfs:seeAlso . -- cgit v1.2.1