@@ -679,18 +679,19 @@ Settings_impl::Setter::set_option<Settings_impl::Session_option_impl::AUTH>(
679
679
}
680
680
681
681
682
- // Other options that need special handling .
682
+ // Connection attributes .
683
683
684
684
685
- // template<>
686
- // inline void
687
- // Settings_impl::Setter::set_option<Settings_impl::Session_option_impl::DNS_SRV>(
688
- // const bool &val
689
- // )
690
- // {
691
- // m_data.m_dns_srv = val;
692
- // add_option(Settings_impl::Session_option_impl::DNS_SRV, val);
693
- // }
685
+ template <>
686
+ inline void
687
+ Settings_impl::Setter::set_option<
688
+ Settings_impl::Session_option_impl::CONNECTION_ATTRIBUTES>(const bool & val)
689
+ {
690
+ if (val)
691
+ m_data.init_connection_attr ();
692
+ else
693
+ m_data.clear_connection_attr ();
694
+ }
694
695
695
696
696
697
template <>
@@ -700,9 +701,9 @@ Settings_impl::Session_option_impl::CONNECTION_ATTRIBUTES>(const std::string &va
700
701
{
701
702
702
703
struct processor
703
- : parser::JSON_parser::Processor
704
- , Any_prc
705
- , Scalar_prc
704
+ : parser::JSON_parser::Processor
705
+ , Any_prc
706
+ , Scalar_prc
706
707
{
707
708
Settings_impl::Data &m_data;
708
709
string m_key;
@@ -942,9 +943,6 @@ void Settings_impl::Setter::null()
942
943
case Session_option_impl::USER:
943
944
throw_error (" Option ... can not be unset" );
944
945
break ;
945
- case Session_option_impl::CONNECTION_ATTRIBUTES:
946
- m_data.clear_connection_attr ();
947
- break ;
948
946
case Session_option_impl::LAST:
949
947
break ;
950
948
default :
@@ -955,28 +953,45 @@ void Settings_impl::Setter::null()
955
953
956
954
957
955
inline
958
- void Settings_impl::Setter::yesno (bool b )
956
+ void Settings_impl::Setter::yesno (bool val )
959
957
{
958
+
959
+ #define SET_OPTION_BOOL_bool (X,N ) \
960
+ case Session_option_impl::X: return set_option<Session_option_impl::X, bool >(val);
961
+ #define SET_OPTION_BOOL_any (X,N ) break ;
962
+ #define SET_OPTION_BOOL_num (X,N ) SET_OPTION_BOOL_any(X,N)
963
+ #define SET_OPTION_BOOL_str (X,N ) SET_OPTION_BOOL_any(X,N)
964
+
965
+ #define SET_CLI_OPTION_BOOL_bool (X,N ) \
966
+ case Client_option_impl::X: return set_option<Client_option_impl::X, bool >(val);
967
+ #define SET_CLI_OPTION_BOOL_any (X,N ) SET_OPTION_BOOL_any(X,N)
968
+ #define SET_CLI_OPTION_BOOL_num (X,N ) SET_OPTION_BOOL_any(X,N)
969
+ #define SET_CLI_OPTION_BOOL_str (X,N ) SET_OPTION_BOOL_any(X,N)
970
+
960
971
switch (m_cur_opt)
961
972
{
962
- case Client_option_impl::POOLING:
963
- add_option (m_cur_opt, b);
964
- return ;
973
+ SESSION_OPTION_LIST (SET_OPTION_BOOL)
974
+ CLIENT_OPTION_LIST (SET_CLI_OPTION_BOOL)
975
+ default :
976
+ break ;
977
+ }
965
978
966
- case Session_option_impl::CONNECTION_ATTRIBUTES:
967
- if (b)
968
- m_data. init_connection_attr ();
969
- else
970
- m_data. clear_connection_attr ();
971
- return ;
972
- case Session_option_impl::DNS_SRV:
973
- add_option (m_cur_opt, b);
974
- return ;
975
- default : break ;
979
+ /*
980
+ Special handling of CONNECTION_ATTRIBUTES option which is declared
981
+ as string option, but it can be also set to a bool value.
982
+ */
983
+
984
+ switch (m_cur_opt)
985
+ {
986
+ SET_OPTION_BOOL_bool (CONNECTION_ATTRIBUTES, val)
987
+ default :
988
+ break ;
976
989
}
990
+
977
991
throw_error (" Option ... can not be bool" );
978
992
}
979
993
994
+
980
995
// URI processor
981
996
982
997
inline
0 commit comments