Lv2Basics.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Lv2Basics.h - basic Lv2 utils
  3. *
  4. * Copyright (c) 2018-2020 Johannes Lorenz <jlsf2013$users.sourceforge.net, $=@>
  5. *
  6. * This file is part of LMMS - https://lmms.io
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public
  19. * License along with this program (see COPYING); if not, write to the
  20. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. * Boston, MA 02110-1301 USA.
  22. *
  23. */
  24. #ifndef LV2BASICS_H
  25. #define LV2BASICS_H
  26. #include "lmmsconfig.h"
  27. #ifdef LMMS_HAVE_LV2
  28. #include <lilv/lilv.h>
  29. #include <memory>
  30. #include <QString>
  31. #include <string>
  32. struct LilvNodeDeleter
  33. {
  34. void operator()(LilvNode* n) { lilv_node_free(n); }
  35. };
  36. struct LilvNodesDeleter
  37. {
  38. void operator()(LilvNodes* n) { lilv_nodes_free(n); }
  39. };
  40. using AutoLilvNode = std::unique_ptr<LilvNode, LilvNodeDeleter>;
  41. using AutoLilvNodes = std::unique_ptr<LilvNodes, LilvNodesDeleter>;
  42. /**
  43. Return QString from a plugin's node, everything will be freed automatically
  44. @param plug The plugin where the node is
  45. @param getFunc The function to return the node from the plugin
  46. */
  47. QString qStringFromPluginNode(const LilvPlugin* plug,
  48. LilvNode * (*getFunc)(const LilvPlugin*));
  49. //! Return port name as QString, everything will be freed automatically
  50. QString qStringFromPortName(const LilvPlugin* plug, const LilvPort* port);
  51. //! Return port name as std::string, everything will be freed automatically
  52. std::string stdStringFromPortName(const LilvPlugin* plug, const LilvPort* port);
  53. #endif // LMMS_HAVE_LV2
  54. #endif // LV2BASICS_H