]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/common/bytestrieiterator.cpp
ICU-66108.tar.gz
[apple/icu.git] / icuSources / common / bytestrieiterator.cpp
index d8318f6524f9670830edae3dc2befee6e08af94f..e64961a1f1365af63de03acb3ba9d58fecde900d 100644 (file)
@@ -1,10 +1,12 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /*
 *******************************************************************************
-*   Copyright (C) 2010-2011, International Business Machines
+*   Copyright (C) 2010-2012, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *******************************************************************************
 *   file name:  bytestrieiterator.cpp
-*   encoding:   US-ASCII
+*   encoding:   UTF-8
 *   tab size:   8 (not used)
 *   indentation:4
 *
@@ -22,7 +24,7 @@ U_NAMESPACE_BEGIN
 
 BytesTrie::Iterator::Iterator(const void *trieBytes, int32_t maxStringLength,
                               UErrorCode &errorCode)
-        : bytes_(reinterpret_cast<const uint8_t *>(trieBytes)),
+        : bytes_(static_cast<const uint8_t *>(trieBytes)),
           pos_(bytes_), initialPos_(bytes_),
           remainingMatchLength_(-1), initialRemainingMatchLength_(-1),
           str_(NULL), maxLength_(maxStringLength), value_(0), stack_(NULL) {
@@ -139,7 +141,6 @@ BytesTrie::Iterator::next(UErrorCode &errorCode) {
             } else {
                 pos_=skipValue(pos, node);
             }
-            sp_.set(str_->data(), str_->length());
             return TRUE;
         }
         if(maxLength_>0 && str_->length()==maxLength_) {
@@ -167,10 +168,14 @@ BytesTrie::Iterator::next(UErrorCode &errorCode) {
     }
 }
 
+StringPiece
+BytesTrie::Iterator::getString() const {
+    return str_ == NULL ? StringPiece() : str_->toStringPiece();
+}
+
 UBool
 BytesTrie::Iterator::truncateAndStop() {
     pos_=NULL;
-    sp_.set(str_->data(), str_->length());
     value_=-1;  // no real value for str
     return TRUE;
 }
@@ -199,7 +204,6 @@ BytesTrie::Iterator::branchNext(const uint8_t *pos, int32_t length, UErrorCode &
     str_->append((char)trieByte, errorCode);
     if(isFinal) {
         pos_=NULL;
-        sp_.set(str_->data(), str_->length());
         value_=value;
         return NULL;
     } else {