22#define STATSD_CLIENT_HPP
33
44#include < cstdlib>
5- #include < experimental/ optional>
5+ #include < optional>
66#include < string>
77#include " UDPSender.hpp"
88
@@ -25,39 +25,39 @@ class StatsdClient {
2525 // !@{
2626
2727 // ! Constructor
28- StatsdClient (const std::string & host,
28+ StatsdClient (const std::string& host,
2929 const uint16_t port,
30- const std::string & prefix,
31- const std::experimental:: optional<uint64_t > batchsize = std::experimental ::nullopt ) noexcept ;
30+ const std::string& prefix,
31+ const std::optional<uint64_t > batchsize = std::nullopt ) noexcept ;
3232
3333 // !@}
3434
3535 // !@name Methods
3636 // !@{
3737
3838 // ! Sets a configuration { host, port, prefix }
39- inline void setConfig (const std::string & host, const uint16_t port, const std::string & prefix) noexcept ;
39+ inline void setConfig (const std::string& host, const uint16_t port, const std::string& prefix) noexcept ;
4040
4141 // ! Returns the error message as an optional std::string
42- inline std::experimental:: optional<std::string> errorMessage () const noexcept ;
42+ inline std::optional<std::string> errorMessage () const noexcept ;
4343
4444 // ! Increments the key, at a given frequency rate
45- inline void increment (const std::string & key, const float frequency = 1 .0f ) const noexcept ;
45+ inline void increment (const std::string& key, const float frequency = 1 .0f ) const noexcept ;
4646
4747 // ! Increments the key, at a given frequency rate
48- inline void decrement (const std::string & key, const float frequency = 1 .0f ) const noexcept ;
48+ inline void decrement (const std::string& key, const float frequency = 1 .0f ) const noexcept ;
4949
5050 // ! Adjusts the specified key by a given delta, at a given frequency rate
51- inline void count (const std::string & key, const int delta, const float frequency = 1 .0f ) const noexcept ;
51+ inline void count (const std::string& key, const int delta, const float frequency = 1 .0f ) const noexcept ;
5252
5353 // ! Records a gauge for the key, with a given value, at a given frequency rate
54- inline void gauge (const std::string & key, const unsigned int value, const float frequency = 1 .0f ) const noexcept ;
54+ inline void gauge (const std::string& key, const unsigned int value, const float frequency = 1 .0f ) const noexcept ;
5555
5656 // ! Records a timing for a key, at a given frequency
57- inline void timing (const std::string & key, const unsigned int ms, const float frequency = 1 .0f ) const noexcept ;
57+ inline void timing (const std::string& key, const unsigned int ms, const float frequency = 1 .0f ) const noexcept ;
5858
5959 // ! Send a value for a key, according to its type, at a given frequency
60- void send (const std::string & key, const int value, const std::string & type, const float frequency = 1 .0f ) const
60+ void send (const std::string& key, const int value, const std::string& type, const float frequency = 1 .0f ) const
6161 noexcept ;
6262
6363 // !@}
@@ -70,45 +70,45 @@ class StatsdClient {
7070 mutable UDPSender m_sender;
7171};
7272
73- StatsdClient::StatsdClient (const std::string & host,
73+ StatsdClient::StatsdClient (const std::string& host,
7474 const uint16_t port,
75- const std::string & prefix,
76- const std::experimental:: optional<uint64_t > batchsize) noexcept
75+ const std::string& prefix,
76+ const std::optional<uint64_t > batchsize) noexcept
7777 : m_prefix(prefix), m_sender(host, port, batchsize) {
7878 // Initialize the randorm generator to be used for sampling
7979 std::srand (time (nullptr ));
8080}
8181
82- void StatsdClient::setConfig (const std::string & host, const uint16_t port, const std::string & prefix) noexcept {
82+ void StatsdClient::setConfig (const std::string& host, const uint16_t port, const std::string& prefix) noexcept {
8383 m_prefix = prefix;
8484 m_sender.setConfig (host, port);
8585}
8686
87- std::experimental:: optional<std::string> StatsdClient::errorMessage () const noexcept {
87+ std::optional<std::string> StatsdClient::errorMessage () const noexcept {
8888 return m_sender.errorMessage ();
8989}
9090
91- void StatsdClient::decrement (const std::string & key, const float frequency) const noexcept {
91+ void StatsdClient::decrement (const std::string& key, const float frequency) const noexcept {
9292 return count (key, -1 , frequency);
9393}
9494
95- void StatsdClient::increment (const std::string & key, const float frequency) const noexcept {
95+ void StatsdClient::increment (const std::string& key, const float frequency) const noexcept {
9696 return count (key, 1 , frequency);
9797}
9898
99- void StatsdClient::count (const std::string & key, const int delta, const float frequency) const noexcept {
99+ void StatsdClient::count (const std::string& key, const int delta, const float frequency) const noexcept {
100100 return send (key, delta, " c" , frequency);
101101}
102102
103- void StatsdClient::gauge (const std::string & key, const unsigned int value, const float frequency) const noexcept {
103+ void StatsdClient::gauge (const std::string& key, const unsigned int value, const float frequency) const noexcept {
104104 return send (key, value, " g" , frequency);
105105}
106106
107- void StatsdClient::timing (const std::string & key, const unsigned int ms, const float frequency) const noexcept {
107+ void StatsdClient::timing (const std::string& key, const unsigned int ms, const float frequency) const noexcept {
108108 return send (key, ms, " ms" , frequency);
109109}
110110
111- void StatsdClient::send (const std::string & key, const int value, const std::string & type, const float frequency) const
111+ void StatsdClient::send (const std::string& key, const int value, const std::string& type, const float frequency) const
112112 noexcept {
113113 const auto isFrequencyOne = [](const float frequency) noexcept {
114114 constexpr float epsilon{0 .0001f };
0 commit comments