File indexing completed on 2025-09-16 08:29:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_CONFIG_HPP
0012 #define BOOST_ASIO_CONFIG_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019 #include <boost/asio/detail/throw_exception.hpp>
0020 #include <boost/asio/detail/type_traits.hpp>
0021 #include <boost/asio/execution_context.hpp>
0022 #include <cstddef>
0023 #include <string>
0024
0025 #include <boost/asio/detail/push_options.hpp>
0026
0027 namespace boost {
0028 namespace asio {
0029
0030
0031 class config_service :
0032 #if defined(GENERATING_DOCUMENTATION)
0033 public execution_context::service
0034 #else
0035 public detail::execution_context_service_base<config_service>
0036 #endif
0037 {
0038 public:
0039 #if defined(GENERATING_DOCUMENTATION)
0040 typedef config_service key_type;
0041 #endif
0042
0043
0044 BOOST_ASIO_DECL explicit config_service(execution_context& ctx);
0045
0046
0047 BOOST_ASIO_DECL void shutdown() override;
0048
0049
0050 BOOST_ASIO_DECL virtual const char* get_value(const char* section,
0051 const char* key, char* value, std::size_t value_len) const;
0052 };
0053
0054
0055
0056 class config
0057 {
0058 public:
0059
0060
0061
0062
0063
0064 explicit config(execution_context& context)
0065 : service_(use_service<config_service>(context))
0066 {
0067 }
0068
0069
0070 config(const config& other) noexcept
0071 : service_(other.service_)
0072 {
0073 }
0074
0075
0076 template <typename T>
0077 constraint_t<is_integral<T>::value, T>
0078 get(const char* section, const char* key, T default_value) const;
0079
0080 private:
0081 config_service& service_;
0082 };
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093 class config_from_concurrency_hint : public execution_context::service_maker
0094 {
0095 public:
0096
0097 BOOST_ASIO_DECL config_from_concurrency_hint();
0098
0099
0100 explicit config_from_concurrency_hint(int concurrency_hint)
0101 : concurrency_hint_(concurrency_hint)
0102 {
0103 }
0104
0105
0106 BOOST_ASIO_DECL void make(execution_context& ctx) const override;
0107
0108 private:
0109 int concurrency_hint_;
0110 };
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131 class config_from_string : public execution_context::service_maker
0132 {
0133 public:
0134
0135 explicit config_from_string(std::string s)
0136 : string_(static_cast<std::string&&>(s)),
0137 prefix_()
0138 {
0139 }
0140
0141
0142 config_from_string(std::string s, std::string prefix)
0143 : string_(static_cast<std::string&&>(s)),
0144 prefix_(static_cast<std::string&&>(prefix))
0145 {
0146 }
0147
0148
0149 BOOST_ASIO_DECL void make(execution_context& ctx) const override;
0150
0151 private:
0152 std::string string_;
0153 std::string prefix_;
0154 };
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166 class config_from_env : public execution_context::service_maker
0167 {
0168 public:
0169
0170 BOOST_ASIO_DECL config_from_env();
0171
0172
0173 explicit config_from_env(std::string prefix)
0174 : prefix_(static_cast<std::string&&>(prefix))
0175 {
0176 }
0177
0178
0179 BOOST_ASIO_DECL void make(execution_context& ctx) const override;
0180
0181 private:
0182 std::string prefix_;
0183 };
0184
0185 }
0186 }
0187
0188 #include <boost/asio/detail/pop_options.hpp>
0189
0190 #include <boost/asio/impl/config.hpp>
0191 #if defined(BOOST_ASIO_HEADER_ONLY)
0192 # include <boost/asio/impl/config.ipp>
0193 #endif
0194
0195 #endif