1 // Copyright 2019 The Abseil Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #include "absl/strings/internal/cordz_sample_token.h" 16 17 #include "absl/base/config.h" 18 #include "absl/strings/internal/cordz_handle.h" 19 #include "absl/strings/internal/cordz_info.h" 20 21 namespace absl { 22 ABSL_NAMESPACE_BEGIN 23 namespace cord_internal { 24 operator ++()25CordzSampleToken::Iterator& CordzSampleToken::Iterator::operator++() { 26 if (current_) { 27 current_ = current_->Next(*token_); 28 } 29 return *this; 30 } 31 operator ++(int)32CordzSampleToken::Iterator CordzSampleToken::Iterator::operator++(int) { 33 Iterator it(*this); 34 operator++(); 35 return it; 36 } 37 operator ==(const CordzSampleToken::Iterator & lhs,const CordzSampleToken::Iterator & rhs)38bool operator==(const CordzSampleToken::Iterator& lhs, 39 const CordzSampleToken::Iterator& rhs) { 40 return lhs.current_ == rhs.current_ && 41 (lhs.current_ == nullptr || lhs.token_ == rhs.token_); 42 } 43 operator !=(const CordzSampleToken::Iterator & lhs,const CordzSampleToken::Iterator & rhs)44bool operator!=(const CordzSampleToken::Iterator& lhs, 45 const CordzSampleToken::Iterator& rhs) { 46 return !(lhs == rhs); 47 } 48 operator *() const49CordzSampleToken::Iterator::reference CordzSampleToken::Iterator::operator*() 50 const { 51 return *current_; 52 } 53 operator ->() const54CordzSampleToken::Iterator::pointer CordzSampleToken::Iterator::operator->() 55 const { 56 return current_; 57 } 58 Iterator(const CordzSampleToken * token)59CordzSampleToken::Iterator::Iterator(const CordzSampleToken* token) 60 : token_(token), current_(CordzInfo::Head(*token)) {} 61 62 } // namespace cord_internal 63 ABSL_NAMESPACE_END 64 } // namespace absl 65