ardour
rdff.h
Go to the documentation of this file.
1 /*
2  RDFF - RDF in RIFF
3  Copyright 2011 David Robillard <http://drobilla.net>
4 
5  Permission to use, copy, modify, and/or distribute this software for any
6  purpose with or without fee is hereby granted, provided that the above
7  copyright notice and this permission notice appear in all copies.
8 
9  THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17 
18 #ifndef RDFF_RDFF_H
19 #define RDFF_RDFF_H
20 
21 #include <stdbool.h>
22 #include <stdint.h>
23 
24 #ifdef __GNUC__
25 # define PACKED __attribute__((__packed__))
26 #else
27 # define PACKED
28 #endif
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
37 typedef struct _RDFF* RDFF;
38 
42 typedef enum {
47 } RDFFStatus;
48 
52 typedef struct {
53  char type[4];
54  uint32_t size;
55  char data[];
56 } PACKED RDFFChunk;
57 
61 typedef struct {
62  uint32_t id;
63  char uri[];
64 } PACKED RDFFURIChunk;
65 
69 typedef struct {
70  uint32_t subject;
71  uint32_t predicate;
72  uint32_t object_type;
73  uint32_t object_size;
74  char object[];
75 } PACKED RDFFTripleChunk;
76 
80 RDFF
81 rdff_open(const char* path, bool write);
82 
87 rdff_write_uri(RDFF file,
88  uint32_t id,
89  uint32_t len,
90  const char* uri);
91 
96 rdff_write_triple(RDFF file,
97  uint32_t subject,
98  uint32_t predicate,
99  uint32_t object_type,
100  uint32_t object_size,
101  const void* object);
102 
112 rdff_read_chunk(RDFF file,
113  RDFFChunk** buf);
114 
118 bool
119 rdff_chunk_is_uri(RDFFChunk* chunk);
120 
124 bool
125 rdff_chunk_is_triple(RDFFChunk* chunk);
126 
131 void
132 rdff_close(RDFF file);
133 
134 #ifdef __cplusplus
135 } /* extern "C" */
136 #endif
137 
138 #endif /* RDFF_RDFF_H */
bool rdff_chunk_is_triple(RDFFChunk *chunk)
Definition: rdff.c:165
bool rdff_chunk_is_uri(RDFFChunk *chunk)
Definition: rdff.c:158
uint32_t subject
Definition: rdff.h:70
RDFFStatus rdff_write_uri(RDFF file, uint32_t id, uint32_t len, const char *uri)
Definition: rdff.c:90
uint32_t id
Definition: rdff.h:62
uint32_t object_size
Definition: rdff.h:73
Definition: rdff.h:52
RDFFStatus
Definition: rdff.h:42
Definition: rdff.c:32
uint32_t predicate
Definition: rdff.h:71
struct _RDFF * RDFF
Definition: rdff.h:37
RDFFStatus rdff_write_triple(RDFF file, uint32_t subject, uint32_t predicate, uint32_t object_type, uint32_t object_size, const void *object)
Definition: rdff.c:108
RDFFStatus rdff_read_chunk(RDFF file, RDFFChunk **buf)
Definition: rdff.c:131
uint32_t object_type
Definition: rdff.h:72
uint32_t size
Definition: rdff.h:54
RDFF rdff_open(const char *path, bool write)
Definition: rdff.c:39
void rdff_close(RDFF file)
Definition: rdff.c:171