Skip to content

Commit

Permalink
GETTER_CTOR -> CTOR_GETTER
Browse files Browse the repository at this point in the history
  • Loading branch information
danielaparker committed Mar 24, 2020
1 parent 889d2d1 commit e71b22c
Show file tree
Hide file tree
Showing 14 changed files with 109 additions and 98 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@ namespace ns {

JSONCONS_ENUM_TRAITS(ns::hiking_experience, beginner, intermediate, advanced)
// First four members listed are mandatory, confidence and expires are optional
JSONCONS_N_GETTER_CTOR_TRAITS(ns::hiking_reputon, 4, rater, assertion, rated, rating,
JSONCONS_N_CTOR_GETTER_TRAITS(ns::hiking_reputon, 4, rater, assertion, rated, rating,
confidence, expires)
// All members are mandatory
JSONCONS_ALL_GETTER_CTOR_TRAITS(ns::hiking_reputation, application, reputons)
JSONCONS_ALL_CTOR_GETTER_TRAITS(ns::hiking_reputation, application, reputons)

int main()
{
Expand Down Expand Up @@ -282,13 +282,13 @@ Marilyn C, 0.9
}
```
This example makes use of the convenience macros `JSONCONS_ENUM_TRAITS`
`JSONCONS_N_GETTER_CTOR_TRAITS`, and `JSONCONS_ALL_GETTER_CTOR_TRAITS` to specialize the
`JSONCONS_N_CTOR_GETTER_TRAITS`, and `JSONCONS_ALL_CTOR_GETTER_TRAITS` to specialize the
[json_type_traits](doc/ref/json_type_traits.md) for the enum type
`ns::hiking_experience`, the class `ns::hiking_reputon` (with some non-mandatory members), and the class
`ns::hiking_reputation` (with all mandatory members.)
The macro `JSONCONS_ENUM_TRAITS` generates the code from
the enum identifiers, and the macros `JSONCONS_N_GETTER_CTOR_TRAITS`
and `JSONCONS_ALL_GETTER_CTOR_TRAITS`
the enum identifiers, and the macros `JSONCONS_N_CTOR_GETTER_TRAITS`
and `JSONCONS_ALL_CTOR_GETTER_TRAITS`
generate the code from the get functions and a constructor.
These macro declarations must be placed outside any namespace blocks.
Expand Down
22 changes: 11 additions & 11 deletions doc/Examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
[Serialize non-mandatory std::optional values using the convenience macros](#G4)
[An example with std::shared_ptr and std::unique_ptr](#G5)
[Serialize a templated class with the `_TPL_` macros](#G6)
[An example using JSONCONS_ENUM_TRAITS and JSONCONS_ALL_GETTER_CTOR_TRAITS](#G7)
[An example using JSONCONS_ENUM_TRAITS and JSONCONS_ALL_CTOR_GETTER_TRAITS](#G7)
[Serialize a polymorphic type based on the presence of members](#G8)
[Ensuring type selection is possible](#G9)
[Specialize json_type_traits explicitly](#G10)
Expand Down Expand Up @@ -572,7 +572,7 @@ JSONCONS_ENUM_TRAITS(ns::BookCategory,fiction,biography)
JSONCONS_ALL_MEMBER_TRAITS(ns::Book1,category,author,title,price)
JSONCONS_ALL_MEMBER_TRAITS(ns::Book2,category,author,title,price)
JSONCONS_ALL_GETTER_CTOR_TRAITS(ns::Book3,category,author,title,price)
JSONCONS_ALL_CTOR_GETTER_TRAITS(ns::Book3,category,author,title,price)
using namespace jsoncons; // for convenience
Expand Down Expand Up @@ -778,7 +778,7 @@ JSONCONS_ALL_MEMBER_NAME_TRAITS(ns::Book1,(category,"Category"),(author,"Author"
(title,"Title"),(price,"Price"))
JSONCONS_ALL_MEMBER_NAME_TRAITS(ns::Book2,(category_,"Category"),(author_,"Author"),
(title_,"Title"),(price_,"Price"))
JSONCONS_ALL_GETTER_CTOR_NAME_TRAITS(ns::Book3,(category,"Category"),(author,"Author"),
JSONCONS_ALL_CTOR_GETTER_NAME_TRAITS(ns::Book3,(category,"Category"),(author,"Author"),
(title,"Title"),(price,"Price"))
JSONCONS_ALL_GETTER_SETTER_NAME_TRAITS(ns::Book4,(getCategory,setCategory,"Category"),
(getAuthor,setAuthor,"Author"),
Expand Down Expand Up @@ -1208,15 +1208,15 @@ int main()
<div id="G7"/>
#### An example using JSONCONS_ENUM_TRAITS and JSONCONS_ALL_GETTER_CTOR_TRAITS
#### An example using JSONCONS_ENUM_TRAITS and JSONCONS_ALL_CTOR_GETTER_TRAITS
This example makes use of the convenience macros `JSONCONS_ENUM_TRAITS`
and `JSONCONS_ALL_GETTER_CTOR_TRAITS` to specialize the
and `JSONCONS_ALL_CTOR_GETTER_TRAITS` to specialize the
[json_type_traits](ref/json_type_traits.md) for the enum type
`ns::hiking_experience` and the classes `ns::hiking_reputon` and
`ns::hiking_reputation`.
The macro `JSONCONS_ENUM_TRAITS` generates the code from
the enum values, and the macro `JSONCONS_ALL_GETTER_CTOR_TRAITS`
the enum values, and the macro `JSONCONS_ALL_CTOR_GETTER_TRAITS`
generates the code from the get functions and a constructor.
These macro declarations must be placed outside any namespace blocks.
Expand Down Expand Up @@ -1289,8 +1289,8 @@ namespace ns {
// Declare the traits. Specify which data members need to be serialized.
JSONCONS_ENUM_TRAITS(ns::hiking_experience, beginner, intermediate, advanced)
JSONCONS_ALL_GETTER_CTOR_TRAITS(ns::hiking_reputon, rater, assertion, rated, rating)
JSONCONS_ALL_GETTER_CTOR_TRAITS(ns::hiking_reputation, application, reputons)
JSONCONS_ALL_CTOR_GETTER_TRAITS(ns::hiking_reputon, rater, assertion, rated, rating)
JSONCONS_ALL_CTOR_GETTER_TRAITS(ns::hiking_reputation, application, reputons)
using namespace jsoncons; // for convenience
Expand Down Expand Up @@ -1326,7 +1326,7 @@ Output:

#### Serialize a polymorphic type based on the presence of members

This example uses the convenience macro `JSONCONS_N_GETTER_CTOR_TRAITS`
This example uses the convenience macro `JSONCONS_N_CTOR_GETTER_TRAITS`
to generate the [json_type_traits](ref/json_type_traits.md) boilerplate for the `HourlyEmployee` and `CommissionedEmployee`
derived classes, and `JSONCONS_POLYMORPHIC_TRAITS` to generate the `json_type_traits` boilerplate
for `std::shared_ptr<Employee>` and `std::unique_ptr<Employee>`. The type selection strategy is based
Expand Down Expand Up @@ -1427,8 +1427,8 @@ public:

} // ns

JSONCONS_N_GETTER_CTOR_TRAITS(ns::HourlyEmployee, 3, firstName, lastName, wage, hours)
JSONCONS_N_GETTER_CTOR_TRAITS(ns::CommissionedEmployee, 4, firstName, lastName, baseSalary, commission, sales)
JSONCONS_N_CTOR_GETTER_TRAITS(ns::HourlyEmployee, 3, firstName, lastName, wage, hours)
JSONCONS_N_CTOR_GETTER_TRAITS(ns::CommissionedEmployee, 4, firstName, lastName, baseSalary, commission, sales)
JSONCONS_POLYMORPHIC_TRAITS(ns::Employee, ns::HourlyEmployee, ns::CommissionedEmployee)

int main()
Expand Down
8 changes: 4 additions & 4 deletions doc/Pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ namespace ns {

JSONCONS_ENUM_TRAITS(ns::hiking_experience, beginner, intermediate, advanced)
// First four members listed are mandatory, confidence and expires are optional
JSONCONS_N_GETTER_CTOR_TRAITS(ns::hiking_reputon, 4, rater, assertion, rated, rating,
JSONCONS_N_CTOR_GETTER_TRAITS(ns::hiking_reputon, 4, rater, assertion, rated, rating,
confidence, expires)
// All members are mandatory
JSONCONS_ALL_GETTER_CTOR_TRAITS(ns::hiking_reputation, application, reputons)
JSONCONS_ALL_CTOR_GETTER_TRAITS(ns::hiking_reputation, application, reputons)

int main()
{
Expand Down Expand Up @@ -243,12 +243,12 @@ Marilyn C, 0.9
}
```
This example makes use of the convenience macros `JSONCONS_ENUM_TRAITS`
and `JSONCONS_ALL_GETTER_CTOR_TRAITS` to specialize the
and `JSONCONS_ALL_CTOR_GETTER_TRAITS` to specialize the
[json_type_traits](doc/ref/json_type_traits.md) for the enum type
`ns::hiking_experience` and the classes `ns::hiking_reputon` and
`ns::hiking_reputation`.
The macro `JSONCONS_ENUM_TRAITS` generates the code from
the enum values, and the macro `JSONCONS_ALL_GETTER_CTOR_TRAITS`
the enum values, and the macro `JSONCONS_ALL_CTOR_GETTER_TRAITS`
generates the code from the get functions and a constructor.
These macro declarations must be placed outside any namespace blocks.
Expand Down
2 changes: 1 addition & 1 deletion doc/ref/csv/csv.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ struct json_type_traits<Json,boost::gregorian::date>
}
};

JSONCONS_ALL_GETTER_CTOR_TRAITS(ns::fixing, index_id, observation_date, rate)
JSONCONS_ALL_CTOR_GETTER_TRAITS(ns::fixing, index_id, observation_date, rate)

int main()
{
Expand Down
32 changes: 16 additions & 16 deletions doc/ref/json_type_traits.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,35 +126,35 @@ JSONCONS_ENUM_NAME_TRAITS(enum_name,
(identifier0,serialized_name0),
(identifier1,serialized_name1)...) // (10)
JSONCONS_N_GETTER_CTOR_TRAITS(class_name,num_mandatory,
JSONCONS_N_CTOR_GETTER_TRAITS(class_name,num_mandatory,
getter_name0,
getter_name1,...) // (11)
JSONCONS_ALL_GETTER_CTOR_TRAITS(class_name,
JSONCONS_ALL_CTOR_GETTER_TRAITS(class_name,
getter_name0,getter_name1,...) // (12)
JSONCONS_TPL_N_GETTER_CTOR_TRAITS(num_template_params,
JSONCONS_TPL_N_CTOR_GETTER_TRAITS(num_template_params,
class_name,num_mandatory,
getter_name0,getter_name1,...) // (13)
JSONCONS_TPL_ALL_GETTER_CTOR_TRAITS(num_template_params,
JSONCONS_TPL_ALL_CTOR_GETTER_TRAITS(num_template_params,
class_name,
getter_name0,getter_name1,...) // (14)
JSONCONS_N_GETTER_CTOR_NAME_TRAITS(class_name,num_mandatory,
JSONCONS_N_CTOR_GETTER_NAME_TRAITS(class_name,num_mandatory,
(getter_name0,serialized_name0),
(getter_name1,serialized_name1)...) // (15)
JSONCONS_ALL_GETTER_CTOR_NAME_TRAITS(class_name,
JSONCONS_ALL_CTOR_GETTER_NAME_TRAITS(class_name,
(getter_name0,serialized_name0),
(getter_name1,serialized_name1)...) // (16)
JSONCONS_TPL_N_GETTER_CTOR_NAME_TRAITS(num_template_params,
JSONCONS_TPL_N_CTOR_GETTER_NAME_TRAITS(num_template_params,
class_name,num_mandatory,
(getter_name0,serialized_name0),
(getter_name1,serialized_name1)...) // (17)
JSONCONS_TPL_ALL_GETTER_CTOR_NAME_TRAITS(num_template_params,
JSONCONS_TPL_ALL_CTOR_GETTER_NAME_TRAITS(num_template_params,
class_name,
(getter_name0,serialized_name0),
(getter_name1,serialized_name1)...) // (18)
Expand Down Expand Up @@ -310,7 +310,7 @@ All of the `json_type_traits` specializations for type `T` generated by the conv
[Convert from and to std::tuple](#A4)
[Extend json_type_traits to support `boost::gregorian` dates.](#A5)
[Specialize json_type_traits to support a book class.](#A6)
[Using JSONCONS_ALL_GETTER_CTOR_TRAITS to generate the json_type_traits](#A7)
[Using JSONCONS_ALL_CTOR_GETTER_TRAITS to generate the json_type_traits](#A7)
[Example with std::shared_ptr, std::unique_ptr and std::optional](#A8)
[Serialize a polymorphic type based on the presence of members](#A9)
[Ensuring type selection is possible](#A10)
Expand Down Expand Up @@ -599,9 +599,9 @@ Charles Bukowski, Pulp, 22.48

<div id="A7"/>

#### Using JSONCONS_ALL_GETTER_CTOR_TRAITS to generate the json_type_traits
#### Using JSONCONS_ALL_CTOR_GETTER_TRAITS to generate the json_type_traits

`JSONCONS_ALL_GETTER_CTOR_TRAITS` is a macro that can be used to generate the `json_type_traits` boilerplate
`JSONCONS_ALL_CTOR_GETTER_TRAITS` is a macro that can be used to generate the `json_type_traits` boilerplate
for your own types.

```c++
Expand Down Expand Up @@ -675,8 +675,8 @@ using namespace jsoncons; // for convenience

// Declare the traits. Specify which data members need to be serialized.
JSONCONS_ENUM_TRAITS(ns::hiking_experience, beginner, intermediate, advanced)
JSONCONS_ALL_GETTER_CTOR_TRAITS(ns::hiking_reputon, rater, assertion, rated, rating)
JSONCONS_ALL_GETTER_CTOR_TRAITS(ns::hiking_reputation, application, reputons)
JSONCONS_ALL_CTOR_GETTER_TRAITS(ns::hiking_reputon, rater, assertion, rated, rating)
JSONCONS_ALL_CTOR_GETTER_TRAITS(ns::hiking_reputation, application, reputons)

int main()
{
Expand Down Expand Up @@ -799,7 +799,7 @@ Output:

#### Serialize a polymorphic type based on the presence of members

This example uses the convenience macro `JSONCONS_N_GETTER_CTOR_TRAITS`
This example uses the convenience macro `JSONCONS_N_CTOR_GETTER_TRAITS`
to generate the `json_type_traits` boilerplate for the `HourlyEmployee` and `CommissionedEmployee`
derived classes, and `JSONCONS_POLYMORPHIC_TRAITS` to generate the `json_type_traits` boilerplate
for `std::shared_ptr<Employee>` and `std::unique_ptr<Employee>`. The type selection strategy is based
Expand Down Expand Up @@ -900,8 +900,8 @@ public:

} // ns

JSONCONS_N_GETTER_CTOR_TRAITS(ns::HourlyEmployee, 3, firstName, lastName, wage, hours)
JSONCONS_N_GETTER_CTOR_TRAITS(ns::CommissionedEmployee, 4, firstName, lastName, baseSalary, commission, sales)
JSONCONS_N_CTOR_GETTER_TRAITS(ns::HourlyEmployee, 3, firstName, lastName, wage, hours)
JSONCONS_N_CTOR_GETTER_TRAITS(ns::CommissionedEmployee, 4, firstName, lastName, baseSalary, commission, sales)
JSONCONS_POLYMORPHIC_TRAITS(ns::Employee, ns::HourlyEmployee, ns::CommissionedEmployee)

int main()
Expand Down
4 changes: 2 additions & 2 deletions doc/ref/ubjson/ubjson.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ namespace ns {

// Declare the traits. Specify which data members need to be serialized.
JSONCONS_ENUM_TRAITS(ns::hiking_experience, beginner, intermediate, advanced)
JSONCONS_ALL_GETTER_CTOR_TRAITS(ns::hiking_reputon, rater, assertion, rated, rating)
JSONCONS_ALL_GETTER_CTOR_TRAITS(ns::hiking_reputation, application, reputons)
JSONCONS_ALL_CTOR_GETTER_TRAITS(ns::hiking_reputon, rater, assertion, rated, rating)
JSONCONS_ALL_CTOR_GETTER_TRAITS(ns::hiking_reputation, application, reputons)

int main()
{
Expand Down
6 changes: 3 additions & 3 deletions examples/src/json_traits_macros_examples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ JSONCONS_ENUM_TRAITS(ns::BookCategory,fiction,biography)

JSONCONS_ALL_MEMBER_TRAITS(ns::Book1,category,author,title,price)
JSONCONS_ALL_MEMBER_TRAITS(ns::Book2,category,author,title,price)
JSONCONS_ALL_GETTER_CTOR_TRAITS(ns::Book3,category,author,title,price)
JSONCONS_ALL_CTOR_GETTER_TRAITS(ns::Book3,category,author,title,price)

JSONCONS_N_GETTER_CTOR_TRAITS(ns::HourlyEmployee, 3, firstName, lastName, wage, hours)
JSONCONS_N_GETTER_CTOR_TRAITS(ns::CommissionedEmployee, 4, firstName, lastName, baseSalary, commission, sales)
JSONCONS_N_CTOR_GETTER_TRAITS(ns::HourlyEmployee, 3, firstName, lastName, wage, hours)
JSONCONS_N_CTOR_GETTER_TRAITS(ns::CommissionedEmployee, 4, firstName, lastName, baseSalary, commission, sales)
JSONCONS_POLYMORPHIC_TRAITS(ns::Employee, ns::HourlyEmployee, ns::CommissionedEmployee)

JSONCONS_N_MEMBER_TRAITS(ns::Bar,1,bar)
Expand Down
2 changes: 1 addition & 1 deletion examples/src/json_traits_macros_named_examples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ JSONCONS_ALL_MEMBER_NAME_TRAITS(ns::Book1,(category,"Category"),(author,"Author"
(title,"Title"),(price,"Price"))
JSONCONS_ALL_MEMBER_NAME_TRAITS(ns::Book2,(category_,"Category"),(author_,"Author"),
(title_,"Title"),(price_,"Price"))
JSONCONS_ALL_GETTER_CTOR_NAME_TRAITS(ns::Book3,(category,"Category"),(author,"Author"),
JSONCONS_ALL_CTOR_GETTER_NAME_TRAITS(ns::Book3,(category,"Category"),(author,"Author"),
(title,"Title"),(price,"Price"))
JSONCONS_ALL_GETTER_SETTER_NAME_TRAITS(ns::Book4,(getCategory,setCategory,"Category"),
(getAuthor,setAuthor,"Author"),
Expand Down
6 changes: 3 additions & 3 deletions examples/src/sample_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@ JSONCONS_ALL_MEMBER_NAME_TRAITS(ns::bond, (principal,"notional"), (maturity,"mat

JSONCONS_ENUM_TRAITS(ns::hiking_experience, beginner, intermediate, advanced)
// First four members listed are mandatory, confidence and expires are optional
JSONCONS_N_GETTER_CTOR_TRAITS(ns::hiking_reputon, 4, rater, assertion, rated, rating,
JSONCONS_N_CTOR_GETTER_TRAITS(ns::hiking_reputon, 4, rater, assertion, rated, rating,
confidence, expires)
// All members are mandatory
JSONCONS_ALL_GETTER_CTOR_TRAITS(ns::hiking_reputation, application, reputons)
JSONCONS_ALL_CTOR_GETTER_TRAITS(ns::hiking_reputation, application, reputons)

JSONCONS_ALL_GETTER_CTOR_TRAITS(ns::fixing, index_id, observation_date, rate)
JSONCONS_ALL_CTOR_GETTER_TRAITS(ns::fixing, index_id, observation_date, rate)
JSONCONS_ALL_MEMBER_TRAITS(ns::employee, employeeNo, name, title)

// Declare the traits. Specify which data members need to be serialized.
Expand Down
2 changes: 1 addition & 1 deletion examples_boost/more_examples/src/extensibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ namespace ns {
};
} namespace ns

JSONCONS_ALL_GETTER_CTOR_TRAITS(ns::fixing, index_id, observation_date, rate)
JSONCONS_ALL_CTOR_GETTER_TRAITS(ns::fixing, index_id, observation_date, rate)

using namespace jsoncons;
using boost::numeric::ublas::matrix;
Expand Down
Loading

0 comments on commit e71b22c

Please sign in to comment.