File tree Expand file tree Collapse file tree 5 files changed +61
-0
lines changed Expand file tree Collapse file tree 5 files changed +61
-0
lines changed Original file line number Diff line number Diff line change 88 -cppcoreguidelines-macro-usage,
99 -cppcoreguidelines-owning-memory,
1010 -cppcoreguidelines-pro-bounds-array-to-pointer-decay,
11+ -cppcoreguidelines-pro-bounds-pointer-arithmetic,
1112 -cppcoreguidelines-pro-type-const-cast,
1213 -cppcoreguidelines-pro-type-member-init,
1314 -cppcoreguidelines-pro-type-reinterpret-cast,
Original file line number Diff line number Diff line change @@ -29,6 +29,13 @@ public:
2929 const char *data() const noexcept;
3030 size_t size() const noexcept;
3131 size_t length() const noexcept;
32+
33+ using iterator = const char *;
34+ using const_iterator = const char *;
35+ const_iterator begin() const noexcept;
36+ const_iterator end() const noexcept;
37+ const_iterator cbegin() const noexcept;
38+ const_iterator cend() const noexcept;
3239};
3340
3441std::ostream &operator<<(std::ostream &, const Str &);
Original file line number Diff line number Diff line change @@ -32,6 +32,16 @@ public:
3232 const char *data() const noexcept;
3333 size_t size() const noexcept;
3434 size_t length() const noexcept;
35+
36+ using iterator = char *;
37+ iterator begin() noexcept;
38+ iterator end() noexcept;
39+
40+ using const_iterator = const char *;
41+ const_iterator begin() const noexcept;
42+ const_iterator end() const noexcept;
43+ const_iterator cbegin() const noexcept;
44+ const_iterator cend() const noexcept;
3545};
3646
3747std::ostream &operator<<(std::ostream &, const String &);
Original file line number Diff line number Diff line change @@ -48,6 +48,16 @@ class String final {
4848 size_t size () const noexcept ;
4949 size_t length () const noexcept ;
5050
51+ using iterator = char *;
52+ iterator begin () noexcept ;
53+ iterator end () noexcept ;
54+
55+ using const_iterator = const char *;
56+ const_iterator begin () const noexcept ;
57+ const_iterator end () const noexcept ;
58+ const_iterator cbegin () const noexcept ;
59+ const_iterator cend () const noexcept ;
60+
5161 // Internal API only intended for the cxxbridge code generator.
5262 String (unsafe_bitcopy_t , const String &) noexcept ;
5363
@@ -78,6 +88,13 @@ class Str final {
7888 Str (const Str &) noexcept = default ;
7989 ~Str () noexcept = default ;
8090
91+ using iterator = const char *;
92+ using const_iterator = const char *;
93+ const_iterator begin () const noexcept ;
94+ const_iterator end () const noexcept ;
95+ const_iterator cbegin () const noexcept ;
96+ const_iterator cend () const noexcept ;
97+
8198private:
8299 friend impl<Str>;
83100 // Not necessarily ABI compatible with &str. Codegen will translate to
Original file line number Diff line number Diff line change @@ -122,6 +122,24 @@ size_t String::size() const noexcept { return cxxbridge1$string$len(this); }
122122
123123size_t String::length () const noexcept { return cxxbridge1$string$len (this ); }
124124
125+ String::iterator String::begin () noexcept {
126+ return const_cast <char *>(this ->data ());
127+ }
128+
129+ String::iterator String::end () noexcept {
130+ return const_cast <char *>(this ->data ()) + this ->size ();
131+ }
132+
133+ String::const_iterator String::begin () const noexcept { return this ->cbegin (); }
134+
135+ String::const_iterator String::end () const noexcept { return this ->cend (); }
136+
137+ String::const_iterator String::cbegin () const noexcept { return this ->data (); }
138+
139+ String::const_iterator String::cend () const noexcept {
140+ return this ->data () + this ->size ();
141+ }
142+
125143String::String (unsafe_bitcopy_t , const String &bits) noexcept
126144 : repr(bits.repr) {}
127145
@@ -158,6 +176,14 @@ Str::operator std::string() const {
158176 return std::string (this ->data (), this ->size ());
159177}
160178
179+ Str::const_iterator Str::begin () const noexcept { return this ->cbegin (); }
180+
181+ Str::const_iterator Str::end () const noexcept { return this ->cend (); }
182+
183+ Str::const_iterator Str::cbegin () const noexcept { return this ->ptr ; }
184+
185+ Str::const_iterator Str::cend () const noexcept { return this ->ptr + this ->len ; }
186+
161187std::ostream &operator <<(std::ostream &os, const Str &s) {
162188 os.write (s.data (), s.size ());
163189 return os;
You can’t perform that action at this time.
0 commit comments