Audacity 3.2.0
LV2Utils.h
Go to the documentation of this file.
1/*!********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file LV2Utils.h
6
7 @brief RAII for lv2 resources
8
9 Paul Licameli split from LV2Symbols.h
10
11*********************************************************************/
12
13#ifndef __AUDACITY__LV2__UTILS__
14#define __AUDACITY__LV2__UTILS__
15
16#include <memory>
17#include <wx/string.h>
18#include "lilv/lilv.h" // for lilv_free
19
21template<typename Type, void (*f)(Type*)>
22struct Lilv_deleter { void operator()(Type *p) noexcept { f(p); } };
23
25template<typename Type, void (*f)(Type*)>
26using Lilv_ptr = std::unique_ptr<Type, Lilv_deleter<Type, f>>;
27
28static inline void free_chars (char *p) { lilv_free(p); }
30
34
37inline wxString LilvString(const LilvNode *node)
38{
39 return wxString::FromUTF8(lilv_node_as_string(node));
40};
41
45inline wxString LilvStringMove(LilvNode *node)
46{
47 LilvNodePtr temp{ node };
48 wxString str = LilvString(node);
49 return str;
50};
51
52#endif
#define str(a)
wxString LilvString(const LilvNode *node)
Definition: LV2Utils.h:37
std::unique_ptr< Type, Lilv_deleter< Type, f > > Lilv_ptr
Generate classes of smart pointers to lv2 resources.
Definition: LV2Utils.h:26
wxString LilvStringMove(LilvNode *node)
Definition: LV2Utils.h:45
Lilv_ptr< LilvNode, lilv_node_free > LilvNodePtr
Definition: LV2Utils.h:33
static void free_chars(char *p)
Definition: LV2Utils.h:28
Lilv_ptr< char, free_chars > LilvCharsPtr
Definition: LV2Utils.h:29
Generate deleter classes for smart pointers to lv2 resources.
Definition: LV2Utils.h:22
void operator()(Type *p) noexcept
Definition: LV2Utils.h:22