[beast: 4/9] BST: add converters bst_it3m_seq_from_item_seq() and bst_item_seq_from_it3m_seq()



commit 845d219c91ccaed22ce92cfc7aab9e1a03c19c2b
Author: Tim Janik <timj gnu org>
Date:   Fri Sep 29 00:57:31 2017 +0200

    BST: add converters bst_it3m_seq_from_item_seq() and bst_item_seq_from_it3m_seq()
    
    Signed-off-by: Tim Janik <timj gnu org>

 beast-gtk/bstbseutils.cc |   18 ++++++++++++++++++
 beast-gtk/bstbseutils.hh |    3 +++
 2 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/beast-gtk/bstbseutils.cc b/beast-gtk/bstbseutils.cc
index d88b26e..aa6ca88 100644
--- a/beast-gtk/bstbseutils.cc
+++ b/beast-gtk/bstbseutils.cc
@@ -88,6 +88,24 @@ bst_path_leaf_index (const String &path, char separator)
   return d && d >= data && d < data + path.size() ? d - data + 1 : 0;
 }
 
+BseIt3mSeq*
+bst_it3m_seq_from_item_seq (Bse::ItemSeq &items)
+{
+  BseIt3mSeq *i3s = bse_it3m_seq_new();
+  for (auto item : items)
+    bse_it3m_seq_append (i3s, !item ? 0 : item.proxy_id());
+  return i3s;
+}
+
+Bse::ItemSeq
+bst_item_seq_from_it3m_seq (BseIt3mSeq *i3s)
+{
+  Bse::ItemSeq items;
+  for (size_t i = 0; i < i3s->n_items; i++)
+    items.push_back (Bse::ItemH::down_cast (bse_server.from_proxy (i3s->items[i])));
+  return items;
+}
+
 namespace Bse {
 
 const char*
diff --git a/beast-gtk/bstbseutils.hh b/beast-gtk/bstbseutils.hh
index be911bc..96f9b91 100644
--- a/beast-gtk/bstbseutils.hh
+++ b/beast-gtk/bstbseutils.hh
@@ -41,6 +41,9 @@ const gchar*    bst_procedure_get_title         (const gchar    *procedure);
 uint            bst_path_leaf_index             (const String &path, char separator = '/');
 Bse::Category   bst_category_find               (const String &pattern);
 
+BseIt3mSeq*     bst_it3m_seq_from_item_seq (Bse::ItemSeq &items);
+Bse::ItemSeq    bst_item_seq_from_it3m_seq (BseIt3mSeq *i3s);
+
 
 namespace Bse {
 const char*     error_blurb (Bse::Error error_value); ///< Retrieve the description of an error value


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]