Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
code_point_view.h
Go to the documentation of this file.
1// Copyright 2023 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CORE_FXCRT_CODE_POINT_VIEW_H_
6#define CORE_FXCRT_CODE_POINT_VIEW_H_
7
8#include "build/build_config.h"
9#include "core/fxcrt/check_op.h"
10#include "core/fxcrt/string_view_template.h"
11#include "core/fxcrt/utf16.h"
12
13namespace pdfium {
14
15#if defined(WCHAR_T_IS_16_BIT)
16// A view over a UTF-16 `WideStringView` suitable for iterating by code point
17// using a range-based `for` loop.
18class CodePointView final {
19 public:
20 class Iterator {
21 public:
22 ~Iterator();
23
24 bool operator==(const Iterator& other) const {
25 return current_ == other.current_;
26 }
27
28 bool operator!=(const Iterator& other) const {
29 return current_ != other.current_;
30 }
31
32 Iterator& operator++() {
35 return *this;
36 }
37
38 char32_t operator*() const {
40 return code_point_;
41 }
42
43 private:
44 friend class CodePointView;
45
46 static constexpr char32_t kSentinel = -1;
47
49
50 char32_t Decode();
51
54 char32_t code_point_;
55 };
56
59
60 Iterator begin() const { return Iterator(backing_); }
61 Iterator end() const { return Iterator(WideStringView()); }
62
63 private:
65};
66#else
68#endif // defined(WCHAR_T_IS_16_BIT)
69
70} // namespace pdfium
71
72#endif // CORE_FXCRT_CODE_POINT_VIEW_H_
WideStringView CodePointView
fxcrt::WideStringView WideStringView