Overload 'register_style' template instead of awkward multi-naming
Hopefully this is an improvement. :-)
This commit is contained in:
parent
d7677fca6f
commit
fe09e0dd6b
@ -151,7 +151,7 @@ class basic_print_stylizer
|
|||||||
|
|
||||||
// Predicate is conceptually 'bool (json)' here
|
// Predicate is conceptually 'bool (json)' here
|
||||||
template <typename Predicate>
|
template <typename Predicate>
|
||||||
auto register_style_object_pred(
|
auto register_style(
|
||||||
Predicate p,
|
Predicate p,
|
||||||
print_style style = print_style())
|
print_style style = print_style())
|
||||||
-> typename std::enable_if<details::takes_arguments<Predicate, BasicJsonType>::value, print_style&>::type
|
-> typename std::enable_if<details::takes_arguments<Predicate, BasicJsonType>::value, print_style&>::type
|
||||||
@ -172,7 +172,7 @@ class basic_print_stylizer
|
|||||||
// 'metawrapper<json_pointer>'. So if you pass 'bool (json)', it
|
// 'metawrapper<json_pointer>'. So if you pass 'bool (json)', it
|
||||||
// will look like it can pass a metawrapper<json_pointer> to it
|
// will look like it can pass a metawrapper<json_pointer> to it
|
||||||
template <typename Predicate>
|
template <typename Predicate>
|
||||||
auto register_style_context_pred(
|
auto register_style(
|
||||||
Predicate p,
|
Predicate p,
|
||||||
print_style style = print_style())
|
print_style style = print_style())
|
||||||
-> typename std::enable_if < !details::takes_arguments<Predicate, BasicJsonType>::value, print_style& >::type
|
-> typename std::enable_if < !details::takes_arguments<Predicate, BasicJsonType>::value, print_style& >::type
|
||||||
@ -189,7 +189,7 @@ class basic_print_stylizer
|
|||||||
string_t str,
|
string_t str,
|
||||||
print_style style = print_style())
|
print_style style = print_style())
|
||||||
{
|
{
|
||||||
return register_style_context_pred([str](const json_pointer_t& pointer)
|
return register_style([str](const json_pointer_t& pointer)
|
||||||
{
|
{
|
||||||
return (pointer.cbegin() != pointer.cend())
|
return (pointer.cbegin() != pointer.cend())
|
||||||
&& (*pointer.crbegin() == str);
|
&& (*pointer.crbegin() == str);
|
||||||
|
|||||||
@ -10956,7 +10956,7 @@ class basic_print_stylizer
|
|||||||
|
|
||||||
// Predicate is conceptually 'bool (json)' here
|
// Predicate is conceptually 'bool (json)' here
|
||||||
template <typename Predicate>
|
template <typename Predicate>
|
||||||
auto register_style_object_pred(
|
auto register_style(
|
||||||
Predicate p,
|
Predicate p,
|
||||||
print_style style = print_style())
|
print_style style = print_style())
|
||||||
-> typename std::enable_if<details::takes_arguments<Predicate, BasicJsonType>::value, print_style&>::type
|
-> typename std::enable_if<details::takes_arguments<Predicate, BasicJsonType>::value, print_style&>::type
|
||||||
@ -10977,7 +10977,7 @@ class basic_print_stylizer
|
|||||||
// 'metawrapper<json_pointer>'. So if you pass 'bool (json)', it
|
// 'metawrapper<json_pointer>'. So if you pass 'bool (json)', it
|
||||||
// will look like it can pass a metawrapper<json_pointer> to it
|
// will look like it can pass a metawrapper<json_pointer> to it
|
||||||
template <typename Predicate>
|
template <typename Predicate>
|
||||||
auto register_style_context_pred(
|
auto register_style(
|
||||||
Predicate p,
|
Predicate p,
|
||||||
print_style style = print_style())
|
print_style style = print_style())
|
||||||
-> typename std::enable_if < !details::takes_arguments<Predicate, BasicJsonType>::value, print_style& >::type
|
-> typename std::enable_if < !details::takes_arguments<Predicate, BasicJsonType>::value, print_style& >::type
|
||||||
@ -10994,7 +10994,7 @@ class basic_print_stylizer
|
|||||||
string_t str,
|
string_t str,
|
||||||
print_style style = print_style())
|
print_style style = print_style())
|
||||||
{
|
{
|
||||||
return register_style_context_pred([str](const json_pointer_t& pointer)
|
return register_style([str](const json_pointer_t& pointer)
|
||||||
{
|
{
|
||||||
return (pointer.cbegin() != pointer.cend())
|
return (pointer.cbegin() != pointer.cend())
|
||||||
&& (*pointer.crbegin() == str);
|
&& (*pointer.crbegin() == str);
|
||||||
|
|||||||
@ -286,7 +286,7 @@ TEST_CASE("serialization")
|
|||||||
print_stylizer stylizer;
|
print_stylizer stylizer;
|
||||||
stylizer.get_default_style() = print_style::preset_multiline;
|
stylizer.get_default_style() = print_style::preset_multiline;
|
||||||
|
|
||||||
stylizer.register_style_context_pred(
|
stylizer.register_style(
|
||||||
[] (const json_pointer<json>& context)
|
[] (const json_pointer<json>& context)
|
||||||
{
|
{
|
||||||
// Matches if context[-2] is "each elem on one line"
|
// Matches if context[-2] is "each elem on one line"
|
||||||
@ -332,7 +332,7 @@ TEST_CASE("serialization")
|
|||||||
print_stylizer stylizer;
|
print_stylizer stylizer;
|
||||||
stylizer.get_default_style() = print_style::preset_multiline;
|
stylizer.get_default_style() = print_style::preset_multiline;
|
||||||
|
|
||||||
stylizer.register_style_object_pred(
|
stylizer.register_style(
|
||||||
[] (const json & j)
|
[] (const json & j)
|
||||||
{
|
{
|
||||||
return j.type() == json::value_t::array;
|
return j.type() == json::value_t::array;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user