-
Notifications
You must be signed in to change notification settings - Fork 63
Add a c++ implementation for podio-dump
#620
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
33db353
Move sortAlphabetically to public header
tmadlener 88f3503
Implement podio-dump-tool in c++ and wrap it in thin script
tmadlener 937842c
Fix test env and paths for roundtrip tests
tmadlener 60f350b
Keep podio-dump.py in set of installed programs for now
tmadlener 6285b82
Fix minor differences in output
tmadlener 7419b9c
Use ranges where possible
tmadlener 102872f
Remove unnecessary flushing of stdout
tmadlener f17a264
Switch to println where possible
tmadlener 1ce9780
Rename legacy tool to podio-dump-legacy
tmadlener 1d84a82
Make more things done at compile time
tmadlener 8ee6923
Enable more tests for sanitizers
tmadlener a49720f
Fix pre-commit issues
tmadlener 36ff461
Simplify parse function
tmadlener 2d6a26b
Use ranges and views in some places
tmadlener 8b0419b
Disable some tests still for TSan and UBSan
tmadlener 03e3622
Range-ify more of the implementation
tmadlener c832bf0
Introduce alias namespace for better readability
tmadlener f0217c0
Improve error message
tmadlener 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #ifndef PODIO_UTILITIES_MISCHELPERS_H | ||
| #define PODIO_UTILITIES_MISCHELPERS_H | ||
|
|
||
| #include <algorithm> | ||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| namespace podio::utils { | ||
|
|
||
| /// Sort the input vector of strings alphabetically, case insensitive. | ||
| /// | ||
| /// @param strings The strings that should be sorted alphabetically | ||
| /// | ||
| /// @returns A vector of strings sorted alphabetically, case insensitive | ||
| inline std::vector<std::string> sortAlphabeticaly(std::vector<std::string> strings) { | ||
| // Obviously there is no tolower(std::string) in c++, so this is slightly more | ||
| // involved and we make use of the fact that lexicographical_compare works on | ||
| // ranges and the fact that we can feed it a dedicated comparison function, | ||
| // where we convert the strings to lower case char-by-char. The alternative is | ||
| // to make string copies inside the first lambda, transform them to lowercase | ||
| // and then use operator< of std::string, which would be effectively | ||
| // hand-writing what is happening below. | ||
| std::ranges::sort(strings, [](const auto& lhs, const auto& rhs) { | ||
| return std::lexicographical_compare( | ||
| lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), | ||
| [](const auto& cl, const auto& cr) { return std::tolower(cl) < std::tolower(cr); }); | ||
| }); | ||
| return strings; | ||
| } | ||
| } // namespace podio::utils | ||
|
|
||
| #endif // PODIO_UTILITIES_MISCHELPERS_H |
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,17 @@ | ||
| #!/usr/bin/env python3 | ||
| """Tiny script to ingest a json string and dump it as a yaml string""" | ||
|
|
||
| import sys | ||
| import json | ||
| import yaml | ||
|
|
||
|
|
||
| def main(): | ||
| """Main, read json from stdin and dump yaml to stdout""" | ||
| input_data = sys.stdin.read() | ||
| model_def = json.loads(input_data) | ||
| print(yaml.dump(model_def, sort_keys=False, default_flow_style=False)) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
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.