| 36 | namespace internal { |
| 37 | |
| 38 | class FieldPosition { |
| 39 | public: |
| 40 | FieldPosition() : parent_(NULLPTR), index_(-1), depth_(0) {} |
| 41 | |
| 42 | FieldPosition child(int index) const { return {this, index}; } |
| 43 | |
| 44 | std::vector<int> path() const { |
| 45 | std::vector<int> path(depth_); |
| 46 | const FieldPosition* cur = this; |
| 47 | for (int i = depth_ - 1; i >= 0; --i) { |
| 48 | path[i] = cur->index_; |
| 49 | cur = cur->parent_; |
| 50 | } |
| 51 | return path; |
| 52 | } |
| 53 | |
| 54 | protected: |
| 55 | FieldPosition(const FieldPosition* parent, int index) |
| 56 | : parent_(parent), index_(index), depth_(parent->depth_ + 1) {} |
| 57 | |
| 58 | const FieldPosition* parent_; |
| 59 | int index_; |
| 60 | int depth_; |
| 61 | }; |
| 62 | |
| 63 | } // namespace internal |
| 64 |
no outgoing calls
no test coverage detected