File: string

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (90 lines) | stat: -rw-r--r-- 2,729 bytes parent folder | download | duplicates (2)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#ifndef _STRING_
#define _STRING_

// For size_t
#include <string.h>

typedef unsigned __INT16_TYPE__ char16;
typedef unsigned __INT32_TYPE__ char32;

namespace std {
template <typename T>
class allocator {};
template <typename T>
class char_traits {};
template <typename C, typename T = char_traits<C>, typename A = allocator<C>>
struct basic_string {
  typedef size_t size_type;
  typedef basic_string<C, T, A> _Type;
  basic_string();
  basic_string(const C *p, const A &a = A());
  basic_string(const C *p, size_type count);

  ~basic_string();

  const C *c_str() const;
  const C *data() const;

  bool empty() const;
  size_type size() const;

  _Type& append(const C *s);
  _Type& append(const C *s, size_type n);
  _Type& assign(const C *s);
  _Type& assign(const C *s, size_type n);

  int compare(const _Type&) const;
  int compare(const C* s) const;
  int compare(size_type pos, size_type len, const _Type&) const;
  int compare(size_type pos, size_type len, const C* s) const;

  size_type find(const _Type& str, size_type pos = 0) const;
  size_type find(const C* s, size_type pos = 0) const;
  size_type find(const C* s, size_type pos, size_type n) const;

  _Type& insert(size_type pos, const _Type& str);
  _Type& insert(size_type pos, const C* s);
  _Type& insert(size_type pos, const C* s, size_type n);

  _Type& operator[](size_type);
  const _Type& operator[](size_type) const;

  _Type& operator+=(const _Type& str);
  _Type& operator+=(const C* s);
  _Type& operator=(const _Type& str);
  _Type& operator=(const C* s);
};

typedef basic_string<char> string;
typedef basic_string<wchar_t> wstring;
typedef basic_string<char16> u16string;
typedef basic_string<char32> u32string;

template <typename C, typename T = char_traits<C>>
struct basic_string_view {
  const C *str;
  constexpr basic_string_view(const C* s) : str(s) {}
};
typedef basic_string_view<char> string_view;
typedef basic_string_view<wchar_t> wstring_view;
typedef basic_string_view<char16> u16string_view;
typedef basic_string_view<char32> u32string_view;

std::string operator+(const std::string&, const std::string&);
std::string operator+(const std::string&, const char*);
std::string operator+(const char*, const std::string&);

bool operator==(const std::string&, const std::string&);
bool operator==(const std::string&, const char*);
bool operator==(const char*, const std::string&);

bool operator!=(const std::string&, const std::string&);
bool operator!=(const std::string&, const char*);
bool operator!=(const char*, const std::string&);

bool operator==(const std::wstring&, const std::wstring&);
bool operator==(const std::wstring&, const wchar_t*);
bool operator==(const wchar_t*, const std::wstring&);
}

#endif // _STRING_