Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(552)

Unified Diff: runtime/vm/object.h

Issue 11416054: Provide a code point iterator to the String class to simplify iteration. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address review comments Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | runtime/vm/object.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.h
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index 07cb5bf6810a4918fbf3a6ffd74f419c27709944..a36be5d17a1d37ad5551fc6d62c6f873545775ae 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -3708,6 +3708,29 @@ class String : public Instance {
static const intptr_t kSizeofRawString = sizeof(RawObject) + (2 * kWordSize);
static const intptr_t kMaxElements = kSmiMax / kTwoByteChar;
+ class CodePointIterator : public ValueObject {
+ public:
+ explicit CodePointIterator(const String& str)
+ : str_(str),
+ index_(-1),
+ ch_(-1) {
+ }
+
+ int32_t Current() {
+ ASSERT(index_ >= 0);
+ ASSERT(index_ < str_.Length());
+ return ch_;
+ }
+
+ bool Next();
+
+ private:
+ const String& str_;
+ intptr_t index_;
+ int32_t ch_;
+ DISALLOW_IMPLICIT_CONSTRUCTORS(CodePointIterator);
+ };
+
intptr_t Length() const { return Smi::Value(raw_ptr()->length_); }
static intptr_t length_offset() { return OFFSET_OF(RawString, length_); }
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698