intl/icu/source/common/chariter.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /*
michael@0 2 **********************************************************************
michael@0 3 * Copyright (C) 1999-2011, International Business Machines
michael@0 4 * Corporation and others. All Rights Reserved.
michael@0 5 **********************************************************************
michael@0 6 */
michael@0 7
michael@0 8 #include "unicode/chariter.h"
michael@0 9
michael@0 10 U_NAMESPACE_BEGIN
michael@0 11
michael@0 12 ForwardCharacterIterator::~ForwardCharacterIterator() {}
michael@0 13 ForwardCharacterIterator::ForwardCharacterIterator()
michael@0 14 : UObject()
michael@0 15 {}
michael@0 16 ForwardCharacterIterator::ForwardCharacterIterator(const ForwardCharacterIterator &other)
michael@0 17 : UObject(other)
michael@0 18 {}
michael@0 19
michael@0 20
michael@0 21 CharacterIterator::CharacterIterator()
michael@0 22 : textLength(0), pos(0), begin(0), end(0) {
michael@0 23 }
michael@0 24
michael@0 25 CharacterIterator::CharacterIterator(int32_t length)
michael@0 26 : textLength(length), pos(0), begin(0), end(length) {
michael@0 27 if(textLength < 0) {
michael@0 28 textLength = end = 0;
michael@0 29 }
michael@0 30 }
michael@0 31
michael@0 32 CharacterIterator::CharacterIterator(int32_t length, int32_t position)
michael@0 33 : textLength(length), pos(position), begin(0), end(length) {
michael@0 34 if(textLength < 0) {
michael@0 35 textLength = end = 0;
michael@0 36 }
michael@0 37 if(pos < 0) {
michael@0 38 pos = 0;
michael@0 39 } else if(pos > end) {
michael@0 40 pos = end;
michael@0 41 }
michael@0 42 }
michael@0 43
michael@0 44 CharacterIterator::CharacterIterator(int32_t length, int32_t textBegin, int32_t textEnd, int32_t position)
michael@0 45 : textLength(length), pos(position), begin(textBegin), end(textEnd) {
michael@0 46 if(textLength < 0) {
michael@0 47 textLength = 0;
michael@0 48 }
michael@0 49 if(begin < 0) {
michael@0 50 begin = 0;
michael@0 51 } else if(begin > textLength) {
michael@0 52 begin = textLength;
michael@0 53 }
michael@0 54 if(end < begin) {
michael@0 55 end = begin;
michael@0 56 } else if(end > textLength) {
michael@0 57 end = textLength;
michael@0 58 }
michael@0 59 if(pos < begin) {
michael@0 60 pos = begin;
michael@0 61 } else if(pos > end) {
michael@0 62 pos = end;
michael@0 63 }
michael@0 64 }
michael@0 65
michael@0 66 CharacterIterator::~CharacterIterator() {}
michael@0 67
michael@0 68 CharacterIterator::CharacterIterator(const CharacterIterator &that) :
michael@0 69 ForwardCharacterIterator(that),
michael@0 70 textLength(that.textLength), pos(that.pos), begin(that.begin), end(that.end)
michael@0 71 {
michael@0 72 }
michael@0 73
michael@0 74 CharacterIterator &
michael@0 75 CharacterIterator::operator=(const CharacterIterator &that) {
michael@0 76 ForwardCharacterIterator::operator=(that);
michael@0 77 textLength = that.textLength;
michael@0 78 pos = that.pos;
michael@0 79 begin = that.begin;
michael@0 80 end = that.end;
michael@0 81 return *this;
michael@0 82 }
michael@0 83
michael@0 84 // implementing first[32]PostInc() directly in a subclass should be faster
michael@0 85 // but these implementations make subclassing a little easier
michael@0 86 UChar
michael@0 87 CharacterIterator::firstPostInc(void) {
michael@0 88 setToStart();
michael@0 89 return nextPostInc();
michael@0 90 }
michael@0 91
michael@0 92 UChar32
michael@0 93 CharacterIterator::first32PostInc(void) {
michael@0 94 setToStart();
michael@0 95 return next32PostInc();
michael@0 96 }
michael@0 97
michael@0 98 U_NAMESPACE_END

mercurial