Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
dart::String::CodePointIterator Class Reference

#include <object.h>

Inheritance diagram for dart::String::CodePointIterator:
dart::ValueObject

Public Member Functions

 CodePointIterator (const String &str)
 
 CodePointIterator (const String &str, intptr_t start, intptr_t length)
 
int32_t Current () const
 
bool Next ()
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Detailed Description

Definition at line 10181 of file object.h.

Constructor & Destructor Documentation

◆ CodePointIterator() [1/2]

dart::String::CodePointIterator::CodePointIterator ( const String str)
inlineexplicit

Definition at line 10183 of file object.h.

10184 : str_(str), ch_(0), index_(-1), end_(str.Length()) {
10185 ASSERT(!str_.IsNull());
10186 }
bool IsNull() const
Definition: object.h:363
#define ASSERT(E)

◆ CodePointIterator() [2/2]

dart::String::CodePointIterator::CodePointIterator ( const String str,
intptr_t  start,
intptr_t  length 
)
inline

Definition at line 10188 of file object.h.

10189 : str_(str), ch_(0), index_(start - 1), end_(start + length) {
10190 ASSERT(start >= 0);
10191 ASSERT(end_ <= str.Length());
10192 }
size_t length

Member Function Documentation

◆ Current()

int32_t dart::String::CodePointIterator::Current ( ) const
inline

Definition at line 10194 of file object.h.

10194 {
10195 ASSERT(index_ >= 0);
10196 ASSERT(index_ < end_);
10197 return ch_;
10198 }

◆ Next()

bool dart::String::CodePointIterator::Next ( )

Definition at line 24318 of file object.cc.

24318 {
24319 ASSERT(index_ >= -1);
24320 intptr_t length = Utf16::Length(ch_);
24321 if (index_ < (end_ - length)) {
24322 index_ += length;
24323 ch_ = str_.CharAt(index_);
24324 if (Utf16::IsLeadSurrogate(ch_) && (index_ < (end_ - 1))) {
24325 int32_t ch2 = str_.CharAt(index_ + 1);
24326 if (Utf16::IsTrailSurrogate(ch2)) {
24327 ch_ = Utf16::Decode(ch_, ch2);
24328 }
24329 }
24330 return true;
24331 }
24332 index_ = end_;
24333 return false;
24334}
uint16_t CharAt(intptr_t index) const
Definition: object.h:10259
static int32_t Decode(uint16_t lead, uint16_t trail)
Definition: unicode.h:151
static bool IsLeadSurrogate(uint32_t ch)
Definition: unicode.h:126
static intptr_t Length(int32_t ch)
Definition: unicode.h:118
static bool IsTrailSurrogate(uint32_t ch)
Definition: unicode.h:131

The documentation for this class was generated from the following files: