28 #include <lv2/lv2plug.in/ns/ext/atom/atom.h>
29 #include <lv2/lv2plug.in/ns/ext/atom/forge.h>
30 #include <lv2/lv2plug.in/ns/ext/atom/util.h>
36 typedef LV2_Atom_Forge_Frame ForgeFrame;
37 typedef LV2_Atom_Forge_Ref ForgeRef;
38 typedef LV2_Atom_Object_Query ObjectQuery;
47 AtomObject (
const void* atom) : p_obj ((LV2_Atom_Object*) atom) { }
50 AtomObject (ForgeRef ref) : p_obj ((LV2_Atom_Object*) ref) { }
58 return p_obj->body.otype;
65 return p_obj->body.id;
72 return lv2_atom_total_size ((LV2_Atom*) p_obj);
90 lv2_atom_object_query (p_obj, &query);
94 inline LV2_Atom_Object* cobj()
const {
return p_obj; }
97 inline operator LV2_Atom_Object*() {
return p_obj; }
109 LV2_Atom_Object* p_obj;
123 Atom (
const void* atom) : p_atom ((LV2_Atom*) atom) { }
126 Atom (ForgeRef ref) : p_atom ((LV2_Atom*) ref) { }
132 inline static uint32_t
135 return lv2_atom_pad_size (size);
142 return lv2_atom_is_null (p_atom);
149 return LV2_ATOM_BODY (p_atom);
156 return ((LV2_Atom_Float*)p_atom)->body;
162 return AtomObject ((LV2_Atom_Object* ) p_atom);
169 return (
const char*) LV2_ATOM_BODY (p_atom);
176 return ((LV2_Atom_Int*)p_atom)->body;
183 return ((LV2_Atom_Long*)p_atom)->body;
190 return ((LV2_Atom_URID*)p_atom)->body;
204 return lv2_atom_total_size (p_atom);
216 inline const LV2_Atom*
223 inline operator const LV2_Atom*() {
return cobj(); }
227 operator= (
const Atom& other)
229 p_atom = other.p_atom;
235 operator== (
Atom& other)
237 return lv2_atom_equals (
cobj(), other.cobj());
242 const LV2_Atom* p_atom;
243 friend class AtomObject;
252 AtomSequence (
const void* slab) : p_seq ((LV2_Atom_Sequence*) slab) { }
264 return p_seq->body.pad;
271 return p_seq->atom.size;
278 return p_seq->body.unit;
282 inline LV2_Atom_Sequence*
289 inline operator LV2_Atom_Sequence*()
const {
return p_seq; }
292 inline operator uint8_t*()
const {
return (uint8_t*) p_seq; }
296 LV2_Atom_Sequence* p_seq;
324 lv2_atom_forge_init (&forge, map);
330 inline LV2_Atom_Forge*
340 return lv2_atom_forge_sequence_head (&forge, &frame, unit);
343 inline operator LV2_Atom_Forge* () {
return cobj(); }
353 lv2_atom_forge_set_buffer (&forge, buf, size);
360 return lv2_atom_forge_beat_time (&forge, beats);
369 return lv2_atom_forge_frame_time (&forge, frames);
373 property_head (uint32_t key, uint32_t context)
375 return lv2_atom_forge_property_head (&forge, key, context);
379 pop (ForgeFrame& frame)
381 lv2_atom_forge_pop (&forge, &frame);
393 return lv2_atom_forge_atom (&forge, size, type);
404 return lv2_atom_forge_path (&forge, path.c_str(), path.size());
418 return lv2_atom_forge_resource (&forge, &frame,
id, otype);
422 write_blank (ForgeFrame& frame, uint32_t
id, uint32_t otype)
425 return lv2_atom_forge_blank (&forge, &frame,
id, otype);
429 write_bool (
const bool val)
431 return lv2_atom_forge_bool (&forge, val);
435 write_int (
const int val)
437 return lv2_atom_forge_int (&forge, val);
442 write_float (
const float val)
444 return lv2_atom_forge_float (&forge, val);
448 write_long (
const int64_t val)
450 return lv2_atom_forge_long (&forge, val);
454 write_string (
const char* str)
456 return lv2_atom_forge_string (&forge, str, strlen (str));
460 write_uri (
const char* uri)
462 return lv2_atom_forge_uri (&forge, uri, strlen (uri));
466 write_raw (
const void* data, uint32_t size)
468 return lv2_atom_forge_raw (&forge, data, size);
472 write_urid (LV2_URID
id)
474 return lv2_atom_forge_urid (&forge,
id);
479 LV2_Atom_Forge forge;