13 std::unordered_set<typename TStorage::LinkAddressType>& visited,
14 typename TStorage::LinkAddressType address,
const TIsElement& isElement,
15 const TAppendElement& appendElement,
bool renderIndex =
false,
bool renderDebug =
false)
17 using Address =
typename TStorage::LinkAddressType;
18 const auto& constants = storage.Constants;
19 if (address == constants.Null || address == constants.Any || address == constants.Itself)
21 if (!Exists(storage, address))
25 output << std::to_string(address);
28 if (!visited.insert(address).second)
32 output << std::to_string(address);
38 output << std::to_string(address) <<
':';
39 auto appendReference = [&](Address reference) {
40 if (reference == address)
42 output << std::to_string(reference);
46 if (reference != constants.Null && reference != constants.Any && reference != constants.Itself &&
47 Exists(storage, reference))
50 if (isElement(element))
52 appendElement(output, element);
56 AppendStructure(storage, output, visited, reference, isElement, appendElement, renderIndex, renderDebug);
58 appendReference(link.
Source);
60 appendReference(link.
Target);
66 requires std::invocable<const TAppendElement&, std::ostream&, const Link<typename TStorage::LinkAddressType>&>
67 std::string
FormatStructure(TStorage& storage,
typename TStorage::LinkAddressType address,
68 const TIsElement& isElement,
const TAppendElement& appendElement,
69 bool renderIndex =
false,
bool renderDebug =
false)
71 std::ostringstream output;
72 std::unordered_set<typename TStorage::LinkAddressType> visited;
73 AppendStructure(storage, output, visited, address, isElement, appendElement, renderIndex, renderDebug);
79 std::string
FormatStructure(TStorage& storage,
typename TStorage::LinkAddressType address,
80 const TIsElement& isElement,
bool renderIndex =
false,
bool renderDebug =
false)
83 output << std::to_string(element.Index);
85 return FormatStructure(storage, address, isElement, appendElement, renderIndex, renderDebug);