5#ifndef CORE_FXCRT_CODE_POINT_VIEW_H_
6#define CORE_FXCRT_CODE_POINT_VIEW_H_
8#include "build/build_config.h"
9#include "core/fxcrt/string_view_template.h"
10#include "core/fxcrt/utf16.h"
11#include "third_party/base/check_op.h"
15#if defined(WCHAR_T_IS_16_BIT)
18class CodePointView final {
22 bool operator==(
const Iterator& other)
const {
23 return current_ == other.current_;
26 bool operator!=(
const Iterator& other)
const {
27 return current_ != other.current_;
30 Iterator& operator++() {
31 DCHECK_LT(current_, end_);
32 current_ += IsSupplementary(code_point_) ? 2 : 1;
33 code_point_ = Decode();
37 char32_t operator*()
const {
38 DCHECK_NE(kSentinel, code_point_);
43 friend class CodePointView;
45 static constexpr char32_t kSentinel = -1;
47 Iterator(
const wchar_t* begin,
const wchar_t* end)
48 : current_(begin), end_(end), code_point_(Decode()) {}
51 if (current_ >= end_) {
55 char32_t code_point = *current_;
56 if (IsHighSurrogate(code_point)) {
57 const wchar_t* next = current_ + 1;
58 if (next < end_ && IsLowSurrogate(*next)) {
59 code_point = SurrogatePair(code_point, *next).ToCodePoint();
66 const wchar_t* current_;
71 explicit CodePointView(WideStringView backing)
72 : begin_(backing.begin()), end_(backing.end()) {
73 DCHECK_LE(begin_, end_);
76 Iterator begin()
const {
return Iterator(begin_, end_); }
78 Iterator end()
const {
return Iterator(end_, end_); }
82 const wchar_t* begin_;
86using CodePointView = WideStringView;
TEST(FXCRYPT, MD5GenerateEmtpyData)