summaryrefslogtreecommitdiff
path: root/bindings/swig/swconfig.i
blob: 06d36472191ae299a00f15e20a5342c075413112 (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
41
42
43
%{
#include <stdio.h>
#include <string>
#include <map>
#include <defs.h>
#include <multimapwdef.h>
#include "swconfig.h"

using namespace sword;
using namespace std;
%}

%include "std_vector.i"
%include "std_string.i"
%include "typemaps.i"


typedef multimapwithdefault < SWBuf, SWBuf, less < SWBuf > > ConfigEntMap;
typedef map < SWBuf, ConfigEntMap, less < SWBuf > > SectionMap;

class SWConfig {
public:
  //member data
  SWBuf filename;
  SectionMap Sections;

  //member functions
  SWConfig(const char *ifilename);
  virtual ~ SWConfig();

  virtual void Load();
  virtual void Save();

%extend {
  void set(const char* group, const char* entry, const char* value) {
	self->Sections[group][entry] = value;
  };
  const char* get(const char* group, const char* entry) {
	return self->Sections[group][entry].c_str();
  };
}

};