29 struct TestMarkPrinter::Impl {
30 const std::vector<TestMark::LinearizedRecord>* array;
32 const TestMark::LinearizedRecord* mark;
33 void (TestMarkFormatter::* open)(
const std::string&,
const TestMark*, int);
34 void (TestMarkFormatter::* close)(
const std::string&,
const TestMark*, int);
37 std::vector<StackRecord> stack;
41 const std::vector<TestMark::LinearizedRecord>* array_,
46 const Impl&) =
delete;
48 const Impl&) =
delete;
51 TestMarkFormatter& formatter_,
54 TestMarkFormatter& formatter_,
55 void (TestMarkFormatter::* open_)(
const std::string&,
const TestMark*,
int),
56 void (TestMarkFormatter::* close_)(
const std::string&,
const TestMark*,
int));
59 TestMarkPrinter::Impl::Impl(
60 const std::vector<TestMark::LinearizedRecord>* array_,
65 assert(array !=
nullptr);
69 void TestMarkPrinter::Impl::printTop(
70 TestMarkFormatter& formatter_,
72 assert(!stack.empty());
74 const auto& top_(stack.back());
75 if(top_.open !=
nullptr) {
77 (formatter_.*top_.open)(top_.mark->label, top_.mark->me, top_.indent);
79 (formatter_.*top_.close)(top_.mark->label, top_.mark->me, top_.indent);
83 bool TestMarkPrinter::Impl::handleItem(
84 TestMarkFormatter& formatter_,
85 void (TestMarkFormatter::* open_)(
const std::string&,
const TestMark*,
int),
86 void (TestMarkFormatter::* close_)(
const std::string&,
const TestMark*,
int)) {
87 assert(array !=
nullptr);
90 if(index >= array->size()) {
93 printTop(formatter_,
false);
102 auto& curr_(array->at(index));
105 stack.push_back({&curr_, open_, close_, 0});
106 printTop(formatter_,
true);
109 assert(!stack.empty());
112 const auto* top_(&stack.back());
113 if(top_->mark->level + 1 != curr_.level) {
114 printTop(formatter_,
false);
116 assert(!stack.empty());
121 stack.push_back({&curr_, open_, close_, top_->indent + 1});
122 printTop(formatter_,
true);
132 const std::vector<TestMark::LinearizedRecord>* array_,
134 pimpl(new Impl(array_, index_)) {
144 return pimpl->handleItem(
150 return pimpl->handleItem(
156 return pimpl->handleItem(
162 return pimpl->handleItem(formatter_,
nullptr,
nullptr);