Browse Source

AK: Add two helpers to DeprecatedStringCodePointIterator

Andreas Kling 2 năm trước cách đây
mục cha
commit
6b497b8710
1 tập tin đã thay đổi với 12 bổ sung0 xóa
  1. 12 0
      AK/Utf8View.h

+ 12 - 0
AK/Utf8View.h

@@ -141,6 +141,18 @@ public:
         return value;
         return value;
     }
     }
 
 
+    [[nodiscard]] Optional<u32> peek() const
+    {
+        if (m_it.done())
+            return {};
+        return *m_it;
+    }
+
+    [[nodiscard]] size_t byte_offset() const
+    {
+        return Utf8View(m_string).byte_offset_of(m_it);
+    }
+
     DeprecatedStringCodePointIterator(DeprecatedString string)
     DeprecatedStringCodePointIterator(DeprecatedString string)
         : m_string(move(string))
         : m_string(move(string))
         , m_it(Utf8View(m_string).begin())
         , m_it(Utf8View(m_string).begin())