Skip to content
Snippets Groups Projects
libcclwcclfileopsections.i 3.39 KiB
Newer Older
#ifndef SWIG_LIBWCCL_WCCLFILEOPSECTIONS_I
#define SWIG_LIBWCCL_WCCLFILEOPSECTIONS_I

%module libcclwcclfileopsections
%{
  #include <libwccl/wcclfileopsections.h>
%}

%include "libcclbool.i"
%include "libcclmatch.i"
%include "libcclposition.i"
%include "libcclstrset.i"
%include "libccltset.i"
%include "libcclvalue.i"
%include "libcclfunctionalopsequence.i"

%include "std_string.i"
%include "std_vector.i"
%include "boost_shared_ptr.i"

namespace Wccl {
  template<class T> class WcclFileOpSections {
  public:
    typedef typename T::op_t op_t;
    typedef typename boost::shared_ptr<op_t> op_ptr_t;
    typedef typename boost::shared_ptr<const op_t> op_ptr_c_t;
    typedef typename boost::shared_ptr<T> ptr_t;
    typedef typename boost::shared_ptr<const T> ptr_c_t;
    typedef typename std::vector<ptr_t> ptr_v_t;
    typedef typename boost::unordered_map<std::string, ptr_t> map_t;
    typedef typename T::name_op_v_t name_op_v_t;
    typedef typename T::name_op_v_c_t name_op_v_c_t;
    /* --------------------------------------------------------------------- */

  protected:  
    bool has_section(const std::string& name) const;
    const ptr_v_t& sections();
    /* --------------------------------------------------------------------- */
  
    size_t size() const;
    bool empty() const;
    /* --------------------------------------------------------------------- */

    std::vector<std::string> section_names() const;
    /* --------------------------------------------------------------------- */

    T& get_section(const std::string& name);
    const T& get_section(const std::string& name) const;
    /* --------------------------------------------------------------------- */

    ptr_t get_section_ptr(const std::string& name);
    ptr_c_t get_section_ptr(const std::string& name) const;
    /* --------------------------------------------------------------------- */

    op_t& get_op(const std::string& name, size_t idx = 0);
    const op_t& get_op(const std::string& name, size_t idx = 0) const;
    /* --------------------------------------------------------------------- */

    op_ptr_t get_op_ptr(const std::string& name, size_t idx = 0);
    op_ptr_c_t get_op_ptr(const std::string& name, size_t idx = 0) const;
    /* --------------------------------------------------------------------- */

    name_op_v_t& add_name_op_pairs(name_op_v_t& pairs);
    name_op_v_c_t& add_name_op_pairs(name_op_v_c_t& pairs) const;
    /* --------------------------------------------------------------------- */

    name_op_v_t gen_name_op_pairs();
    name_op_v_c_t gen_name_op_pairs() const;
    /* --------------------------------------------------------------------- */
  
    WcclFileOpSections();

    void append(const ptr_t& section);
    /* --------------------------------------------------------------------- */
  };

  %template(UntypedOpSequenceWcclFileOpSections) WcclFileOpSections<UntypedOpSequence>;
  %template(StrSetOpSequence) WcclFileOpSections<OpSequence<StrSet> >;
  %template(TSetOpSequence) WcclFileOpSections<OpSequence<TSet> >;
  %template(BoolOpSequence) WcclFileOpSections<OpSequence<Bool> >;
  %template(PositionOpSequence) WcclFileOpSections<OpSequence<Position> >;
  %template(MatchOpSequence) WcclFileOpSections<OpSequence<Match> >;
Paweł Kędzia's avatar
Paweł Kędzia committed

  %template(OpSequenceStrSet) Wccl::WcclFileOpSections<Wccl::OpSequence<Wccl::StrSet> >;
}

using namespace std;
using namespace Wccl;

#endif /* SWIG_LIBWCCL_WCCLFILEOPSECTIONS_I */