| 68 | } |
| 69 | |
| 70 | std::shared_ptr<ColumnPath> ColumnPath::FromNode(const Node& node) { |
| 71 | // Build the path in reverse order as we traverse the nodes to the top |
| 72 | std::vector<std::string> rpath_; |
| 73 | const Node* cursor = &node; |
| 74 | // The schema node is not part of the ColumnPath |
| 75 | while (cursor->parent()) { |
| 76 | rpath_.push_back(cursor->name()); |
| 77 | cursor = cursor->parent(); |
| 78 | } |
| 79 | |
| 80 | // Build ColumnPath in correct order |
| 81 | std::vector<std::string> path(rpath_.crbegin(), rpath_.crend()); |
| 82 | return std::make_shared<ColumnPath>(std::move(path)); |
| 83 | } |
| 84 | |
| 85 | std::shared_ptr<ColumnPath> ColumnPath::extend(const std::string& node_name) const { |
| 86 | std::vector<std::string> path; |