summaryrefslogtreecommitdiff
path: root/bindings/swig/swmgr.i
blob: d914be00baf66465c4624becee470b433a0f86b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
%{
#include <swmgr.h>
%}

%ignore sword::SWMgr::Modules;
%ignore sword::SWMgr::findConfig;
%include "swmgr.h"

%extend sword::SWMgr {
    std::vector < sword::SWBuf > getGlobalOptionsVector() {
        std::list<sword::SWBuf> l(self->getGlobalOptions());
        return std::vector< sword::SWBuf >(l.begin(), l.end());
    }
    
    std::vector < sword::SWBuf > getGlobalOptionValuesVector(const char *option) {
        std::list<sword::SWBuf> l(self->getGlobalOptionValues(option));
        return std::vector< sword::SWBuf >(l.begin(), l.end());
    }
    
    std::map<sword::SWBuf, sword::SWModule*> &getModules() {
        return self->Modules;
    }
    
    SWModule* getModuleAt( const int pos ) {
        if (pos < 0 || pos > (int)self->Modules.size() )
            return 0;
    
        sword::ModMap::iterator it = self->Modules.begin(); 
        
        for (int i = 0; i < pos; ++i) {
            it++;
        }

        if ( it != self->Modules.end() ) {
            return (*it).second;
        }
        
        return 0;
    }
}