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.

270 lines
6.3 KiB

  1. %include <exception.i>
  2. %include <std_container.i>
  3. %include <std_alloc.i>
  4. %include <std_char_traits.i>
  5. %{
  6. #include <string>
  7. %}
  8. namespace std
  9. {
  10. %naturalvar basic_string;
  11. }
  12. namespace std {
  13. template <class _CharT, class _Traits = char_traits<_CharT>, typename _Alloc = allocator<_CharT> >
  14. class basic_string
  15. {
  16. #if !defined(SWIG_STD_MODERN_STL) || defined(SWIG_STD_NOMODERN_STL)
  17. %ignore push_back;
  18. %ignore clear;
  19. %ignore compare;
  20. %ignore append;
  21. #endif
  22. public:
  23. typedef size_t size_type;
  24. typedef ptrdiff_t difference_type;
  25. typedef _CharT value_type;
  26. typedef value_type reference;
  27. typedef value_type const_reference;
  28. typedef _Alloc allocator_type;
  29. static const size_type npos;
  30. #ifdef SWIG_EXPORT_ITERATOR_METHODS
  31. class iterator;
  32. class reverse_iterator;
  33. class const_iterator;
  34. class const_reverse_iterator;
  35. #endif
  36. %traits_swigtype(_CharT);
  37. %fragment(SWIG_Traits_frag(_CharT));
  38. basic_string(const _CharT* __s, size_type __n);
  39. // Capacity:
  40. size_type length() const;
  41. size_type max_size() const;
  42. size_type capacity() const;
  43. void reserve(size_type __res_arg = 0);
  44. // Modifiers:
  45. basic_string&
  46. append(const basic_string& __str);
  47. basic_string&
  48. append(const basic_string& __str, size_type __pos, size_type __n);
  49. basic_string&
  50. append(const _CharT* __s, size_type __n);
  51. basic_string&
  52. append(size_type __n, _CharT __c);
  53. basic_string&
  54. assign(const basic_string& __str);
  55. basic_string&
  56. assign(const basic_string& __str, size_type __pos, size_type __n);
  57. basic_string&
  58. assign(const _CharT* __s, size_type __n);
  59. basic_string&
  60. insert(size_type __pos1, const basic_string& __str);
  61. basic_string&
  62. insert(size_type __pos1, const basic_string& __str,
  63. size_type __pos2, size_type __n);
  64. basic_string&
  65. insert(size_type __pos, const _CharT* __s, size_type __n);
  66. basic_string&
  67. insert(size_type __pos, size_type __n, _CharT __c);
  68. basic_string&
  69. erase(size_type __pos = 0, size_type __n = npos);
  70. basic_string&
  71. replace(size_type __pos, size_type __n, const basic_string& __str);
  72. basic_string&
  73. replace(size_type __pos1, size_type __n1, const basic_string& __str,
  74. size_type __pos2, size_type __n2);
  75. basic_string&
  76. replace(size_type __pos, size_type __n1, const _CharT* __s,
  77. size_type __n2);
  78. basic_string&
  79. replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c);
  80. size_type
  81. copy(_CharT* __s, size_type __n, size_type __pos = 0) const;
  82. // String operations:
  83. const _CharT* c_str() const;
  84. size_type
  85. find(const _CharT* __s, size_type __pos, size_type __n) const;
  86. size_type
  87. find(const basic_string& __str, size_type __pos = 0) const;
  88. size_type
  89. find(_CharT __c, size_type __pos = 0) const;
  90. size_type
  91. rfind(const basic_string& __str, size_type __pos = npos) const;
  92. size_type
  93. rfind(const _CharT* __s, size_type __pos, size_type __n) const;
  94. size_type
  95. rfind(_CharT __c, size_type __pos = npos) const;
  96. size_type
  97. find_first_of(const basic_string& __str, size_type __pos = 0) const;
  98. size_type
  99. find_first_of(const _CharT* __s, size_type __pos, size_type __n) const;
  100. size_type
  101. find_first_of(_CharT __c, size_type __pos = 0) const;
  102. size_type
  103. find_last_of(const basic_string& __str, size_type __pos = npos) const;
  104. size_type
  105. find_last_of(const _CharT* __s, size_type __pos, size_type __n) const;
  106. size_type
  107. find_last_of(_CharT __c, size_type __pos = npos) const;
  108. size_type
  109. find_first_not_of(const basic_string& __str, size_type __pos = 0) const;
  110. size_type
  111. find_first_not_of(const _CharT* __s, size_type __pos,
  112. size_type __n) const;
  113. size_type
  114. find_first_not_of(_CharT __c, size_type __pos = 0) const;
  115. size_type
  116. find_last_not_of(const basic_string& __str, size_type __pos = npos) const;
  117. size_type
  118. find_last_not_of(const _CharT* __s, size_type __pos,
  119. size_type __n) const;
  120. size_type
  121. find_last_not_of(_CharT __c, size_type __pos = npos) const;
  122. basic_string
  123. substr(size_type __pos = 0, size_type __n = npos) const;
  124. int
  125. compare(const basic_string& __str) const;
  126. int
  127. compare(size_type __pos, size_type __n, const basic_string& __str) const;
  128. int
  129. compare(size_type __pos1, size_type __n1, const basic_string& __str,
  130. size_type __pos2, size_type __n2) const;
  131. %ignore pop_back();
  132. %ignore front() const;
  133. %ignore back() const;
  134. %ignore basic_string(size_type n);
  135. %std_sequence_methods_val(basic_string);
  136. %ignore pop();
  137. #ifdef %swig_basic_string
  138. // Add swig/language extra methods
  139. %swig_basic_string(std::basic_string<_CharT, _Traits, _Alloc >);
  140. #endif
  141. #ifdef SWIG_EXPORT_ITERATOR_METHODS
  142. class iterator;
  143. class reverse_iterator;
  144. class const_iterator;
  145. class const_reverse_iterator;
  146. void
  147. insert(iterator __p, size_type __n, _CharT __c);
  148. basic_string&
  149. replace(iterator __i1, iterator __i2, const basic_string& __str);
  150. basic_string&
  151. replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n);
  152. basic_string&
  153. replace(iterator __i1, iterator __i2, size_type __n, _CharT __c);
  154. basic_string&
  155. replace(iterator __i1, iterator __i2, const _CharT* __k1, const _CharT* __k2);
  156. basic_string&
  157. replace(iterator __i1, iterator __i2, const_iterator __k1, const_iterator __k2);
  158. #endif
  159. basic_string& operator +=(const basic_string& v);
  160. %newobject __add__;
  161. %newobject __radd__;
  162. %extend {
  163. std::basic_string<_CharT,_Traits,_Alloc >* __add__(const basic_string& v) {
  164. std::basic_string<_CharT,_Traits,_Alloc >* res = new std::basic_string<_CharT,_Traits,_Alloc >(*self);
  165. *res += v;
  166. return res;
  167. }
  168. std::basic_string<_CharT,_Traits,_Alloc >* __radd__(const basic_string& v) {
  169. std::basic_string<_CharT,_Traits,_Alloc >* res = new std::basic_string<_CharT,_Traits,_Alloc >(v);
  170. *res += *self;
  171. return res;
  172. }
  173. std::basic_string<_CharT,_Traits,_Alloc > __str__() {
  174. return *self;
  175. }
  176. std::basic_ostream<_CharT, std::char_traits<_CharT> >&
  177. __rlshift__(std::basic_ostream<_CharT, std::char_traits<_CharT> >& out) {
  178. out << *self;
  179. return out;
  180. }
  181. }
  182. };
  183. }