INCLUDE(CPack)
#FIND_PACKAGE(SWIG REQUIRED)
-
+MESSAGE(STATUS "Looking modules in ${CMAKE_MODULE_PATH}")
FIND_PROGRAM(SWIG_EXECUTABLE
NAMES swig-1.3 swig
PATHS ${SWIG_DIR} ${SWIG_DIR}/.. ${SWIG_DIR}/../../bin /usr/bin /usr/local/bin ${CMAKE_INSTALL_PREFIX}/bin
--- /dev/null
+
+require 'rzypp'
+include Rzypp
+
+a = Arch.new("i386")
+puts a.to_s
+#exit
+
+z = ZYppFactory::instance.get_zypp
+
+manager = RepoManager.new
+
+manager.known_repositories.each do | repo |
+ repo.base_urls.each do | url |
+ puts url.to_s
+ end
+end
+
/** accessors needed by solver/zmd */
/** Deprecated */
std::string index() const;
- /** Deprecated, defaults to Rel::NONE */
- Rel op() const;
- /** Deprecated, defaults to Edition::noedition */
- Edition edition() const;
-
+
private:
typedef capability::CapabilityImpl Impl;
typedef capability::CapabilityImpl_Ptr Impl_Ptr ;
--- /dev/null
+
+%template(UrlSet) std::set<Url>;
+
+class RepoInfo
+ {
+ friend std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
+
+ public:
+ RepoInfo();
+ ~RepoInfo();
+
+ /**
+ * unique identifier for this source. If not specified
+ * It should be generated from the base url.
+ *
+ * Normally, in a .repo file the section name is used
+ * ( [somerepo] )
+ */
+ std::string alias() const;
+
+ /**
+ * A Url under which the metadata are located, or a set of mirrors.
+ *
+ * This can't be empty in order the repository to be valid
+ * unless the download of the mirror list succeeds and it
+ * contains a valid url.
+ */
+ std::set<Url> baseUrls() const;
+
+ /**
+ * Url of a file which contains a list of Urls
+ * If empty, the base url will be used.
+ */
+ Url mirrorListUrl() const;
+
+ typedef std::set<Url>::const_iterator urls_const_iterator;
+
+ /**
+ * iterator that points at begin of repository urls
+ */
+ urls_const_iterator baseUrlsBegin() const;
+
+ /**
+ * iterator that points at end of repository urls
+ */
+ urls_const_iterator baseUrlsEnd() const;
+
+ /**
+ * If enabled is false, then this repository must be ignored as if does
+ * not exists, except when checking for duplicate alias.
+ */
+ boost::tribool enabled() const;
+
+ /**
+ * If true, the repostory must be refreshed before creating resolvables
+ * from it
+ */
+ boost::tribool autorefresh() const;
+
+ /**
+ * Type of repository,
+ *
+ */
+ repo::RepoType type() const;
+
+ /**
+ * \short Repository short label
+ *
+ * Short label or description of the repository, to be used on
+ * the user interface.
+ * ie: "SUSE Linux 10.2 updates"
+ */
+ std::string name() const;
+
+ /**
+ * \short File where this repo was read from
+ *
+ * \note could be an empty pathname for repo
+ * infos created in memory.
+ */
+ Pathname filepath() const;
+
+ /**
+ * Add a base url. \see baseUrls
+ * \param url The base url for the repository.
+ *
+ * To edit or remove urls, create a new RepoInfo instead.
+ */
+ RepoInfo & addBaseUrl( const Url &url );
+
+ /**
+ * Set mirror list url. \see mirrorListUrl
+ * \param url The base url for the list
+ */
+ RepoInfo & setMirrorListUrl( const Url &url );
+
+ /**
+ * enable or disable the repository \see enabled
+ * \param enabled
+ */
+ RepoInfo & setEnabled( boost::tribool enabled );
+
+ /**
+ * enable or disable autorefresh \see autorefresh
+ * \param enabled
+ */
+ RepoInfo & setAutorefresh( boost::tribool autorefresh );
+
+ /**
+ * set the repository alias \see alias
+ * \param alias
+ */
+ RepoInfo & setAlias( const std::string &alias );
+
+ /**
+ * set the repository type \see type
+ * \param t
+ */
+ RepoInfo & setType( const repo::RepoType &t );
+
+ /**
+ * set the repository name \see name
+ * \param name
+ */
+ RepoInfo & setName( const std::string &name );
+
+ /**
+ * \short set the repository filepath
+ * \param path File path
+ */
+ RepoInfo & setFilepath( const Pathname &filename );
+
+ std::ostream & dumpOn( std::ostream & str ) const;
+
+ std::ostream & dumpRepoOn( std::ostream & str ) const;
+
+ class Impl;
+ private:
+ /** Pointer to implementation */
+ RWCOW_pointer<Impl> _pimpl;
+ };
+ typedef std::list<RepoInfo> RepoInfoList;
+ %template(RepoInfoList) std::list<RepoInfo>;
+
--- /dev/null
+
+ std::list<RepoInfo> readRepoFile(const Url & repo_file);
+
+ struct RepoManagerOptions
+ {
+ RepoManagerOptions();
+
+ Pathname repoCachePath;
+ Pathname repoRawCachePath;
+ Pathname knownReposPath;
+ };
+
+ class RepoManager
+ {
+ public:
+ RepoManager( const RepoManagerOptions &options = RepoManagerOptions() );
+ ~RepoManager();
+
+ enum RawMetadataRefreshPolicy
+ {
+ RefreshIfNeeded,
+ RefreshForced
+ };
+
+ enum CacheBuildPolicy
+ {
+ BuildIfNeeded,
+ BuildForced
+ };
+
+ enum RepoRemovePolicy
+ {
+
+ };
+
+ std::list<RepoInfo> knownRepositories() const;
+ void refreshMetadata( const RepoInfo &info,
+ RawMetadataRefreshPolicy policy = RefreshIfNeeded,
+ const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
+ void cleanMetadata( const RepoInfo &info,
+ const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
+ void buildCache( const RepoInfo &info,
+ CacheBuildPolicy policy = BuildIfNeeded,
+ const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
+ void cleanCache( const RepoInfo &info,
+ const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
+ bool isCached( const RepoInfo &info ) const;
+ Repository createFromCache( const RepoInfo &info,const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
+ repo::RepoType probe( const Url &url );
+ void addRepository( const RepoInfo &info,
+ const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
+ void addRepositories( const Url &url,
+ const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
+ void removeRepository( const RepoInfo & info,
+ const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
+
+ };
--- /dev/null
+class RepoStatus
+ {
+ friend std::ostream & operator<<( std::ostream & str, const RepoStatus & obj );
+
+ public:
+
+ /**
+ * Checksum of the repository.
+ * Usually the checksum of the index, but any
+ * checksum that changes when the repository changes
+ * in any way is sufficient.
+ */
+ std::string checksum() const;
+
+ /**
+ * timestamp of the repository. If the repository
+ * changes, it has to be updated as well with the
+ * new timestamp.
+ */
+ Date timestamp() const;
+
+ /**
+ * set the repository checksum \see checksum
+ * \param checksum
+ */
+ RepoStatus & setChecksum( const std::string &checksum );
+
+ /**
+ * set the repository timestamp \see timestamp
+ * \param timestamp
+ */
+ RepoStatus & setTimestamp( const Date ×tamp );
+
+ /** Implementation */
+ class Impl;
+
+ public:
+ /** Default ctor */
+ RepoStatus();
+
+ /**
+ * \short Status from a single file
+ * As most repository state is represented
+ * by the status of the index file, you can
+ * construct the status from a file.
+ */
+ RepoStatus( const Pathname &file );
+
+ /** Dtor */
+ ~RepoStatus();
+
+ public:
+
+ private:
+ /** Pointer to implementation */
+ RWCOW_pointer<Impl> _pimpl;
+ };
\ No newline at end of file
--- /dev/null
+
+struct RepoType
+ {
+ static const RepoType RPMMD;
+ static const RepoType YAST2;
+ //static const RepoType NONE;
+
+ enum Type
+ {
+ NONE_e,
+ RPMMD_e,
+ YAST2_e
+ };
+
+ RepoType(Type type) : _type(type) {}
+
+ explicit RepoType(const std::string & strval_r);
+
+ const Type toEnum() const { return _type; }
+
+ RepoType::Type parse(const std::string & strval_r);
+
+ const std::string & asString() const;
+
+ Type _type;
+ };
\ No newline at end of file
--- /dev/null
+
+ class Repository : private base::SafeBool<Repository>
+ {
+ public:
+ Repository();
+ static const Repository noRepository;
+ public:
+ typedef unsigned long NumericId;
+ NumericId numericId() const;
+ const zypp::ResStore & resolvables();
+ const RepoInfo info() const;
+ const std::list<packagedelta::PatchRpm> & patchRpms() const;
+ const std::list<packagedelta::DeltaRpm> & deltaRpms() const;
+ };
+
Vendor vendor() const;
ByteCount size() const;
ByteCount archivesize() const;
- Source_Ref source() const;
- unsigned sourceMediaNr() const;
+ Repository repository() const;
+ unsigned mediaNr() const;
bool installOnly() const;
Date buildtime() const;
Date installtime() const;
+++ /dev/null
-
-class Source_Ref
-{
- friend std::ostream & operator<<( std::ostream & str, const Source_Ref & obj );
- friend bool operator==( const Source_Ref & lhs, const Source_Ref & rhs );
- friend bool operator<( const Source_Ref & lhs, const Source_Ref & rhs );
-
- public:
- typedef source::SourceImpl Impl;
- typedef source::SourceImpl_Ptr Impl_Ptr;
-
- public:
- Source_Ref();
- static const Source_Ref noSource;
-
- public:
- typedef unsigned long NumericId;
- NumericId numericId() const;
-
- public:
- std::string checksum() const;
- Date timestamp() const;
- bool hasResolvablesOfKind( const zypp::Resolvable::Kind &kind ) const;
- std::set<zypp::Resolvable::Kind> resolvableKinds() const;
- bool resStoreInitialized() const;
- const ResStore & resolvables() const;
- const ResStore resolvables(zypp::Resolvable::Kind kind) const;
- //const Pathname providePackage( Package::constPtr package );
- const Pathname provideFile(const Pathname & file_r, const unsigned media_nr = 1);
- const Pathname provideDirTree(const Pathname & dir_r, const unsigned media_nr = 1);
- const void releaseFile(const Pathname & file_r, const unsigned media_nr = 1);
- const void releaseDir(const Pathname & dir_r, const unsigned media_nr = 1, bool recursive = false);
- bool enabled() const;
- void enable();
- void disable();
- bool autorefresh() const;
- void setAutorefresh( bool enable_r );
- void refresh();
- void storeMetadata(const Pathname & cache_dir_r);
- std::string alias (void) const;
- void setAlias (const std::string & alias_r);
- std::string type (void) const;
- unsigned numberOfMedia(void) const;
- std::string vendor (void) const;
- std::string unique_id (void) const;
- std::string id (void) const;
- void setId (const std::string id_r);
- unsigned priority (void) const;
- void setPriority (unsigned p);
- unsigned priorityUnsubscribed (void) const;
- void setPriorityUnsubscribed (unsigned p);
- bool subscribed (void) const;
- void setSubscribed (bool s);
- const Pathname & cacheDir (void) const;
- const std::list<Pathname> publicKeys();
- Url url (void) const;
- void setUrl( const Url & url );
- bool remote() const;
- const Pathname & path (void) const;
- bool baseSource() const;
- public:
- void changeMedia(const media::MediaId & media_r, const Pathname & path_r);
- void redirect(unsigned media_nr, const Url & new_url);
- void release();
- void reattach(const Pathname &attach_point);
- media::MediaVerifierRef verifier(unsigned media_nr);
- private:
- friend class SourceFactory;
- friend class source::SourceImpl;
- explicit
- Source_Ref( const Impl_Ptr & impl_r );
- };
\ No newline at end of file
+++ /dev/null
-
-class SourceFactory
- {
- friend std::ostream & operator<<( std::ostream & str, const SourceFactory & obj );
-
- public:
- /** Default ctor */
- SourceFactory();
- /** Dtor */
- ~SourceFactory();
-
- public:
- /** Construct source.
- * \throw EXCEPTION on fail
- */
- Source_Ref createFrom( const source::SourceInfo & context );
-
- /** Construct source from an implementation.
- * Returns Source_Ref::noSource on NULL \a impl_r.
- */
- //Source_Ref createFrom( const Source_Ref::Impl_Ptr & impl_r );
-
- /** Construct source.
- * \throw EXCEPTION on fail
- */
- Source_Ref createFrom( const Url & url_r, const Pathname & path_r = "/", const std::string & alias_r = "", const Pathname & cache_dir_r = "", bool base_source = false );
-
- /** Construct source of a given type.
- * \throw EXCEPTION on fail
- */
- Source_Ref createFrom( const std::string & type, const Url & url_r, const Pathname & path_r, const std::string & alias_r, const Pathname & cache_dir_r, bool base_source, tribool auto_refresh );
-
- protected:
- template<class _SourceImpl>
- Source_Ref createSourceImplWorkflow( media::MediaId id, const source::SourceInfo &context );
- private:
- /** Implementation */
- class Impl;
- /** Pointer to implementation */
- RW_pointer<Impl> _pimpl;
-
- public:
- struct ProductEntry {
- Pathname _dir;
- std::string _name;
- ProductEntry( const Pathname & dir_r = "/", const std::string & name_r = std::string() ){
- _dir = dir_r;
- _name = name_r;
- }
- bool operator<( const ProductEntry & rhs ) const {
- return( _dir.asString() < rhs._dir.asString() );
- }
- };
-
- typedef std::set<ProductEntry> ProductSet;
-
- /** Check which products are available on the media
- * \throw Exception or MediaException on fail
- */
- void listProducts( const Url & url_r, ProductSet & products_r );
- private:
-// bool probeSource( const std::string name, boost::function<bool()> prober, callback::SendReport<CreateSourceReport> &report );
- void scanProductsFile( const Pathname & file_r, ProductSet & pset_r ) const;
- };
\ No newline at end of file
%typemap(freearg) const Url & {
delete $1;
}
+
+%typemap(out) Url {
+ VALUE rburlstr = rb_str_new2($1.asString().c_str());
+ $result = rburlstr ;
+}
\ No newline at end of file
-%rename("asString") foo(to_s);
+%rename("asString") to_s;
+
+#define auto_string( cl ) \
+%extend cl { \
+ std::string to_s() { \
+ return self->asString();\
+ } \
+}
#define iter( cl, storetype ) \
%mixin cl "Enumerable"; \
} \
}
+#define auto_iterator( cl, storetype ) \
+%mixin cl "Enumerable"; \
+%extend cl { \
+ void each() { \
+ cl::iterator i = self->begin(); \
+ while ( i != self->end() ) { \
+ rb_yield( SWIG_NewPointerObj( (void *) &*i, $descriptor(storetype), 0)); \
+ ++i; \
+ } \
+ } \
+}
+
+
%extend Target {
void each_by_kind( const ResObject::Kind & kind_r )
{
--- /dev/null
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * std_list.i
+ *
+ * SWIG typemaps for std::list
+ * ----------------------------------------------------------------------------- */
+
+%include <std_common.i>
+
+// ------------------------------------------------------------------------
+// std::list
+//
+// The aim of all that follows would be to integrate std::list with
+// Ruby as much as possible, namely, to allow the user to pass and
+// be returned Ruby arrays
+// const declarations are used to guess the intent of the function being
+// exported; therefore, the following rationale is applied:
+//
+// -- f(std::list<T>), f(const std::list<T>&), f(const std::list<T>*):
+// the parameter being read-only, either a Ruby array or a
+// previously wrapped std::list<T> can be passed.
+// -- f(std::list<T>&), f(std::list<T>*):
+// the parameter must be modified; therefore, only a wrapped std::list
+// can be passed.
+// -- std::list<T> f():
+// the list is returned by copy; therefore, a Ruby array of T:s
+// is returned which is most easily used in other Ruby functions
+// -- std::list<T>& f(), std::list<T>* f(), const std::list<T>& f(),
+// const std::list<T>* f():
+// the list is returned by reference; therefore, a wrapped std::list
+// is returned
+// ------------------------------------------------------------------------
+
+%{
+#include <list>
+#include <algorithm>
+#include <stdexcept>
+%}
+
+// exported class
+
+namespace std {
+
+ %mixin list "Enumerable";
+
+ template<class T> class list {
+ %typemap(in) list<T> {
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ $1;
+ for (unsigned int i=0; i<size; i++) {
+ VALUE o = RARRAY($input)->ptr[i];
+ T* x;
+ SWIG_ConvertPtr(o, (void **) &x, $descriptor(T *), 1);
+ $1.push_back(*x);
+ }
+ } else {
+ void *ptr;
+ SWIG_ConvertPtr($input, &ptr, $&1_descriptor, 1);
+ $1 = *(($&1_type) ptr);
+ }
+ }
+ %typemap(in) const list<T>& (std::list<T> temp),
+ const list<T>* (std::list<T> temp) {
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ $1 = &temp;
+ for (unsigned int i=0; i<size; i++) {
+ VALUE o = RARRAY($input)->ptr[i];
+ T* x;
+ SWIG_ConvertPtr(o, (void **) &x, $descriptor(T *), 1);
+ temp.push_back(*x);
+ }
+ } else {
+ SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 1);
+ }
+ }
+
+ void each() {
+ for ( std::list<T>::const_iterator it = self->begin();
+ it != self->end();
+ ++it )
+ {
+ T* x = &(*it);
+ rb_yield(SWIG_NewPointerObj((void *) x,
+ $descriptor(T *), 0));
+ }
+ }
+
+
+ %typemap(out) list<T> {
+ $result = rb_ary_new2($1.size());
+ unsigned int i = 0;
+ for ( std::list<T>::iterator it = $1.begin();
+ it != $1.end();
+ ++it )
+ {
+ T* x = new T((*it));
+ rb_ary_store($result,i,
+ SWIG_NewPointerObj((void *) x,
+ $descriptor(T *), 1));
+ ++i;
+ }
+ }
+ %typecheck(SWIG_TYPECHECK_VECTOR) list<T> {
+ /* native sequence? */
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ if (size == 0) {
+ /* an empty sequence can be of any type */
+ $1 = 1;
+ } else {
+ /* check the first element only */
+ T* x;
+ VALUE o = RARRAY($input)->ptr[0];
+ if ((SWIG_ConvertPtr(o,(void **) &x,
+ $descriptor(T *),0)) != -1)
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ } else {
+ /* wrapped list? */
+ std::list<T >* v;
+ if (SWIG_ConvertPtr($input,(void **) &v,
+ $&1_descriptor,0) != -1)
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ }
+ %typecheck(SWIG_TYPECHECK_VECTOR) const list<T>&,
+ const list<T>* {
+ /* native sequence? */
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ if (size == 0) {
+ /* an empty sequence can be of any type */
+ $1 = 1;
+ } else {
+ /* check the first element only */
+ T* x;
+ VALUE o = RARRAY($input)->ptr[0];
+ if ((SWIG_ConvertPtr(o,(void **) &x,
+ $descriptor(T *),0)) != -1)
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ } else {
+ /* wrapped list? */
+ std::list<T >* v;
+ if (SWIG_ConvertPtr($input,(void **) &v,
+ $1_descriptor,0) != -1)
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ }
+ public:
+ list();
+ list(unsigned int size);
+ list(unsigned int size, const T& value);
+ list(const list<T> &);
+
+ %rename(__len__) size;
+ unsigned int size() const;
+ %rename("empty?") empty;
+ bool empty() const;
+ void clear();
+ %rename(push) push_back;
+ void push_back(const T& x);
+ %extend {
+ /*
+ T pop() throw (std::out_of_range) {
+ if (self->size() == 0)
+ throw std::out_of_range("pop from empty list");
+ T x = self->back();
+ self->pop_back();
+ return x;
+ }
+ T& __getitem__(int i) throw (std::out_of_range) {
+ int size = int(self->size());
+ if (i<0) i += size;
+ if (i>=0 && i<size)
+ return (*self)[i];
+ else
+ throw std::out_of_range("list index out of range");
+ }
+ void __setitem__(int i, const T& x) throw (std::out_of_range) {
+ int size = int(self->size());
+ if (i<0) i+= size;
+ if (i>=0 && i<size)
+ (*self)[i] = x;
+ else
+ throw std::out_of_range("list index out of range");
+ }
+ */
+ void each() {
+ for ( std::list<T>::iterator it = self->begin();
+ it != self->end();
+ ++it )
+ {
+ T* x = &(*it);
+ rb_yield(SWIG_NewPointerObj((void *) x,
+ $descriptor(T *), 0));
+ }
+ }
+ }
+ };
+
+ // Partial specialization for lists of pointers. [ beazley ]
+
+ %mixin list<T*> "Enumerable";
+ template<class T> class list<T*> {
+ %typemap(in) list<T*> {
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ $1 = std::list<T* >(size);
+ for (unsigned int i=0; i<size; i++) {
+ VALUE o = RARRAY($input)->ptr[i];
+ T* x;
+ SWIG_ConvertPtr(o, (void **) &x, $descriptor(T *), 1);
+ (($1_type &)$1)[i] = x;
+ }
+ } else {
+ void *ptr;
+ SWIG_ConvertPtr($input, &ptr, $&1_descriptor, 1);
+ $1 = *(($&1_type) ptr);
+ }
+ }
+ %typemap(in) const list<T*>& (std::list<T*> temp),
+ const list<T*>* (std::list<T*> temp) {
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ temp = std::list<T* >(size);
+ $1 = &temp;
+ for (unsigned int i=0; i<size; i++) {
+ VALUE o = RARRAY($input)->ptr[i];
+ T* x;
+ SWIG_ConvertPtr(o, (void **) &x, $descriptor(T *), 1);
+ temp[i] = x;
+ }
+ } else {
+ SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 1);
+ }
+ }
+ %typemap(out) list<T*> {
+ $result = rb_ary_new2($1.size());
+ for (unsigned int i=0; i<$1.size(); i++) {
+ T* x = (($1_type &)$1)[i];
+ rb_ary_store($result,i,
+ SWIG_NewPointerObj((void *) x,
+ $descriptor(T *), 0));
+ }
+ }
+ %typecheck(SWIG_TYPECHECK_VECTOR) list<T*> {
+ /* native sequence? */
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ if (size == 0) {
+ /* an empty sequence can be of any type */
+ $1 = 1;
+ } else {
+ /* check the first element only */
+ T* x;
+ VALUE o = RARRAY($input)->ptr[0];
+ if ((SWIG_ConvertPtr(o,(void **) &x,
+ $descriptor(T *),0)) != -1)
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ } else {
+ /* wrapped list? */
+ std::list<T* >* v;
+ if (SWIG_ConvertPtr($input,(void **) &v,
+ $&1_descriptor,0) != -1)
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ }
+ %typecheck(SWIG_TYPECHECK_VECTOR) const list<T*>&,
+ const list<T*>* {
+ /* native sequence? */
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ if (size == 0) {
+ /* an empty sequence can be of any type */
+ $1 = 1;
+ } else {
+ /* check the first element only */
+ T* x;
+ VALUE o = RARRAY($input)->ptr[0];
+ if ((SWIG_ConvertPtr(o,(void **) &x,
+ $descriptor(T *),0)) != -1)
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ } else {
+ /* wrapped list? */
+ std::list<T* >* v;
+ if (SWIG_ConvertPtr($input,(void **) &v,
+ $1_descriptor,0) != -1)
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ }
+ public:
+ list();
+ list(unsigned int size);
+ list(unsigned int size, T * &value);
+ list(const list<T*> &);
+
+ %rename(__len__) size;
+ unsigned int size() const;
+ %rename("empty?") empty;
+ bool empty() const;
+ void clear();
+ %rename(push) push_back;
+ void push_back(T* x);
+ %extend {
+ /*
+ T* pop() throw (std::out_of_range) {
+ if (self->size() == 0)
+ throw std::out_of_range("pop from empty list");
+ T* x = self->back();
+ self->pop_back();
+ return x;
+ }
+ T* __getitem__(int i) throw (std::out_of_range) {
+ int size = int(self->size());
+ if (i<0) i += size;
+ if (i>=0 && i<size)
+ return (*self)[i];
+ else
+ throw std::out_of_range("list index out of range");
+ }
+ void __setitem__(int i, T* x) throw (std::out_of_range) {
+ int size = int(self->size());
+ if (i<0) i+= size;
+ if (i>=0 && i<size)
+ (*self)[i] = x;
+ else
+ throw std::out_of_range("list index out of range");
+ }
+ */
+ void each() {
+ for ( std::list<T>::iterator it = self->begin();
+ it != self->end();
+ ++it )
+ {
+ T* x = &(*it);
+ rb_yield(SWIG_NewPointerObj((void *) x,
+ $descriptor(T *), 0));
+ }
+ }
+ }
+ };
+
+
+ // specializations for built-ins
+
+ %define specialize_std_list(T,CHECK,CONVERT_FROM,CONVERT_TO)
+ %mixin list<T> "Enumerable";
+ template<> class list<T> {
+ %typemap(in) list<T> {
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ $1 = std::list<T >(size);
+ for (unsigned int i=0; i<size; i++) {
+ VALUE o = RARRAY($input)->ptr[i];
+ if (CHECK(o))
+ (($1_type &)$1)[i] = (T)(CONVERT_FROM(o));
+ else
+ rb_raise(rb_eTypeError,
+ "wrong argument type"
+ " (expected list<" #T ">)");
+ }
+ } else {
+ void *ptr;
+ SWIG_ConvertPtr($input, &ptr, $&1_descriptor, 1);
+ $1 = *(($&1_type) ptr);
+ }
+ }
+ %typemap(in) const list<T>& (std::list<T> temp),
+ const list<T>* (std::list<T> temp) {
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ temp = std::list<T >(size);
+ $1 = &temp;
+ for (unsigned int i=0; i<size; i++) {
+ VALUE o = RARRAY($input)->ptr[i];
+ if (CHECK(o))
+ temp[i] = (T)(CONVERT_FROM(o));
+ else
+ rb_raise(rb_eTypeError,
+ "wrong argument type"
+ " (expected list<" #T ">)");
+ }
+ } else {
+ SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 1);
+ }
+ }
+ %typemap(out) list<T> {
+ $result = rb_ary_new2($1.size());
+ for (unsigned int i=0; i<$1.size(); i++)
+ rb_ary_store($result,i,CONVERT_TO((($1_type &)$1)[i]));
+ }
+ %typecheck(SWIG_TYPECHECK_VECTOR) list<T> {
+ /* native sequence? */
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ if (size == 0) {
+ /* an empty sequence can be of any type */
+ $1 = 1;
+ } else {
+ /* check the first element only */
+ VALUE o = RARRAY($input)->ptr[0];
+ if (CHECK(o))
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ } else {
+ /* wrapped list? */
+ std::list<T >* v;
+ if (SWIG_ConvertPtr($input,(void **) &v,
+ $&1_descriptor,0) != -1)
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ }
+ %typecheck(SWIG_TYPECHECK_VECTOR) const list<T>&,
+ const list<T>* {
+ /* native sequence? */
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ if (size == 0) {
+ /* an empty sequence can be of any type */
+ $1 = 1;
+ } else {
+ /* check the first element only */
+ VALUE o = RARRAY($input)->ptr[0];
+ if (CHECK(o))
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ } else {
+ /* wrapped list? */
+ std::list<T >* v;
+ if (SWIG_ConvertPtr($input,(void **) &v,
+ $1_descriptor,0) != -1)
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ }
+ public:
+ list();
+ list(unsigned int size);
+ list(unsigned int size, const T& value);
+ list(const list<T> &);
+
+ %rename(__len__) size;
+ unsigned int size() const;
+ %rename("empty?") empty;
+ bool empty() const;
+ void clear();
+ %rename(push) push_back;
+ void push_back(T x);
+ %extend {
+ /*
+ T pop() throw (std::out_of_range) {
+ if (self->size() == 0)
+ throw std::out_of_range("pop from empty list");
+ T x = self->back();
+ self->pop_back();
+ return x;
+ }
+ T __getitem__(int i) throw (std::out_of_range) {
+ int size = int(self->size());
+ if (i<0) i += size;
+ if (i>=0 && i<size)
+ return (*self)[i];
+ else
+ throw std::out_of_range("list index out of range");
+ }
+ void __setitem__(int i, T x) throw (std::out_of_range) {
+ int size = int(self->size());
+ if (i<0) i+= size;
+ if (i>=0 && i<size)
+ (*self)[i] = x;
+ else
+ throw std::out_of_range("list index out of range");
+ }
+ */
+ void each() {
+ for ( std::list<T>::iterator it = self->begin();
+ it != self->end();
+ ++it )
+ {
+ T* x = &(*it);
+ rb_yield(SWIG_NewPointerObj((void *) x,
+ $descriptor(T *), 0));
+ }
+ }
+ }
+ };
+ %enddef
+
+ specialize_std_list(bool,SWIG_BOOL_P,SWIG_RB2BOOL,SWIG_BOOL2RB);
+ specialize_std_list(char,FIXNUM_P,FIX2INT,INT2NUM);
+ specialize_std_list(int,FIXNUM_P,FIX2INT,INT2NUM);
+ specialize_std_list(short,FIXNUM_P,FIX2INT,INT2NUM);
+ specialize_std_list(long,FIXNUM_P,FIX2INT,INT2NUM);
+ specialize_std_list(unsigned char,FIXNUM_P,FIX2INT,INT2NUM);
+ specialize_std_list(unsigned int,FIXNUM_P,FIX2INT,INT2NUM);
+ specialize_std_list(unsigned short,FIXNUM_P,FIX2INT,INT2NUM);
+ specialize_std_list(unsigned long,FIXNUM_P,FIX2INT,INT2NUM);
+ specialize_std_list(double,SWIG_FLOAT_P,SWIG_NUM2DBL,rb_float_new);
+ specialize_std_list(float,SWIG_FLOAT_P,SWIG_NUM2DBL,rb_float_new);
+ specialize_std_list(std::string,SWIG_STRING_P,SWIG_RB2STR,SWIG_STR2RB);
+
+}
+
--- /dev/null
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * std_set.i
+ *
+ * SWIG typemaps for std::set
+ * ----------------------------------------------------------------------------- */
+
+%include <std_common.i>
+
+// ------------------------------------------------------------------------
+// std::set
+//
+// The aim of all that follows would be to integrate std::set with
+// Ruby as much as possible, namely, to allow the user to pass and
+// be returned Ruby arrays
+// const declarations are used to guess the intent of the function being
+// exported; therefore, the following rationale is applied:
+//
+// -- f(std::set<T>), f(const std::set<T>&), f(const std::set<T>*):
+// the parameter being read-only, either a Ruby array or a
+// previously wrapped std::set<T> can be passed.
+// -- f(std::set<T>&), f(std::set<T>*):
+// the parameter must be modified; therefore, only a wrapped std::set
+// can be passed.
+// -- std::set<T> f():
+// the set is returned by copy; therefore, a Ruby array of T:s
+// is returned which is most easily used in other Ruby functions
+// -- std::set<T>& f(), std::set<T>* f(), const std::set<T>& f(),
+// const std::set<T>* f():
+// the set is returned by reference; therefore, a wrapped std::set
+// is returned
+// ------------------------------------------------------------------------
+
+%{
+#include <set>
+#include <algorithm>
+#include <stdexcept>
+%}
+
+// exported class
+
+namespace std {
+
+ %mixin set "Enumerable";
+
+ template<class T> class set {
+ %typemap(in) set<T> {
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ $1;
+ for (unsigned int i=0; i<size; i++) {
+ VALUE o = RARRAY($input)->ptr[i];
+ T* x;
+ SWIG_ConvertPtr(o, (void **) &x, $descriptor(T *), 1);
+ $1.insert(*x);
+ }
+ } else {
+ void *ptr;
+ SWIG_ConvertPtr($input, &ptr, $&1_descriptor, 1);
+ $1 = *(($&1_type) ptr);
+ }
+ }
+ %typemap(in) const set<T>& (std::set<T> temp),
+ const set<T>* (std::set<T> temp) {
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ $1 = &temp;
+ for (unsigned int i=0; i<size; i++) {
+ VALUE o = RARRAY($input)->ptr[i];
+ T* x;
+ SWIG_ConvertPtr(o, (void **) &x, $descriptor(T *), 1);
+ temp.insert(*x);
+ }
+ } else {
+ SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 1);
+ }
+ }
+
+ void each() {
+ for ( std::set<T>::iterator it = self->begin();
+ it != self->end();
+ ++it )
+ {
+ T* x = (T *) &(*it);
+ rb_yield(SWIG_NewPointerObj((void *) x,
+ $descriptor(T *), 0));
+ }
+ }
+
+
+ %typemap(out) set<T> {
+ $result = rb_ary_new2($1.size());
+ unsigned int i = 0;
+ for ( std::set<T>::iterator it = $1.begin();
+ it != $1.end();
+ ++it )
+ {
+ T* x = new T((*it));
+ rb_ary_store($result,i,
+ SWIG_NewPointerObj((void *) x,
+ $descriptor(T *), 1));
+ ++i;
+ }
+ }
+ %typecheck(SWIG_TYPECHECK_VECTOR) set<T> {
+ /* native sequence? */
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ if (size == 0) {
+ /* an empty sequence can be of any type */
+ $1 = 1;
+ } else {
+ /* check the first element only */
+ T* x;
+ VALUE o = RARRAY($input)->ptr[0];
+ if ((SWIG_ConvertPtr(o,(void **) &x,
+ $descriptor(T *),0)) != -1)
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ } else {
+ /* wrapped set? */
+ std::set<T >* v;
+ if (SWIG_ConvertPtr($input,(void **) &v,
+ $&1_descriptor,0) != -1)
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ }
+ %typecheck(SWIG_TYPECHECK_VECTOR) const set<T>&,
+ const set<T>* {
+ /* native sequence? */
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ if (size == 0) {
+ /* an empty sequence can be of any type */
+ $1 = 1;
+ } else {
+ /* check the first element only */
+ T* x;
+ VALUE o = RARRAY($input)->ptr[0];
+ if ((SWIG_ConvertPtr(o,(void **) &x,
+ $descriptor(T *),0)) != -1)
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ } else {
+ /* wrapped set? */
+ std::set<T >* v;
+ if (SWIG_ConvertPtr($input,(void **) &v,
+ $1_descriptor,0) != -1)
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ }
+ public:
+ set();
+ set(const set<T> &);
+
+ %rename(__len__) size;
+ unsigned int size() const;
+ %rename("empty?") empty;
+ bool empty() const;
+ void clear();
+ %rename(push) insert;
+ void insert(const T& x);
+ %extend {
+ /*
+ T pop() throw (std::out_of_range) {
+ if (self->size() == 0)
+ throw std::out_of_range("pop from empty set");
+ T x = self->back();
+ self->pop_back();
+ return x;
+ }
+ T& __getitem__(int i) throw (std::out_of_range) {
+ int size = int(self->size());
+ if (i<0) i += size;
+ if (i>=0 && i<size)
+ return (*self)[i];
+ else
+ throw std::out_of_range("set index out of range");
+ }
+ void __setitem__(int i, const T& x) throw (std::out_of_range) {
+ int size = int(self->size());
+ if (i<0) i+= size;
+ if (i>=0 && i<size)
+ (*self)[i] = x;
+ else
+ throw std::out_of_range("set index out of range");
+ }
+ */
+ void each() {
+ for ( std::set<T>::iterator it = self->begin();
+ it != self->end();
+ ++it )
+ {
+ T* x = (T *)&(*it);
+ rb_yield(SWIG_NewPointerObj((void *) x,
+ $descriptor(T *), 0));
+ }
+ }
+ }
+ };
+
+ // Partial specialization for sets of pointers. [ beazley ]
+
+ %mixin set<T*> "Enumerable";
+ template<class T> class set<T*> {
+ %typemap(in) set<T*> {
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ $1 = std::set<T* >(size);
+ for (unsigned int i=0; i<size; i++) {
+ VALUE o = RARRAY($input)->ptr[i];
+ T* x;
+ SWIG_ConvertPtr(o, (void **) &x, $descriptor(T *), 1);
+ (($1_type &)$1)[i] = x;
+ }
+ } else {
+ void *ptr;
+ SWIG_ConvertPtr($input, &ptr, $&1_descriptor, 1);
+ $1 = *(($&1_type) ptr);
+ }
+ }
+ %typemap(in) const set<T*>& (std::set<T*> temp),
+ const set<T*>* (std::set<T*> temp) {
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ temp = std::set<T* >(size);
+ $1 = &temp;
+ for (unsigned int i=0; i<size; i++) {
+ VALUE o = RARRAY($input)->ptr[i];
+ T* x;
+ SWIG_ConvertPtr(o, (void **) &x, $descriptor(T *), 1);
+ temp[i] = x;
+ }
+ } else {
+ SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 1);
+ }
+ }
+ %typemap(out) set<T*> {
+ $result = rb_ary_new2($1.size());
+ for (unsigned int i=0; i<$1.size(); i++) {
+ T* x = (($1_type &)$1)[i];
+ rb_ary_store($result,i,
+ SWIG_NewPointerObj((void *) x,
+ $descriptor(T *), 0));
+ }
+ }
+ %typecheck(SWIG_TYPECHECK_VECTOR) set<T*> {
+ /* native sequence? */
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ if (size == 0) {
+ /* an empty sequence can be of any type */
+ $1 = 1;
+ } else {
+ /* check the first element only */
+ T* x;
+ VALUE o = RARRAY($input)->ptr[0];
+ if ((SWIG_ConvertPtr(o,(void **) &x,
+ $descriptor(T *),0)) != -1)
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ } else {
+ /* wrapped set? */
+ std::set<T* >* v;
+ if (SWIG_ConvertPtr($input,(void **) &v,
+ $&1_descriptor,0) != -1)
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ }
+ %typecheck(SWIG_TYPECHECK_VECTOR) const set<T*>&,
+ const set<T*>* {
+ /* native sequence? */
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ if (size == 0) {
+ /* an empty sequence can be of any type */
+ $1 = 1;
+ } else {
+ /* check the first element only */
+ T* x;
+ VALUE o = RARRAY($input)->ptr[0];
+ if ((SWIG_ConvertPtr(o,(void **) &x,
+ $descriptor(T *),0)) != -1)
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ } else {
+ /* wrapped set? */
+ std::set<T* >* v;
+ if (SWIG_ConvertPtr($input,(void **) &v,
+ $1_descriptor,0) != -1)
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ }
+ public:
+ set();
+ set(const set<T*> &);
+
+ %rename(__len__) size;
+ unsigned int size() const;
+ %rename("empty?") empty;
+ bool empty() const;
+ void clear();
+ %rename(push) insert;
+ void insert(T* x);
+ %extend {
+ /*
+ T* pop() throw (std::out_of_range) {
+ if (self->size() == 0)
+ throw std::out_of_range("pop from empty set");
+ T* x = self->back();
+ self->pop_back();
+ return x;
+ }
+ T* __getitem__(int i) throw (std::out_of_range) {
+ int size = int(self->size());
+ if (i<0) i += size;
+ if (i>=0 && i<size)
+ return (*self)[i];
+ else
+ throw std::out_of_range("set index out of range");
+ }
+ void __setitem__(int i, T* x) throw (std::out_of_range) {
+ int size = int(self->size());
+ if (i<0) i+= size;
+ if (i>=0 && i<size)
+ (*self)[i] = x;
+ else
+ throw std::out_of_range("set index out of range");
+ }
+ */
+ void each() {
+ for ( std::set<T>::iterator it = self->begin();
+ it != self->end();
+ ++it )
+ {
+ T* x = (T*) &(*it);
+ rb_yield(SWIG_NewPointerObj((void *) x,
+ $descriptor(T *), 0));
+ }
+ }
+ }
+ };
+
+
+ // specializations for built-ins
+
+ %define specialize_std_set(T,CHECK,CONVERT_FROM,CONVERT_TO)
+ %mixin set<T> "Enumerable";
+ template<> class set<T> {
+ %typemap(in) set<T> {
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ $1 = std::set<T >(size);
+ for (unsigned int i=0; i<size; i++) {
+ VALUE o = RARRAY($input)->ptr[i];
+ if (CHECK(o))
+ (($1_type &)$1)[i] = (T)(CONVERT_FROM(o));
+ else
+ rb_raise(rb_eTypeError,
+ "wrong argument type"
+ " (expected set<" #T ">)");
+ }
+ } else {
+ void *ptr;
+ SWIG_ConvertPtr($input, &ptr, $&1_descriptor, 1);
+ $1 = *(($&1_type) ptr);
+ }
+ }
+ %typemap(in) const set<T>& (std::set<T> temp),
+ const set<T>* (std::set<T> temp) {
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ temp = std::set<T >(size);
+ $1 = &temp;
+ for (unsigned int i=0; i<size; i++) {
+ VALUE o = RARRAY($input)->ptr[i];
+ if (CHECK(o))
+ temp[i] = (T)(CONVERT_FROM(o));
+ else
+ rb_raise(rb_eTypeError,
+ "wrong argument type"
+ " (expected set<" #T ">)");
+ }
+ } else {
+ SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 1);
+ }
+ }
+ %typemap(out) set<T> {
+ $result = rb_ary_new2($1.size());
+ for (unsigned int i=0; i<$1.size(); i++)
+ rb_ary_store($result,i,CONVERT_TO((($1_type &)$1)[i]));
+ }
+ %typecheck(SWIG_TYPECHECK_VECTOR) set<T> {
+ /* native sequence? */
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ if (size == 0) {
+ /* an empty sequence can be of any type */
+ $1 = 1;
+ } else {
+ /* check the first element only */
+ VALUE o = RARRAY($input)->ptr[0];
+ if (CHECK(o))
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ } else {
+ /* wrapped set? */
+ std::set<T >* v;
+ if (SWIG_ConvertPtr($input,(void **) &v,
+ $&1_descriptor,0) != -1)
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ }
+ %typecheck(SWIG_TYPECHECK_VECTOR) const set<T>&,
+ const set<T>* {
+ /* native sequence? */
+ if (rb_obj_is_kind_of($input,rb_cArray)) {
+ unsigned int size = RARRAY($input)->len;
+ if (size == 0) {
+ /* an empty sequence can be of any type */
+ $1 = 1;
+ } else {
+ /* check the first element only */
+ VALUE o = RARRAY($input)->ptr[0];
+ if (CHECK(o))
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ } else {
+ /* wrapped set? */
+ std::set<T >* v;
+ if (SWIG_ConvertPtr($input,(void **) &v,
+ $1_descriptor,0) != -1)
+ $1 = 1;
+ else
+ $1 = 0;
+ }
+ }
+ public:
+ set();
+ set(const set<T> &);
+
+ %rename(__len__) size;
+ unsigned int size() const;
+ %rename("empty?") empty;
+ bool empty() const;
+ void clear();
+ %rename(push) insert;
+ void insert(T x);
+ %extend {
+ /*
+ T pop() throw (std::out_of_range) {
+ if (self->size() == 0)
+ throw std::out_of_range("pop from empty set");
+ T x = self->back();
+ self->pop_back();
+ return x;
+ }
+ T __getitem__(int i) throw (std::out_of_range) {
+ int size = int(self->size());
+ if (i<0) i += size;
+ if (i>=0 && i<size)
+ return (*self)[i];
+ else
+ throw std::out_of_range("set index out of range");
+ }
+ void __setitem__(int i, T x) throw (std::out_of_range) {
+ int size = int(self->size());
+ if (i<0) i+= size;
+ if (i>=0 && i<size)
+ (*self)[i] = x;
+ else
+ throw std::out_of_range("set index out of range");
+ }
+ */
+ void each() {
+ for ( std::set<T>::iterator it = self->begin();
+ it != self->end();
+ ++it )
+ {
+ T* x = &(*it);
+ rb_yield(SWIG_NewPointerObj((void *) x,
+ $descriptor(T *), 0));
+ }
+ }
+ }
+ };
+ %enddef
+
+ specialize_std_set(bool,SWIG_BOOL_P,SWIG_RB2BOOL,SWIG_BOOL2RB);
+ specialize_std_set(char,FIXNUM_P,FIX2INT,INT2NUM);
+ specialize_std_set(int,FIXNUM_P,FIX2INT,INT2NUM);
+ specialize_std_set(short,FIXNUM_P,FIX2INT,INT2NUM);
+ specialize_std_set(long,FIXNUM_P,FIX2INT,INT2NUM);
+ specialize_std_set(unsigned char,FIXNUM_P,FIX2INT,INT2NUM);
+ specialize_std_set(unsigned int,FIXNUM_P,FIX2INT,INT2NUM);
+ specialize_std_set(unsigned short,FIXNUM_P,FIX2INT,INT2NUM);
+ specialize_std_set(unsigned long,FIXNUM_P,FIX2INT,INT2NUM);
+ specialize_std_set(double,SWIG_FLOAT_P,SWIG_NUM2DBL,rb_float_new);
+ specialize_std_set(float,SWIG_FLOAT_P,SWIG_NUM2DBL,rb_float_new);
+ specialize_std_set(std::string,SWIG_STRING_P,SWIG_RB2STR,SWIG_STR2RB);
+
+}
+
%module rzypp
-%include std_string.i
%{
/* Includes the header in the wrapper code */
#include <zypp/ZYpp.h>
#include <zypp/Pathname.h>
#include "zypp/base/ReferenceCounted.h"
- #include "zypp/SourceFactory.h"
- #include "zypp/Source.h"
#include "zypp/ResObject.h"
#include "zypp/Target.h"
#include "zypp/target/TargetImpl.h"
#include "zypp/CapFactory.h"
#include "zypp/Package.h"
#include "zypp/ResFilters.h"
-#include "zypp/source/OnMediaLocation.h"
+#include "zypp/OnMediaLocation.h"
+ #include "zypp/Repository.h"
+ #include "zypp/RepoManager.h"
+ #include "zypp/repo/RepoType.h"
#include "zypp/MediaSetAccess.h"
using namespace boost;
using namespace zypp;
+ using namespace zypp::repo;
using namespace zypp::resfilter;
+ typedef std::set<Url> UrlSet;
%}
-#ifdef SWIGRUBY
-%include "ruby.i"
-#endif
-
%rename("+") "operator+";
%rename("<<") "operator<<";
%rename("!=") "operator!=";
};
%include "Pathname.i"
+%include "Url.i"
+
+%include std_string.i
+%include "stl.i"
+%include "std_list.i"
+%include "std_set.i"
+
%include "Arch.i"
%include "ResStore.i"
%include "Edition.i"
%include "Date.i"
%include "Resolvable.i"
%include "ByteCount.i"
-%include "Source.i"
-%include "SourceFactory.i"
+%include "RepoType.i"
+%include "Repository.i"
+%include "RepoInfo.i"
+%include "RepoManager.i"
+%include "RepoStatus.i"
%include "ResObject.i"
%include "TranslatedText.i"
%include "CheckSum.i"
%include "ResPool.i"
%include "ZYppCommitPolicy.i"
%include "ZYppCommitResult.i"
-%include "Url.i"
%include "MediaSetAccess.i"
+
+#ifdef SWIGRUBY
+%include "ruby.i"
+#endif
+
+
/* define iterators using swig macros */
iter2( ResStore, ResObject::Ptr )
+auto_iterator( std::list<RepoInfo>, RepoInfo )
+%alias Arch::asString "to_s";
class ZYpp
{