From 227d3b252cc551efa8d7d62d019fedf6e2532122 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20K=C4=99dzia?= <pawel.kedzia@pwr.wroc.pl>
Date: Wed, 11 May 2011 16:41:17 +0200
Subject: [PATCH] (swig) Added wrapper for Wccl::WcclFile

---
 swig/Makefile         |   5 +
 swig/libcclwcclfile.i | 261 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 266 insertions(+)
 create mode 100644 swig/libcclwcclfile.i

diff --git a/swig/Makefile b/swig/Makefile
index 2e94c98..7a89f04 100644
--- a/swig/Makefile
+++ b/swig/Makefile
@@ -72,6 +72,7 @@ CBINOUT=_libcclvalue.so \
 				_libccllexicon.so \
 				_libccllexicons.so \
 				_libcclwcclfileopsections.so \
+				_libcclwcclfile.so \
 				_wccl.so \
 				_boost_shared_ptr.so
 
@@ -102,6 +103,7 @@ CWRAP=libcclvalue_wrap.cxx \
 			libccllexicon_wrap.cxx \
 			libccllexicons_wrap.cxx \
 			libcclwcclfileopsections_wrap.cxx \
+			libcclwcclfile_wrap.cxx \
 			wccl_wrap.cxx \
 			boost_shared_ptr_wrap.cxx
 
@@ -132,6 +134,7 @@ CWRAPBIN=libcclvalue_wrap.o \
 				 libccllexicon_wrap.o \
 				 libccllexicons_wrap.o \
 				 libcclwcclfileopsections_wrap.o \
+				 libcclwcclfile_wrap.o \
 				 wccl_wrap.o \
 				 boost_shared_ptr_wrap.o
 
@@ -162,6 +165,7 @@ PYMODULES=libcclvalue.py \
 					libccllexicon.py \
 					libccllexicons.py \
 					libcclwcclfileopsections.py \
+					libcclwcclfile.py \
 					wccl.py \
 					boost_shared_ptr.py
 
@@ -192,6 +196,7 @@ PYCBIN=libcclvalue.pyc \
 			 libccllexicon.pyc \
 			 libccllexicons.pyc \
 			 libcclwcclfileopsections.pyc \
+			 libcclwcclfile.pyc \
 			 wccl.pyc \
 			 boost_shared_ptr.pyc
 
diff --git a/swig/libcclwcclfile.i b/swig/libcclwcclfile.i
new file mode 100644
index 0000000..81dda6a
--- /dev/null
+++ b/swig/libcclwcclfile.i
@@ -0,0 +1,261 @@
+#ifndef SWIG_LIBWCCL_WCCLFILE_I
+#define SWIG_LIBWCCL_WCCLFILE_I
+
+%module libcclwcclfile
+%{
+  #include <libwccl/wcclfile.h>
+%}
+
+%include "libcclbool.i"
+%include "libccltset.i"
+%include "libcclmatch.i"
+%include "libcclstrset.i"
+%include "libcclposition.i"
+%include "libccllexicon.i"
+%include "libccllexicons.i"
+%include "libccltagrulesequence.i"
+%include "libcclmatchrulesequence.i"
+%include "libcclfunctionaloperator.i"
+%include "libcclwcclfileopsections.i"
+%include "libcclfunctionalopsequence.i"
+
+%include "libcorpus/libcorpustagset.i"
+
+%include "std_string.i"
+%include "std_vector.i"
+%include "boost_shared_ptr.i"
+
+%template(UntypedOpSequencePtrVector) std::vector<boost::shared_ptr<Wccl::UntypedOpSequence> >;
+%template(BoolOpSequencePtrVector) std::vector<boost::shared_ptr<Wccl::OpSequence<Wccl::Bool> > >;
+%template(StrSetOpSequencePtrVector) std::vector<boost::shared_ptr<Wccl::OpSequence<Wccl::StrSet> > >;
+%template(TSetOpSequencePtrVector) std::vector<boost::shared_ptr<Wccl::OpSequence<Wccl::TSet> > >;
+%template(PositionOpSequencePtrVector) std::vector<boost::shared_ptr<Wccl::OpSequence<Wccl::Position> > >;
+%template(MatchOpSequencePtrVector) std::vector<boost::shared_ptr<Wccl::OpSequence<Wccl::Match> > >;
+
+%nodefaultctor Wccl::WcclFile;
+
+%template(OpSequenceStrSet) Wccl::WcclFileOpSections<Wccl::OpSequence<Wccl::StrSet> >;
+
+namespace Wccl {
+  class WcclFile 
+    : public WcclFileOpSections<UntypedOpSequence> /*,
+    WcclFileOpSections<OpSequence<StrSet> >,
+    WcclFileOpSections<OpSequence<TSet> >,
+    WcclFileOpSections<OpSequence<Bool> >,
+    WcclFileOpSections<OpSequence<Position> >,
+    WcclFileOpSections<OpSequence<Match> > 
+    */ {
+  public:
+    WcclFile(const Corpus2::Tagset& tagset, const std::string& search_path);
+
+    /* --------------------------------------------------------------------- */
+    /* --------------------------------------------------------------------- */
+    /* --------------------------------------------------------------------- */
+
+    /*
+    const std::vector<shared_ptr<UntypedOpSequence> >& untyped_sections();
+    */
+
+    /*
+    template<class T> const typename std::vector<shared_ptr<OpSequence<T> > >& sections();
+    %template(sections_bool) sections<Bool>;
+    %template(sections_tset) sections<TSet>;
+    %template(sections_strset) sections<StrSet>;
+    %template(sections_position) sections<Position>;
+    %template(sections_match) sections<Match>;
+    */
+
+    bool has_untyped_section(const std::string& name) const;
+
+    template<class T> bool has_section(const std::string& name) const;
+    %template(has_section_bool) has_section<Bool>;
+    %template(has_section_tset) has_section<TSet>;
+    %template(has_section_strset) has_section<StrSet>;
+    %template(has_section_position) has_section<Position>;
+    %template(has_section_match) has_section<Match>;
+    
+    /* --------------------------------------------------------------------- */
+  
+    std::vector<std::string> untyped_section_names() const;
+
+    template<class T> std::vector<std::string> section_names() const;
+    %template(section_names_bool) section_names<Bool>;
+    %template(section_names_tset) section_names<TSet>;
+    %template(section_names_strset) section_names<StrSet>;
+    %template(section_names_position) section_names<Position>;
+    %template(section_names_match) section_names<Match>;
+
+    /* --------------------------------------------------------------------- */
+
+    // const UntypedOpSequence& get_untyped_section(const std::string& name) const;
+    UntypedOpSequence& get_untyped_section(const std::string& name);
+
+    /* --------------------------------------------------------------------- */
+
+    // template<class T> const OpSequence<T>& get_section(const std::string& name) const;
+    template<class T> OpSequence<T>& get_section(const std::string& name);
+    %template(get_section_bool) get_section<Bool>;
+    %template(get_section_tset) get_section<TSet>;
+    %template(get_section_strset) get_section<StrSet>;
+    %template(get_section_position) get_section<Position>;
+    %template(get_section_match) get_section<Match>;
+    
+    shared_ptr<UntypedOpSequence> get_untyped_section_ptr(const std::string& name);
+    shared_ptr<const UntypedOpSequence> get_untyped_section_ptr(const std::string& name) const;
+    
+    /* --------------------------------------------------------------------- */
+
+    // template<class T> shared_ptr<const OpSequence<T> > get_section_ptr(const std::string& name) const;
+    template<class T> shared_ptr<OpSequence<T> > get_section_ptr(const std::string& name);
+    %template(get_section_ptr_bool) get_section_ptr<Bool>;
+    %template(get_section_ptr_tset) get_section_ptr<TSet>;
+    %template(get_section_ptr_strset) get_section_ptr<StrSet>;
+    %template(get_section_ptr_position) get_section_ptr<Position>;
+    %template(get_section_ptr_match) get_section_ptr<Match>;
+ 
+    /* --------------------------------------------------------------------- */
+
+    // const FunctionalOperator& get_untyped_op(const std::string& name, size_t idx = 0) const;
+    FunctionalOperator& get_untyped_op(const std::string& name, size_t idx = 0);
+    
+    /* --------------------------------------------------------------------- */
+
+    // template<class T> const Operator<T>& get_op(const std::string& name, size_t idx = 0) const;
+    template<class T> Operator<T>& get_op(const std::string& name, size_t idx = 0);
+    /*
+    %template(get_op_bool) get_op<Bool>;
+    %template(get_op_tset) get_op<TSet>;
+    %template(get_op_strset) get_op<StrSet>;
+    %template(get_op_position) get_op<Position>;
+    %template(get_op_match) get_op<Match>;
+    */
+    
+    /* --------------------------------------------------------------------- */
+
+    // shared_ptr<const FunctionalOperator> get_untyped_op_ptr(const std::string& name, size_t idx = 0) const;
+    shared_ptr<FunctionalOperator> get_untyped_op_ptr(const std::string& name, size_t idx = 0);
+
+    /* --------------------------------------------------------------------- */
+
+    // template<class T> shared_ptr<const Operator<T> > get_op_ptr(const std::string& name, size_t idx = 0) const;
+    template<class T> shared_ptr<Operator<T> > get_op_ptr(const std::string& name, size_t idx = 0);
+    %template(get_op_ptr_bool) get_op_ptr<Bool>;
+    %template(get_op_ptr_tset) get_op_ptr<TSet>;
+    %template(get_op_ptr_strset) get_op_ptr<StrSet>;
+    %template(get_op_ptr_position) get_op_ptr<Position>;
+    %template(get_op_ptr_match) get_op_ptr<Match>;
+
+    /* --------------------------------------------------------------------- */
+
+    UntypedOpSequence::name_op_v_t gen_name_untyped_op_pairs();
+    UntypedOpSequence::name_op_v_c_t gen_name_untyped_op_pairs() const;
+
+    /* --------------------------------------------------------------------- */
+
+    // template<class T> typename OpSequence<T>::name_op_v_c_t gen_name_op_pairs() const;
+    template<class T> typename OpSequence<T>::name_op_v_t gen_name_op_pairs();
+    %template(gen_name_op_pairs_bool) gen_name_op_pairs<Bool>;
+    %template(gen_name_op_pairs_tset) gen_name_op_pairs<TSet>;
+    %template(gen_name_op_pairs_strset) gen_name_op_pairs<StrSet>;
+    %template(gen_name_op_pairs_position) gen_name_op_pairs<Position>;
+    %template(gen_name_op_pairs_match) gen_name_op_pairs<Match>;
+
+    /* --------------------------------------------------------------------- */
+
+    // FunctionalOpSequence::name_op_v_c_t gen_all_op_pairs() const;
+    FunctionalOpSequence::name_op_v_t gen_all_op_pairs();
+
+
+    /* --------------------------------------------------------------------- */
+    /* --------------------------------------------------------------------- */
+    /* --------------------------------------------------------------------- */
+
+    bool has_lexicon(const std::string& name) const;
+    bool has_lexicons() const;
+
+    shared_ptr<const Lexicon> get_lexicon_ptr(const std::string& name) const;
+    const Lexicon& get_lexicon(const std::string& name) const;
+
+    shared_ptr<const Lexicons> get_lexicons_ptr() const;
+    const Lexicons& get_lexicons() const;
+
+    /* --------------------------------------------------------------------- */
+    /* --------------------------------------------------------------------- */
+    /* --------------------------------------------------------------------- */
+  
+    bool has_tag_rules() const;
+
+    const TagRuleSequence& get_tag_rules() const;
+
+    // shared_ptr<const TagRuleSequence> get_tag_rules_ptr() const;
+    shared_ptr<TagRuleSequence> get_tag_rules_ptr();
+
+    /* --------------------------------------------------------------------- */
+    /* --------------------------------------------------------------------- */
+    /* --------------------------------------------------------------------- */
+
+    bool has_match_rules() const;
+    
+    const MatchRuleSequence& get_match_rules() const;
+
+    // shared_ptr<const MatchRuleSequence> get_match_rules_ptr() const;
+    shared_ptr<MatchRuleSequence> get_match_rules_ptr();
+
+    /* --------------------------------------------------------------------- */
+    /* --------------------------------------------------------------------- */
+    /* --------------------------------------------------------------------- */
+
+    const Corpus2::Tagset& tagset() const;
+
+    /*
+    // const PwrNlp::PathSearcher<Wccl::FileNotFound> path() const { return path_; }
+    PwrNlp::PathSearcher<Wccl::FileNotFound> path(); 
+    */
+
+    /* --------------------------------------------------------------------- */
+    /* --------------------------------------------------------------------- */
+    /* --------------------------------------------------------------------- */
+
+    /*
+    // void add_untyped_section(const boost::shared_ptr<const UntypedOpSequence>& section);
+    void add_untyped_section(const shared_ptr<UntypedOpSequence>& section);
+    */
+
+    void add_untyped_section(const UntypedOpSequence& section);
+
+    /*
+    // template<class T> void add_section(const shared_ptr<const OpSequence<T> >& section);
+    template<class T> void add_section(const shared_ptr<OpSequence<T> >& section);
+    %template(add_section_ptr_bool) add_section<Bool>;
+    %template(add_section_ptr_tset) add_section<TSet>;
+    %template(add_section_ptr_strset) add_section<StrSet>;
+    %template(add_section_ptr_position) add_section<Position>;
+    %template(add_section_ptr_match) add_section<Match>;
+    */
+    
+    template<class T> void add_section(const OpSequence<T>& section);
+    %template(add_section_bool) add_section<Bool>;
+    %template(add_section_tset) add_section<TSet>;
+    %template(add_section_strset) add_section<StrSet>;
+    %template(add_section_position) add_section<Position>;
+    %template(add_section_match) add_section<Match>;
+
+    /*
+    void import_lexicon(const boost::shared_ptr<Lexicon>& lexicon);
+    */
+
+    /*
+    void set_tag_rules(const shared_ptr<TagRuleSequence>& tag_rules);
+    */
+
+    /*
+    void set_match_rules(const shared_ptr<MatchRuleSequence>& match_rules);
+    */
+  };
+}
+
+using namespace boost;
+using namespace Wccl;
+using namespace std;
+
+#endif /* SWIG_LIBWCCL_WCCLFILE_I */
-- 
GitLab