1 // Copyright 2021 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 #ifndef ABSL_STRINGS_INTERNAL_CORD_REP_CONSUME_H_ 16 #define ABSL_STRINGS_INTERNAL_CORD_REP_CONSUME_H_ 17 18 #include <functional> 19 20 #include "absl/functional/function_ref.h" 21 #include "absl/strings/internal/cord_internal.h" 22 23 namespace absl { 24 ABSL_NAMESPACE_BEGIN 25 namespace cord_internal { 26 27 // Consume() and ReverseConsume() consume CONCAT based trees and invoke the 28 // provided functor with the contained nodes in the proper forward or reverse 29 // order, which is used to convert CONCAT trees into other tree or cord data. 30 // All CONCAT and SUBSTRING nodes are processed internally. The 'offset` 31 // parameter of the functor is non-zero for any nodes below SUBSTRING nodes. 32 // It's up to the caller to form these back into SUBSTRING nodes or otherwise 33 // store offset / prefix information. These functions are intended to be used 34 // only for migration / transitional code where due to factors such as ODR 35 // violations, we can not 100% guarantee that all code respects 'new format' 36 // settings and flags, so we need to be able to parse old data on the fly until 37 // all old code is deprecated / no longer the default format. 38 void Consume(CordRep* rep, 39 FunctionRef<void(CordRep*, size_t, size_t)> consume_fn); 40 void ReverseConsume(CordRep* rep, 41 FunctionRef<void(CordRep*, size_t, size_t)> consume_fn); 42 43 } // namespace cord_internal 44 ABSL_NAMESPACE_END 45 } // namespace absl 46 47 #endif // ABSL_STRINGS_INTERNAL_CORD_REP_CONSUME_H_ 48