From fd7449df22ebb98a7aa6e213d6d17bd6b295132f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20K=C4=99dzia?= <pawel.kedzia@pwr.wroc.pl>
Date: Thu, 24 Feb 2011 10:53:29 +0100
Subject: [PATCH] Added wrappers for tag, tagset and tagsetmanager.

---
 swig/boost_shared_ptr.i       | 23 ++++++++++++
 swig/libcclparser.i           | 29 +++++++++++++++
 swig/libcorpustag.i           | 55 ++++++++++++++++++++++++++++
 swig/libcorpustagset.i        | 69 +++++++++++++++++++++++++++++++++++
 swig/libcorpustagsetmanager.i | 31 ++++++++++++++++
 5 files changed, 207 insertions(+)
 create mode 100644 swig/boost_shared_ptr.i
 create mode 100644 swig/libcclparser.i
 create mode 100644 swig/libcorpustag.i
 create mode 100644 swig/libcorpustagset.i
 create mode 100644 swig/libcorpustagsetmanager.i

diff --git a/swig/boost_shared_ptr.i b/swig/boost_shared_ptr.i
new file mode 100644
index 0000000..1db8cbe
--- /dev/null
+++ b/swig/boost_shared_ptr.i
@@ -0,0 +1,23 @@
+/**
+ * Wrapper for boost shared_ptr
+ */
+#ifndef SWIG_BOOST_SHAREDPTR
+#define SWIG_BOOST_SHAREDPTR
+
+%module swig_boost_shared_ptr
+%{
+%}
+
+namespace boost {
+  template<class T> class shared_ptr {
+  public:
+    shared_ptr();
+    shared_ptr(T * p);
+    T* operator->();
+  private:
+    T * px;
+    int pn;
+  };
+}
+
+#endif /* SWIG_BOOST_SHAREDPTR */
diff --git a/swig/libcclparser.i b/swig/libcclparser.i
new file mode 100644
index 0000000..2b830cc
--- /dev/null
+++ b/swig/libcclparser.i
@@ -0,0 +1,29 @@
+#ifndef SWIG_LIBCCL_PARSER_I
+#define SWIG_LIBCCL_PARSER_I
+
+%module libcclparser
+%{
+  #include <libwccl/parser/Parser.h>
+%}
+
+%include "libcorpustagsetmanager.i"
+
+%include "std_string.i"
+%include "std_vector.i"
+
+namespace Wccl {
+  class Parser {
+  public:
+    Parser(const Corpus2::Tagset&);
+    ~TagsetManager();
+
+    /* --------------------------------------------------------------------- */
+  };
+
+  inline const Tagset& get_named_tagset(const std::string& name);
+}
+
+using namespace std;
+using namespace Corpus2;
+
+#endif /* SWIG_LIBCCL_PARSER_I */
diff --git a/swig/libcorpustag.i b/swig/libcorpustag.i
new file mode 100644
index 0000000..4184bca
--- /dev/null
+++ b/swig/libcorpustag.i
@@ -0,0 +1,55 @@
+#ifndef SWIG_LIBCORPUS2_TAG_I
+#define SWIG_LIBCORPUS2_TAG_I
+
+%module libcorpustag
+%{
+  #include <libcorpus2/tag.h>
+  #include <boost/cstdint.hpp>
+%}
+
+%include "std_string.i"
+%include "std_vector.i"
+
+/* Typedefs */
+%inline %{
+  typedef std::bitset<64> mask_t;
+%}
+
+%feature("notabstract") Corpus2::Tag;
+
+namespace Corpus2 {
+  class Tag {
+  public:
+    Tag();
+    explicit Tag(mask_t pos);
+    Tag(mask_t pos, mask_t values);
+
+    /* --------------------------------------------------------------------- */
+    ~Tag();
+
+    /* --------------------------------------------------------------------- */
+    bool is_null() const;
+    int pos_count() const;
+    int get_pos_index() const;
+
+    mask_t get_values() const;
+    mask_t get_pos() const;
+
+    Tag& combine_with(const Tag& other);
+    Tag get_combined(const Tag& other) const;
+    Tag& mask_with(const Tag& other);
+    Tag get_masked(const Tag& other);
+
+    std::string raw_dump() const;
+    bool operator<(const Tag& other) const;
+    bool operator==(const Tag& other) const;
+  };
+
+  size_t hash_value(const Tag &tag);
+}
+
+using namespace std;
+using namespace Corpus2;
+
+
+#endif /* SWIG_LIBCORPUS2_TAG_I */
diff --git a/swig/libcorpustagset.i b/swig/libcorpustagset.i
new file mode 100644
index 0000000..1e581d7
--- /dev/null
+++ b/swig/libcorpustagset.i
@@ -0,0 +1,69 @@
+#ifndef SWIG_LIBCORPUS2_TAGSET_I
+#define SWIG_LIBCORPUS2_TAGSET_I
+
+%module libcorpustagset
+%{
+  #include <libcorpus2/tagset.h>
+%}
+
+%include "libcorpustag.i"
+
+%include "std_string.i"
+%include "std_vector.i"
+
+%feature("notabstract") Corpus2::Tagset;
+
+namespace Corpus2 {
+  class Tagset {
+  public:
+    Tagset();
+    static Tagset from_data(const char*);
+
+    /* --------------------------------------------------------------------- */
+    Tag parse_symbol(const std::string& s) const;
+
+    /* --------------------------------------------------------------------- */
+    std::vector<Tag> parse_tag(const char* c, bool allow_extra) const;
+    Tag parse_simple_tag(const char* c, bool allow_extra) const;
+    Tag make_ign_tag() const;
+
+    /* --------------------------------------------------------------------- */
+    std::string tag_to_string(const Tag& tag) const;
+    std::string tag_to_no_opt_string(const Tag &tag) const;
+
+    /* --------------------------------------------------------------------- */
+    std::vector<std::string> tag_to_symbol_string_vector(const Tag& tag, bool 
+      compress_attribites = true) const;
+
+    std::string tag_to_symbol_string(const Tag& tag,
+      bool compress_attribites = true) const;
+
+    /* --------------------------------------------------------------------- */
+    size_t tag_size(const Tag& tag) const;
+    bool tag_is_singular(const Tag& tag) const;
+
+    /* --------------------------------------------------------------------- */
+    std::vector<Tag> split_tag(const Tag& tag) const;
+
+    /* --------------------------------------------------------------------- */
+    int pos_count() const;
+    int attribute_count() const;
+    int value_count() const;
+    size_t size() const;
+    
+    double size_extra() const;
+
+    /* --------------------------------------------------------------------- */
+    std::string name() const;
+    void set_name(const std::string& name);
+
+
+    std::string id_string() const;
+    std::string id_string(const Tag& tag) const;
+  };
+}
+
+using namespace std;
+using namespace Corpus2;
+
+#endif /* SWIG_LIBCORPUS2_TAGSET_I */
diff --git a/swig/libcorpustagsetmanager.i b/swig/libcorpustagsetmanager.i
new file mode 100644
index 0000000..07dcbbe
--- /dev/null
+++ b/swig/libcorpustagsetmanager.i
@@ -0,0 +1,31 @@
+#ifndef SWIG_LIBCORPUS2_TAGSETMANAGER_I
+#define SWIG_LIBCORPUS2_TAGSETMANAGER_I
+
+%module libcorpustagsetmanager
+%{
+  #include <libcorpus2/tagsetmanager.h>
+%}
+
+%include "libcorpustagset.i"
+
+%include "std_string.i"
+%include "std_vector.i"
+
+%feature("notabstract") Corpus2::TagsetManager;
+
+namespace Corpus2 {
+  class TagsetManager {
+  public:
+    TagsetManager();
+    ~TagsetManager();
+
+    /* --------------------------------------------------------------------- */
+  };
+
+  inline const Tagset& get_named_tagset(const std::string& name);
+}
+
+using namespace std;
+using namespace Corpus2;
+
+#endif /* SWIG_LIBCORPUS2_TAGSETMANAGER_I */
-- 
GitLab