-
Notifications
You must be signed in to change notification settings - Fork 0
SDWAN-252 | authz version semver #1
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
Conversation
…ulong (ulong can be 32 bits in case it is not built with LP64. 2. add test to verify the max values of 64bits
… ulong (ulong can be 32 bits in case it is not built with LP64.
2. add test to verify the max values of 64bits
… ulong (ulong can be 32 bits in case it is not built with LP64.
2. add test to verify the max values of 64bits
| const std::string prerelease_allowed_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-"; | ||
| const std::string version_pattern = "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"; | ||
| const std::string loose_version_pattern = "^v?(0|[1-9]\\d*)(?:\\.(0|[1-9]\\d*))?(?:\\.(0|[1-9]\\d*))?(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"; | ||
| const std::string version_pattern = "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we change regex? Where are these new patterns coming from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the same regex, Oded just broke it into lines to make it easier to read the major.minor.patch parts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@logan is right, I just broke the regex into those parts as defined in standard.
include/semver/semver.hpp
Outdated
| patch = patch_m.matched ? std::stoul(patch_m) : 0; | ||
| major = (BuildIdentifierPart) parse_build_identifier_part(major_m); | ||
| minor = minor_m.matched ? (BuildIdentifierPart) parse_build_identifier_part(minor_m) : 0; | ||
| patch = patch_m.matched ? (BuildIdentifierPart) parse_build_identifier_part(patch_m) : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parse_buld_identifier_part() already returns BuildIdentifierPart so we don't need these type casts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, good catch... its a leftovers
include/semver/semver.hpp
Outdated
| namespace semver | ||
| { | ||
|
|
||
| typedef uint64_t BuildIdentifierPart; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: using is considered to be more in line with modern C++ than typedef. e.g. using BuildIdentifierPart = uint64_t;.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the idea was to allow users of this class to define the size of BuildIdentifierPart before the include (if someone wants a smaller size)
but for some reason I couldn't make it work...
I'll change it to using
include/semver/semver.hpp
Outdated
|
|
||
| inline BuildIdentifierPart parse_build_identifier_part(const std::string& version_part) | ||
| { | ||
| return (BuildIdentifierPart)std::stoull(version_part); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: static_cast<BuildIdentifierPart>(...) is also more like modern C++ ))
include/semver/semver.hpp
Outdated
| namespace semver | ||
| { | ||
|
|
||
| typedef uint64_t BuildIdentifierPart; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the idea was to allow users of this class to define the size of BuildIdentifierPart before the include (if someone wants a smaller size)
but for some reason I couldn't make it work...
I'll change it to using
| const std::string prerelease_allowed_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-"; | ||
| const std::string version_pattern = "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"; | ||
| const std::string loose_version_pattern = "^v?(0|[1-9]\\d*)(?:\\.(0|[1-9]\\d*))?(?:\\.(0|[1-9]\\d*))?(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"; | ||
| const std::string version_pattern = "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@logan is right, I just broke the regex into those parts as defined in standard.
| const std::string version_pattern = "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"; | ||
| const std::string loose_version_pattern = "^v?(0|[1-9]\\d*)(?:\\.(0|[1-9]\\d*))?(?:\\.(0|[1-9]\\d*))?(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"; | ||
| const std::string version_pattern = "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)" | ||
| "(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Twingate/sdwan,
maybe you can help me understand this regex and if it complies with RFC ABNF .
<pre-release identifier> ::= <alphanumeric identifier>
| <numeric identifier>
I would do something much easier on this one (?:-[a-zA-Z0-9\.]*), although I tried to modify it and it didn't go that easy for the tests!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually the regex it taken from RFC
include/semver/semver.hpp
Outdated
| patch = patch_m.matched ? std::stoul(patch_m) : 0; | ||
| major = (BuildIdentifierPart) parse_build_identifier_part(major_m); | ||
| minor = minor_m.matched ? (BuildIdentifierPart) parse_build_identifier_part(minor_m) : 0; | ||
| patch = patch_m.matched ? (BuildIdentifierPart) parse_build_identifier_part(patch_m) : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, good catch... its a leftovers
include/semver/semver.hpp
Outdated
| namespace semver | ||
| { | ||
|
|
||
| using BuildIdentifierPart = uint64_t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw., this code is using variable_name style, not VariableStyle, for naming variables, functions, and types. It's better to use the same style when modifying existing code so that code looks consistent.
No description provided.