MCPcopy Create free account
hub / github.com/Icinga/icinga2 / iterator

Class iterator

third-party/utf8cpp/source/utf8/checked.h:250–308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

248 // The iterator class
249 template <typename octet_iterator>
250 class iterator {
251 octet_iterator it;
252 octet_iterator range_start;
253 octet_iterator range_end;
254 public:
255 typedef uint32_t value_type;
256 typedef uint32_t* pointer;
257 typedef uint32_t& reference;
258 typedef std::ptrdiff_t difference_type;
259 typedef std::bidirectional_iterator_tag iterator_category;
260 iterator () {}
261 explicit iterator (const octet_iterator& octet_it,
262 const octet_iterator& rangestart,
263 const octet_iterator& rangeend) :
264 it(octet_it), range_start(rangestart), range_end(rangeend)
265 {
266 if (it < range_start || it > range_end)
267 throw std::out_of_range("Invalid utf-8 iterator position");
268 }
269 // the default "big three" are OK
270 octet_iterator base () const { return it; }
271 uint32_t operator * () const
272 {
273 octet_iterator temp = it;
274 return utf8::next(temp, range_end);
275 }
276 bool operator == (const iterator& rhs) const
277 {
278 if (range_start != rhs.range_start || range_end != rhs.range_end)
279 throw std::logic_error("Comparing utf-8 iterators defined with different ranges");
280 return (it == rhs.it);
281 }
282 bool operator != (const iterator& rhs) const
283 {
284 return !(operator == (rhs));
285 }
286 iterator& operator ++ ()
287 {
288 utf8::next(it, range_end);
289 return *this;
290 }
291 iterator operator ++ (int)
292 {
293 iterator temp = *this;
294 utf8::next(it, range_end);
295 return temp;
296 }
297 iterator& operator -- ()
298 {
299 utf8::prior(it, range_start);
300 return *this;
301 }
302 iterator operator -- (int)
303 {
304 iterator temp = *this;
305 utf8::prior(it, range_start);
306 return temp;
307 }

Callers 1

iter_implMethod · 0.50

Calls 2

nextFunction · 0.70
priorFunction · 0.70

Tested by

no test coverage detected