From 3487ca8a1ec93a8e1c7f9e5f7f38933443f56f48 Mon Sep 17 00:00:00 2001 From: Tony Gorez Date: Tue, 3 Sep 2024 17:38:30 +0200 Subject: [PATCH 1/6] refactor: introduce PropertyT Signed-off-by: Tony Gorez --- .../sourcemeta/jsontoolkit/jsonpointer_pointer.h | 2 +- .../sourcemeta/jsontoolkit/jsonpointer_token.h | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_pointer.h b/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_pointer.h index 703bcd924..30ed505ec 100644 --- a/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_pointer.h +++ b/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_pointer.h @@ -19,7 +19,7 @@ template typename Allocator> class GenericPointer { public: - using Token = GenericToken; + using Token = GenericToken; using Value = typename Token::Value; using Container = std::vector; diff --git a/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_token.h b/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_token.h index 775feb98e..3d7f0d627 100644 --- a/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_token.h +++ b/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_token.h @@ -11,11 +11,12 @@ namespace sourcemeta::jsontoolkit { /// @ingroup jsonpointer template typename Allocator> + template typename Allocator, typename PropertyT> class GenericToken { public: using Value = JSON; - using Property = typename Value::String; + static_assert(std::is_same_v); + using Property = PropertyT; using Index = typename Value::Array::size_type; /// This constructor creates an JSON Pointer token from a string. For @@ -208,14 +209,14 @@ class GenericToken { } /// Compare JSON Pointer tokens - auto operator==(const GenericToken &other) - const noexcept -> bool { + auto operator==(const GenericToken + &other) const noexcept -> bool { return this->data == other.data; } /// Overload to support ordering of JSON Pointer token. Typically for sorting /// reasons. - auto operator<(const GenericToken &other) + auto operator<(const GenericToken &other) const noexcept -> bool { return this->data < other.data; } From 97679b3669e64bd3fe3c8d48455f9b31347501ef Mon Sep 17 00:00:00 2001 From: Tony Gorez Date: Tue, 3 Sep 2024 17:41:12 +0200 Subject: [PATCH 2/6] refactor: delete allocator on token Signed-off-by: Tony Gorez --- .../include/sourcemeta/jsontoolkit/jsonpointer_pointer.h | 2 +- .../include/sourcemeta/jsontoolkit/jsonpointer_token.h | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_pointer.h b/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_pointer.h index 30ed505ec..ef42582f1 100644 --- a/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_pointer.h +++ b/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_pointer.h @@ -19,7 +19,7 @@ template typename Allocator> class GenericPointer { public: - using Token = GenericToken; + using Token = GenericToken; using Value = typename Token::Value; using Container = std::vector; diff --git a/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_token.h b/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_token.h index 3d7f0d627..c69598776 100644 --- a/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_token.h +++ b/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_token.h @@ -10,8 +10,7 @@ namespace sourcemeta::jsontoolkit { /// @ingroup jsonpointer -template typename Allocator, typename PropertyT> +template class GenericToken { public: using Value = JSON; @@ -209,14 +208,14 @@ class GenericToken { } /// Compare JSON Pointer tokens - auto operator==(const GenericToken - &other) const noexcept -> bool { + auto operator==(const GenericToken &other) + const noexcept -> bool { return this->data == other.data; } /// Overload to support ordering of JSON Pointer token. Typically for sorting /// reasons. - auto operator<(const GenericToken &other) + auto operator<(const GenericToken &other) const noexcept -> bool { return this->data < other.data; } From 447f481c0334bf205fe16775c56058a607012afc Mon Sep 17 00:00:00 2001 From: Tony Gorez Date: Tue, 3 Sep 2024 17:43:15 +0200 Subject: [PATCH 3/6] refactor: remove trait from token Signed-off-by: Tony Gorez --- .../sourcemeta/jsontoolkit/jsonpointer_pointer.h | 2 +- .../sourcemeta/jsontoolkit/jsonpointer_token.h | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_pointer.h b/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_pointer.h index ef42582f1..1dd78beb5 100644 --- a/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_pointer.h +++ b/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_pointer.h @@ -19,7 +19,7 @@ template typename Allocator> class GenericPointer { public: - using Token = GenericToken; + using Token = GenericToken; using Value = typename Token::Value; using Container = std::vector; diff --git a/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_token.h b/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_token.h index c69598776..c7846c265 100644 --- a/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_token.h +++ b/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_token.h @@ -10,8 +10,7 @@ namespace sourcemeta::jsontoolkit { /// @ingroup jsonpointer -template -class GenericToken { +template class GenericToken { public: using Value = JSON; static_assert(std::is_same_v); @@ -208,15 +207,15 @@ class GenericToken { } /// Compare JSON Pointer tokens - auto operator==(const GenericToken &other) - const noexcept -> bool { + auto operator==(const GenericToken &other) const noexcept + -> bool { return this->data == other.data; } /// Overload to support ordering of JSON Pointer token. Typically for sorting /// reasons. - auto operator<(const GenericToken &other) - const noexcept -> bool { + auto operator<(const GenericToken &other) const noexcept + -> bool { return this->data < other.data; } From 514fd36551c24420dfd9eb797b1f31772bbcbad2 Mon Sep 17 00:00:00 2001 From: Tony Gorez Date: Tue, 3 Sep 2024 17:46:51 +0200 Subject: [PATCH 4/6] refactor: get rid of chart in constructor Signed-off-by: Tony Gorez --- .../include/sourcemeta/jsontoolkit/jsonpointer_token.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_token.h b/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_token.h index c7846c265..0c8cc16c2 100644 --- a/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_token.h +++ b/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_token.h @@ -38,7 +38,7 @@ template class GenericToken { /// /// const sourcemeta::jsontoolkit::Pointer::Token token{"foo"}; /// ``` - GenericToken(const CharT *const property) + GenericToken(const Property::value_type *const property) : data{std::in_place_type, property} {} /// This constructor creates an JSON Pointer token from a character. For @@ -50,7 +50,7 @@ template class GenericToken { /// /// const sourcemeta::jsontoolkit::Pointer::Token token{'a'}; /// ``` - GenericToken(const CharT character) + GenericToken(const Property::value_type character) : data{std::in_place_type, Property{character}} {} /// This constructor creates an JSON Pointer token from an item index. For From 88621f38797d22f6d60ccd473e17ae873142dc61 Mon Sep 17 00:00:00 2001 From: Tony Gorez Date: Tue, 3 Sep 2024 17:50:28 +0200 Subject: [PATCH 5/6] refactor: get rid of char param Signed-off-by: Tony Gorez --- .../include/sourcemeta/jsontoolkit/jsonpointer_pointer.h | 2 +- .../include/sourcemeta/jsontoolkit/jsonpointer_token.h | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_pointer.h b/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_pointer.h index 1dd78beb5..65858fb0c 100644 --- a/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_pointer.h +++ b/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_pointer.h @@ -19,7 +19,7 @@ template typename Allocator> class GenericPointer { public: - using Token = GenericToken; + using Token = GenericToken; using Value = typename Token::Value; using Container = std::vector; diff --git a/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_token.h b/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_token.h index 0c8cc16c2..98380d3db 100644 --- a/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_token.h +++ b/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_token.h @@ -10,10 +10,9 @@ namespace sourcemeta::jsontoolkit { /// @ingroup jsonpointer -template class GenericToken { +template class GenericToken { public: using Value = JSON; - static_assert(std::is_same_v); using Property = PropertyT; using Index = typename Value::Array::size_type; @@ -207,15 +206,13 @@ template class GenericToken { } /// Compare JSON Pointer tokens - auto operator==(const GenericToken &other) const noexcept - -> bool { + auto operator==(const GenericToken &other) const noexcept -> bool { return this->data == other.data; } /// Overload to support ordering of JSON Pointer token. Typically for sorting /// reasons. - auto operator<(const GenericToken &other) const noexcept - -> bool { + auto operator<(const GenericToken &other) const noexcept -> bool { return this->data < other.data; } From ce5fc991264097a61a9bec0ae84e63eca8c233ba Mon Sep 17 00:00:00 2001 From: Tony Gorez Date: Tue, 3 Sep 2024 17:53:32 +0200 Subject: [PATCH 6/6] fix: add typename prefix Signed-off-by: Tony Gorez --- .../include/sourcemeta/jsontoolkit/jsonpointer_token.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_token.h b/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_token.h index 98380d3db..08eae8161 100644 --- a/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_token.h +++ b/src/jsonpointer/include/sourcemeta/jsontoolkit/jsonpointer_token.h @@ -37,7 +37,7 @@ template class GenericToken { /// /// const sourcemeta::jsontoolkit::Pointer::Token token{"foo"}; /// ``` - GenericToken(const Property::value_type *const property) + GenericToken(const typename Property::value_type *const property) : data{std::in_place_type, property} {} /// This constructor creates an JSON Pointer token from a character. For @@ -49,7 +49,7 @@ template class GenericToken { /// /// const sourcemeta::jsontoolkit::Pointer::Token token{'a'}; /// ``` - GenericToken(const Property::value_type character) + GenericToken(const typename Property::value_type character) : data{std::in_place_type, Property{character}} {} /// This constructor creates an JSON Pointer token from an item index. For