-
Notifications
You must be signed in to change notification settings - Fork 15
Introduce layer_path class #640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
beojan
wants to merge
8
commits into
Framework-R-D:main
Choose a base branch
from
beojan:identifier-layer-paths
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
663cb7c
Add layer_path and bulleted_list
beojan f26bb4c
Add layer path hashing
beojan 76a6bc0
identifiers need to support boost hashing
beojan f3077e3
Update data_cell_index to use layer_path, and follow on
beojan 70b3135
Replace starts_with / ends_with with mismatch
beojan 1ea55cd
Use bulleted_list everywhere
beojan 47c351e
Address Codex comments
beojan d6a7e9b
Test bulleted_list
beojan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| #include "layer_path.hpp" | ||
|
|
||
| #include "boost/container_hash/hash.hpp" | ||
| #include "fmt/format.h" | ||
| #include "fmt/ranges.h" | ||
|
|
||
| #include <algorithm> | ||
| #include <ranges> | ||
|
|
||
| using namespace std::literals; | ||
| using namespace phlex::experimental::literals; | ||
|
|
||
| namespace phlex::experimental { | ||
| layer_path::layer_path(std::string_view path) : | ||
| layer_path_{ | ||
| std::from_range, | ||
| path | std::views::split('/') | | ||
| std::views::filter([](auto const& sr) { return not sr.empty(); }) | | ||
| std::views::transform([](auto const& sr) { return identifier(std::string_view(sr)); })} | ||
| { | ||
| if (path.starts_with("/") and not path.starts_with("/job")) { | ||
|
beojan marked this conversation as resolved.
Outdated
|
||
| throw std::runtime_error( | ||
| fmt::format("A complete layer path must start with '/job'. '{}' does not!", path)); | ||
| } | ||
| } | ||
|
|
||
| bool layer_path::empty() const noexcept { return layer_path_.empty(); } | ||
|
|
||
| bool layer_path::complete() const noexcept { return not empty() and layer_path_[0] == "job"_idq; } | ||
|
|
||
| bool layer_path::is_strict_prefix_of(layer_path const& other) const noexcept | ||
| { | ||
| return std::ranges::starts_with(other.layer_path_, layer_path_); | ||
|
beojan marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| bool layer_path::ends_with(layer_path const& other) const noexcept | ||
| { | ||
| return std::ranges::ends_with(layer_path_, other.layer_path_); | ||
|
beojan marked this conversation as resolved.
Outdated
|
||
| } | ||
| bool layer_path::ends_with(identifier const& name) const noexcept | ||
| { | ||
| return not empty() and layer_path_.back() == name; | ||
| } | ||
|
|
||
| std::string layer_path::to_string() const | ||
| { | ||
| return fmt::format("{}{}", complete() ? "/" : "", fmt::join(layer_path_, "/")); | ||
| } | ||
| std::size_t layer_path::hash() const noexcept | ||
| { | ||
| if (empty()) { | ||
| return 0; | ||
| } | ||
| if (layer_path_.size() == 1) { | ||
| return layer_path_[0].hash(); | ||
| } | ||
| std::size_t seed = layer_path_[0].hash(); | ||
| boost::hash_range(seed, layer_path_.begin() + 1, layer_path_.end()); | ||
| return seed; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.