File indexing completed on 2024-11-15 09:01:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef ABSL_STRINGS_INTERNAL_CORD_DATA_EDGE_H_
0016 #define ABSL_STRINGS_INTERNAL_CORD_DATA_EDGE_H_
0017
0018 #include <cassert>
0019 #include <cstddef>
0020
0021 #include "absl/base/config.h"
0022 #include "absl/strings/internal/cord_internal.h"
0023 #include "absl/strings/internal/cord_rep_flat.h"
0024 #include "absl/strings/string_view.h"
0025
0026 namespace absl {
0027 ABSL_NAMESPACE_BEGIN
0028 namespace cord_internal {
0029
0030
0031
0032 inline bool IsDataEdge(const CordRep* edge) {
0033 assert(edge != nullptr);
0034
0035
0036
0037
0038 if (edge->tag == EXTERNAL || edge->tag >= FLAT) return true;
0039 if (edge->tag == SUBSTRING) edge = edge->substring()->child;
0040 return edge->tag == EXTERNAL || edge->tag >= FLAT;
0041 }
0042
0043
0044
0045 inline absl::string_view EdgeData(const CordRep* edge) {
0046 assert(IsDataEdge(edge));
0047
0048 size_t offset = 0;
0049 const size_t length = edge->length;
0050 if (edge->IsSubstring()) {
0051 offset = edge->substring()->start;
0052 edge = edge->substring()->child;
0053 }
0054 return edge->tag >= FLAT
0055 ? absl::string_view{edge->flat()->Data() + offset, length}
0056 : absl::string_view{edge->external()->base + offset, length};
0057 }
0058
0059 }
0060 ABSL_NAMESPACE_END
0061 }
0062
0063 #endif