Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
3.5 KiB

  1. //
  2. // std::map
  3. //
  4. %include <std_pair.i>
  5. %include <std_container.i>
  6. %define %std_map_methods_common(map...)
  7. %std_container_methods(map);
  8. size_type erase(const key_type& x);
  9. size_type count(const key_type& x) const;
  10. #ifdef SWIG_EXPORT_ITERATOR_METHODS
  11. // iterator insert(iterator position, const value_type& x);
  12. void erase(iterator position);
  13. void erase(iterator first, iterator last);
  14. iterator find(const key_type& x);
  15. iterator lower_bound(const key_type& x);
  16. iterator upper_bound(const key_type& x);
  17. #endif
  18. %enddef
  19. %define %std_map_methods(map...)
  20. %std_map_methods_common(map);
  21. #ifdef SWIG_EXPORT_ITERATOR_METHODS
  22. // iterator insert(const value_type& x);
  23. #endif
  24. %enddef
  25. // ------------------------------------------------------------------------
  26. // std::map
  27. //
  28. // const declarations are used to guess the intent of the function being
  29. // exported; therefore, the following rationale is applied:
  30. //
  31. // -- f(std::map<T>), f(const std::map<T>&):
  32. // the parameter being read-only, either a sequence or a
  33. // previously wrapped std::map<T> can be passed.
  34. // -- f(std::map<T>&), f(std::map<T>*):
  35. // the parameter may be modified; therefore, only a wrapped std::map
  36. // can be passed.
  37. // -- std::map<T> f(), const std::map<T>& f():
  38. // the map is returned by copy; therefore, a sequence of T:s
  39. // is returned which is most easily used in other functions
  40. // -- std::map<T>& f(), std::map<T>* f():
  41. // the map is returned by reference; therefore, a wrapped std::map
  42. // is returned
  43. // -- const std::map<T>* f(), f(const std::map<T>*):
  44. // for consistency, they expect and return a plain map pointer.
  45. // ------------------------------------------------------------------------
  46. %{
  47. #include <map>
  48. #include <algorithm>
  49. #include <stdexcept>
  50. %}
  51. // exported class
  52. namespace std {
  53. template<class _Key, class _Tp, class _Compare = std::less<_Key >,
  54. class _Alloc = allocator<std::pair<const _Key, _Tp > > >
  55. class map {
  56. public:
  57. typedef size_t size_type;
  58. typedef ptrdiff_t difference_type;
  59. typedef _Key key_type;
  60. typedef _Tp mapped_type;
  61. typedef std::pair<const _Key, _Tp> value_type;
  62. typedef value_type* pointer;
  63. typedef const value_type* const_pointer;
  64. typedef value_type& reference;
  65. typedef const value_type& const_reference;
  66. typedef _Alloc allocator_type;
  67. %traits_swigtype(_Key);
  68. %traits_swigtype(_Tp);
  69. %fragment(SWIG_Traits_frag(std::pair< _Key, _Tp >), "header",
  70. fragment=SWIG_Traits_frag(_Key),
  71. fragment=SWIG_Traits_frag(_Tp),
  72. fragment="StdPairTraits") {
  73. namespace swig {
  74. template <> struct traits<std::pair< _Key, _Tp > > {
  75. typedef pointer_category category;
  76. static const char* type_name() {
  77. return "std::pair<" #_Key "," #_Tp " >";
  78. }
  79. };
  80. }
  81. }
  82. %fragment(SWIG_Traits_frag(std::map<_Key, _Tp, _Compare, _Alloc >), "header",
  83. fragment=SWIG_Traits_frag(std::pair<_Key, _Tp >),
  84. fragment="StdMapTraits") {
  85. namespace swig {
  86. template <> struct traits<std::map<_Key, _Tp, _Compare, _Alloc > > {
  87. typedef pointer_category category;
  88. static const char* type_name() {
  89. return "std::map<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >";
  90. }
  91. };
  92. }
  93. }
  94. %typemap_traits_ptr(SWIG_TYPECHECK_MAP, std::map<_Key, _Tp, _Compare, _Alloc >);
  95. map( const _Compare& );
  96. #ifdef %swig_map_methods
  97. // Add swig/language extra methods
  98. %swig_map_methods(std::map<_Key, _Tp, _Compare, _Alloc >);
  99. #endif
  100. %std_map_methods(map);
  101. };
  102. }