annotate lib/swig/swigwin-2.0.11/Lib/lua/std_map.i @ 2575:a76d408c5132 tip

DrawTranslucent -> DrawTextureGrayShade Removed old texture drawing stuff
author a.parshin
date Wed, 09 Mar 2016 01:39:52 +0200
parents b3009adc0e2f
children
rev   line source
1899
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
1 /* -----------------------------------------------------------------------------
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
2 * std_map.i
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
3 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
4 * SWIG typemaps for std::map
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
5 * ----------------------------------------------------------------------------- */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
6
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
7 %include <std_common.i>
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
8
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
9 // ------------------------------------------------------------------------
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
10 // std::map
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
11 // ------------------------------------------------------------------------
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
12
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
13 %{
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
14 #include <map>
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
15 #include <algorithm>
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
16 #include <stdexcept>
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
17 %}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
18
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
19 // exported class
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
20
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
21 namespace std {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
22
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
23 template<class K, class T> class map {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
24 // add typemaps here
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
25 public:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
26 typedef size_t size_type;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
27 typedef ptrdiff_t difference_type;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
28 typedef K key_type;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
29 typedef T mapped_type;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
30 map();
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
31 map(const map<K,T> &);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
32
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
33 unsigned int size() const;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
34 bool empty() const;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
35 void clear();
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
36 %extend {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
37 const T& get(const K& key) throw (std::out_of_range) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
38 std::map<K,T >::iterator i = self->find(key);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
39 if (i != self->end())
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
40 return i->second;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
41 else
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
42 throw std::out_of_range("key not found");
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
43 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
44 void set(const K& key, const T& x) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
45 (*self)[key] = x;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
46 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
47 void del(const K& key) throw (std::out_of_range) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
48 std::map<K,T >::iterator i = self->find(key);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
49 if (i != self->end())
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
50 self->erase(i);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
51 else
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
52 throw std::out_of_range("key not found");
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
53 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
54 bool has_key(const K& key) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
55 std::map<K,T >::iterator i = self->find(key);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
56 return i != self->end();
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
57 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
58 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
59 };
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
60 }