THRIFT-4762: Applied some C++11 refactorings to the runtime library and compiler (#1719)
* make use of C++11 override keyword
* added const specifier to TTransport::getOrigin()
* added more const correctness to the compiler
* make use of auto keyword
* replaced usage of NULL with nullptr
* make use of explicitly-defaulted function definition
* extended changelog
diff --git a/lib/c_glib/test/testthrifttestclient.cpp b/lib/c_glib/test/testthrifttestclient.cpp
old mode 100755
new mode 100644
index 1910c8a..20fbcdb
--- a/lib/c_glib/test/testthrifttestclient.cpp
+++ b/lib/c_glib/test/testthrifttestclient.cpp
@@ -67,58 +67,58 @@
class TestHandler : public ThriftTestIf {
public:
- TestHandler() {}
+ TestHandler() = default;
- void testVoid() {
+ void testVoid() override {
cout << "[C -> C++] testVoid()" << endl;
}
- void testString(string& out, const string &thing) {
+ void testString(string& out, const string &thing) override {
cout << "[C -> C++] testString(\"" << thing << "\")" << endl;
out = thing;
}
- bool testBool(const bool thing) {
+ bool testBool(const bool thing) override {
cout << "[C -> C++] testBool(" << (thing ? "true" : "false") << ")" << endl;
return thing;
}
- int8_t testByte(const int8_t thing) {
+ int8_t testByte(const int8_t thing) override {
cout << "[C -> C++] testByte(" << (int)thing << ")" << endl;
return thing;
}
- int32_t testI32(const int32_t thing) {
+ int32_t testI32(const int32_t thing) override {
cout << "[C -> C++] testI32(" << thing << ")" << endl;
return thing;
}
- int64_t testI64(const int64_t thing) {
+ int64_t testI64(const int64_t thing) override {
cout << "[C -> C++] testI64(" << thing << ")" << endl;
return thing;
}
- double testDouble(const double thing) {
+ double testDouble(const double thing) override {
cout.precision(6);
cout << "[C -> C++] testDouble(" << fixed << thing << ")" << endl;
return thing;
}
- void testBinary(string& out, const string &thing) {
+ void testBinary(string& out, const string &thing) override {
cout << "[C -> C++] testBinary(\"" << thing << "\")" << endl;
out = thing;
}
- void testStruct(Xtruct& out, const Xtruct &thing) {
+ void testStruct(Xtruct& out, const Xtruct &thing) override {
cout << "[C -> C++] testStruct({\"" << thing.string_thing << "\", " << (int)thing.byte_thing << ", " << thing.i32_thing << ", " << thing.i64_thing << "})" << endl;
out = thing;
}
- void testNest(Xtruct2& out, const Xtruct2& nest) {
+ void testNest(Xtruct2& out, const Xtruct2& nest) override {
const Xtruct &thing = nest.struct_thing;
cout << "[C -> C++] testNest({" << (int)nest.byte_thing << ", {\"" << thing.string_thing << "\", " << (int)thing.byte_thing << ", " << thing.i32_thing << ", " << thing.i64_thing << "}, " << nest.i32_thing << "})" << endl;
out = nest;
}
- void testMap(map<int32_t, int32_t> &out, const map<int32_t, int32_t> &thing) {
+ void testMap(map<int32_t, int32_t> &out, const map<int32_t, int32_t> &thing) override {
cout << "[C -> C++] testMap({";
map<int32_t, int32_t>::const_iterator m_iter;
bool first = true;
@@ -134,7 +134,7 @@
out = thing;
}
- void testStringMap(map<std::string, std::string> &out, const map<std::string, std::string> &thing) {
+ void testStringMap(map<std::string, std::string> &out, const map<std::string, std::string> &thing) override {
cout << "[C -> C++] testStringMap({";
map<std::string, std::string>::const_iterator m_iter;
bool first = true;
@@ -151,7 +151,7 @@
}
- void testSet(set<int32_t> &out, const set<int32_t> &thing) {
+ void testSet(set<int32_t> &out, const set<int32_t> &thing) override {
cout << "[C -> C++] testSet({";
set<int32_t>::const_iterator s_iter;
bool first = true;
@@ -167,7 +167,7 @@
out = thing;
}
- void testList(vector<int32_t> &out, const vector<int32_t> &thing) {
+ void testList(vector<int32_t> &out, const vector<int32_t> &thing) override {
cout << "[C -> C++] testList({";
vector<int32_t>::const_iterator l_iter;
bool first = true;
@@ -183,16 +183,16 @@
out = thing;
}
- Numberz::type testEnum(const Numberz::type thing) {
+ Numberz::type testEnum(const Numberz::type thing) override {
cout << "[C -> C++] testEnum(" << thing << ")" << endl;
return thing;
}
- UserId testTypedef(const UserId thing) {
+ UserId testTypedef(const UserId thing) override {
cout << "[C -> C++] testTypedef(" << thing << ")" << endl;
return thing; }
- void testMapMap(map<int32_t, map<int32_t,int32_t> > &mapmap, const int32_t hello) {
+ void testMapMap(map<int32_t, map<int32_t,int32_t> > &mapmap, const int32_t hello) override {
cout << "[C -> C++] testMapMap(" << hello << ")" << endl;
map<int32_t,int32_t> pos;
@@ -207,7 +207,7 @@
}
- void testInsanity(map<UserId, map<Numberz::type,Insanity> > &insane, const Insanity &argument) {
+ void testInsanity(map<UserId, map<Numberz::type,Insanity> > &insane, const Insanity &argument) override {
THRIFT_UNUSED_VARIABLE (argument);
cout << "[C -> C++] testInsanity()" << endl;
@@ -277,7 +277,7 @@
}
- void testMulti(Xtruct &hello, const int8_t arg0, const int32_t arg1, const int64_t arg2, const std::map<int16_t, std::string> &arg3, const Numberz::type arg4, const UserId arg5) {
+ void testMulti(Xtruct &hello, const int8_t arg0, const int32_t arg1, const int64_t arg2, const std::map<int16_t, std::string> &arg3, const Numberz::type arg4, const UserId arg5) override {
THRIFT_UNUSED_VARIABLE (arg3);
THRIFT_UNUSED_VARIABLE (arg4);
THRIFT_UNUSED_VARIABLE (arg5);
@@ -291,7 +291,7 @@
}
void testException(const std::string &arg)
- throw(Xception, apache::thrift::TException)
+ throw(Xception, apache::thrift::TException) override
{
cout << "[C -> C++] testException(" << arg << ")" << endl;
if (arg.compare("Xception") == 0) {
@@ -309,7 +309,7 @@
}
}
- void testMultiException(Xtruct &result, const std::string &arg0, const std::string &arg1) throw(Xception, Xception2) {
+ void testMultiException(Xtruct &result, const std::string &arg0, const std::string &arg1) throw(Xception, Xception2) override {
cout << "[C -> C++] testMultiException(" << arg0 << ", " << arg1 << ")" << endl;
@@ -329,7 +329,7 @@
}
}
- void testOneway(int sleepFor) {
+ void testOneway(int sleepFor) override {
cout << "testOneway(" << sleepFor << "): Sleeping..." << endl;
sleep(sleepFor);
cout << "testOneway(" << sleepFor << "): done sleeping!" << endl;
@@ -350,12 +350,12 @@
static void
test_thrift_client (void)
{
- ThriftSocket *tsocket = NULL;
- ThriftBinaryProtocol *protocol = NULL;
- TTestThriftTestClient *client = NULL;
- TTestThriftTestIf *iface = NULL;
- GError *error = NULL;
- gchar *string = NULL;
+ ThriftSocket *tsocket = nullptr;
+ ThriftBinaryProtocol *protocol = nullptr;
+ TTestThriftTestClient *client = nullptr;
+ TTestThriftTestIf *iface = nullptr;
+ GError *error = nullptr;
+ gchar *string = nullptr;
gint8 byte = 0;
gint16 i16 = 0;
gint32 i32 = 0, another_i32 = 56789;
@@ -363,18 +363,18 @@
double dbl = 0.0;
TTestXtruct *xtruct_in, *xtruct_out;
TTestXtruct2 *xtruct2_in, *xtruct2_out;
- GHashTable *map_in = NULL, *map_out = NULL;
- GHashTable *set_in = NULL, *set_out = NULL;
- GArray *list_in = NULL, *list_out = NULL;
+ GHashTable *map_in = nullptr, *map_out = nullptr;
+ GHashTable *set_in = nullptr, *set_out = nullptr;
+ GArray *list_in = nullptr, *list_out = nullptr;
TTestNumberz enum_in, enum_out;
TTestUserId user_id_in, user_id_out;
- GHashTable *insanity_in = NULL;
+ GHashTable *insanity_in = nullptr;
TTestXtruct *xtruct1, *xtruct2;
- TTestInsanity *insanity_out = NULL;
- TTestXtruct *multi_in = NULL;
- GHashTable *multi_map_out = NULL;
- TTestXception *xception = NULL;
- TTestXception2 *xception2 = NULL;
+ TTestInsanity *insanity_out = nullptr;
+ TTestXtruct *multi_in = nullptr;
+ GHashTable *multi_map_out = nullptr;
+ TTestXception *xception = nullptr;
+ TTestXception2 *xception2 = nullptr;
#if (!GLIB_CHECK_VERSION (2, 36, 0))
// initialize gobject
@@ -392,33 +392,33 @@
iface = T_TEST_THRIFT_TEST_IF (client);
// open and send
- thrift_transport_open (THRIFT_TRANSPORT(tsocket), NULL);
+ thrift_transport_open (THRIFT_TRANSPORT(tsocket), nullptr);
assert (t_test_thrift_test_client_test_void (iface, &error) == TRUE);
- assert (error == NULL);
+ assert (error == nullptr);
assert (t_test_thrift_test_client_test_string (iface, &string, "test123", &error) == TRUE);
assert (strcmp (string, "test123") == 0);
g_free (string);
- assert (error == NULL);
+ assert (error == nullptr);
assert (t_test_thrift_test_client_test_byte (iface, &byte, (gint8) 5, &error) == TRUE);
assert (byte == 5);
- assert (error == NULL);
+ assert (error == nullptr);
assert (t_test_thrift_test_client_test_i32 (iface, &i32, 123, &error) == TRUE);
assert (i32 == 123);
- assert (error == NULL);
+ assert (error == nullptr);
assert (t_test_thrift_test_client_test_i64 (iface, &i64, 12345, &error) == TRUE);
assert (i64 == 12345);
- assert (error == NULL);
+ assert (error == nullptr);
assert (t_test_thrift_test_client_test_double (iface, &dbl, 5.6, &error) == TRUE);
assert (dbl == 5.6);
- assert (error == NULL);
+ assert (error == nullptr);
- xtruct_out = (TTestXtruct *) g_object_new (T_TEST_TYPE_XTRUCT, NULL);
+ xtruct_out = (TTestXtruct *) g_object_new (T_TEST_TYPE_XTRUCT, nullptr);
xtruct_out->byte_thing = 1;
xtruct_out->__isset_byte_thing = TRUE;
xtruct_out->i32_thing = 15;
@@ -427,50 +427,50 @@
xtruct_out->__isset_i64_thing = TRUE;
xtruct_out->string_thing = g_strdup ("abc123");
xtruct_out->__isset_string_thing = TRUE;
- xtruct_in = (TTestXtruct *) g_object_new(T_TEST_TYPE_XTRUCT, NULL);
+ xtruct_in = (TTestXtruct *) g_object_new(T_TEST_TYPE_XTRUCT, nullptr);
assert (t_test_thrift_test_client_test_struct (iface, &xtruct_in, xtruct_out, &error) == TRUE);
- assert (error == NULL);
+ assert (error == nullptr);
- xtruct2_out = (TTestXtruct2 *) g_object_new (T_TEST_TYPE_XTRUCT2, NULL);
+ xtruct2_out = (TTestXtruct2 *) g_object_new (T_TEST_TYPE_XTRUCT2, nullptr);
xtruct2_out->byte_thing = 1;
xtruct2_out->__isset_byte_thing = TRUE;
- if (xtruct2_out->struct_thing != NULL)
+ if (xtruct2_out->struct_thing != nullptr)
g_object_unref(xtruct2_out->struct_thing);
xtruct2_out->struct_thing = xtruct_out;
xtruct2_out->__isset_struct_thing = TRUE;
xtruct2_out->i32_thing = 123;
xtruct2_out->__isset_i32_thing = TRUE;
- xtruct2_in = (TTestXtruct2 *) g_object_new (T_TEST_TYPE_XTRUCT2, NULL);
+ xtruct2_in = (TTestXtruct2 *) g_object_new (T_TEST_TYPE_XTRUCT2, nullptr);
assert (t_test_thrift_test_client_test_nest (iface, &xtruct2_in, xtruct2_out, &error) == TRUE);
- assert (error == NULL);
+ assert (error == nullptr);
g_object_unref (xtruct2_out);
g_object_unref (xtruct2_in);
g_object_unref (xtruct_in);
- map_out = g_hash_table_new (NULL, NULL);
- map_in = g_hash_table_new (NULL, NULL); g_hash_table_insert (map_out, &i32, &i32);
+ map_out = g_hash_table_new (nullptr, nullptr);
+ map_in = g_hash_table_new (nullptr, nullptr); g_hash_table_insert (map_out, &i32, &i32);
assert (t_test_thrift_test_client_test_map (iface, &map_in, map_out, &error) == TRUE);
- assert (error == NULL);
+ assert (error == nullptr);
g_hash_table_destroy (map_out);
g_hash_table_destroy (map_in);
- map_out = g_hash_table_new (NULL, NULL);
- map_in = g_hash_table_new (NULL, NULL);
+ map_out = g_hash_table_new (nullptr, nullptr);
+ map_in = g_hash_table_new (nullptr, nullptr);
g_hash_table_insert (map_out, g_strdup ("a"), g_strdup ("123"));
g_hash_table_insert (map_out, g_strdup ("a b"), g_strdup ("with spaces "));
g_hash_table_insert (map_out, g_strdup ("same"), g_strdup ("same"));
g_hash_table_insert (map_out, g_strdup ("0"), g_strdup ("numeric key"));
assert (t_test_thrift_test_client_test_string_map (iface, &map_in, map_out, &error) == TRUE);
- assert (error == NULL);
+ assert (error == nullptr);
g_hash_table_destroy (map_out);
g_hash_table_destroy (map_in);
- set_out = g_hash_table_new (NULL, NULL);
- set_in = g_hash_table_new (NULL, NULL);
+ set_out = g_hash_table_new (nullptr, nullptr);
+ set_in = g_hash_table_new (nullptr, nullptr);
g_hash_table_insert (set_out, &i32, &i32);
assert (t_test_thrift_test_client_test_set (iface, &set_in, set_out, &error) == TRUE);
- assert (error == NULL);
+ assert (error == nullptr);
g_hash_table_destroy (set_out);
g_hash_table_destroy (set_in);
@@ -480,31 +480,31 @@
g_array_append_val (list_out, i32);
g_array_append_val (list_out, another_i32);
assert (t_test_thrift_test_client_test_list (iface, &list_in, list_out, &error) == TRUE);
- assert (error == NULL);
+ assert (error == nullptr);
g_array_free (list_out, TRUE);
g_array_free (list_in, TRUE);
enum_out = T_TEST_NUMBERZ_ONE;
assert (t_test_thrift_test_client_test_enum (iface, &enum_in, enum_out, &error) == TRUE);
assert (enum_in == enum_out);
- assert (error == NULL);
+ assert (error == nullptr);
user_id_out = 12345;
assert (t_test_thrift_test_client_test_typedef (iface, &user_id_in, user_id_out, &error) == TRUE);
assert (user_id_in == user_id_out);
- assert (error == NULL);
+ assert (error == nullptr);
- map_in = g_hash_table_new (NULL, NULL);
+ map_in = g_hash_table_new (nullptr, nullptr);
assert (t_test_thrift_test_client_test_map_map (iface, &map_in, i32, &error) == TRUE);
- assert (error == NULL);
+ assert (error == nullptr);
g_hash_table_destroy (map_in);
// insanity
- insanity_out = (TTestInsanity *) g_object_new (T_TEST_TYPE_INSANITY, NULL);
- insanity_out->userMap = g_hash_table_new (NULL, NULL);
+ insanity_out = (TTestInsanity *) g_object_new (T_TEST_TYPE_INSANITY, nullptr);
+ insanity_out->userMap = g_hash_table_new (nullptr, nullptr);
g_hash_table_insert (insanity_out->userMap, GINT_TO_POINTER (enum_out), &user_id_out);
- xtruct1 = (TTestXtruct *) g_object_new (T_TEST_TYPE_XTRUCT, NULL);
+ xtruct1 = (TTestXtruct *) g_object_new (T_TEST_TYPE_XTRUCT, nullptr);
xtruct1->byte_thing = 1;
xtruct1->__isset_byte_thing = TRUE;
xtruct1->i32_thing = 15;
@@ -513,7 +513,7 @@
xtruct1->__isset_i64_thing = TRUE;
xtruct1->string_thing = g_strdup ("abc123");
xtruct1->__isset_string_thing = TRUE;
- xtruct2 = (TTestXtruct *) g_object_new (T_TEST_TYPE_XTRUCT, NULL);
+ xtruct2 = (TTestXtruct *) g_object_new (T_TEST_TYPE_XTRUCT, nullptr);
xtruct2->byte_thing = 1;
xtruct2->__isset_byte_thing = TRUE;
xtruct2->i32_thing = 15;
@@ -523,7 +523,7 @@
xtruct2->string_thing = g_strdup ("abc123");
xtruct2->__isset_string_thing = TRUE;
- insanity_in = g_hash_table_new (NULL, NULL);
+ insanity_in = g_hash_table_new (nullptr, nullptr);
g_ptr_array_add (insanity_out->xtructs, xtruct1);
g_ptr_array_add (insanity_out->xtructs, xtruct2);
assert (t_test_thrift_test_client_test_insanity (iface, &insanity_in, insanity_out, &error) == TRUE);
@@ -531,10 +531,10 @@
g_hash_table_unref (insanity_in);
g_ptr_array_free (insanity_out->xtructs, TRUE);
- multi_map_out = g_hash_table_new (NULL, NULL);
+ multi_map_out = g_hash_table_new (nullptr, nullptr);
string = g_strdup ("abc123");
g_hash_table_insert (multi_map_out, &i16, string);
- multi_in = (TTestXtruct *) g_object_new (T_TEST_TYPE_XTRUCT, NULL);
+ multi_in = (TTestXtruct *) g_object_new (T_TEST_TYPE_XTRUCT, nullptr);
assert (t_test_thrift_test_client_test_multi (iface, &multi_in, byte, i32, i64, multi_map_out, enum_out, user_id_out, &error) == TRUE);
assert (multi_in->i32_thing == i32);
assert (multi_in->i64_thing == i64);
@@ -545,53 +545,53 @@
assert (t_test_thrift_test_client_test_exception (iface, "Xception", &xception, &error) == FALSE);
assert (xception->errorCode == 1001);
g_error_free (error);
- error = NULL;
+ error = nullptr;
g_object_unref (xception);
- xception = NULL;
+ xception = nullptr;
assert (t_test_thrift_test_client_test_exception (iface, "ApplicationException", &xception, &error) == FALSE);
g_error_free (error);
- error = NULL;
- assert (xception == NULL);
+ error = nullptr;
+ assert (xception == nullptr);
assert (t_test_thrift_test_client_test_exception (iface, "Test", &xception, &error) == TRUE);
- assert (error == NULL);
+ assert (error == nullptr);
- multi_in = (TTestXtruct*) g_object_new (T_TEST_TYPE_XTRUCT, NULL);
- assert (t_test_thrift_test_client_test_multi_exception (iface, &multi_in, "Xception", NULL, &xception, &xception2, &error) == FALSE);
+ multi_in = (TTestXtruct*) g_object_new (T_TEST_TYPE_XTRUCT, nullptr);
+ assert (t_test_thrift_test_client_test_multi_exception (iface, &multi_in, "Xception", nullptr, &xception, &xception2, &error) == FALSE);
assert (xception->errorCode == 1001);
- assert (xception2 == NULL);
+ assert (xception2 == nullptr);
g_error_free (error);
- error = NULL;
+ error = nullptr;
g_object_unref (xception);
g_object_unref (multi_in);
- xception = NULL;
- multi_in = NULL;
+ xception = nullptr;
+ multi_in = nullptr;
- multi_in = (TTestXtruct*) g_object_new (T_TEST_TYPE_XTRUCT, NULL);
- assert (t_test_thrift_test_client_test_multi_exception (iface, &multi_in, "Xception2", NULL, &xception, &xception2, &error) == FALSE);
+ multi_in = (TTestXtruct*) g_object_new (T_TEST_TYPE_XTRUCT, nullptr);
+ assert (t_test_thrift_test_client_test_multi_exception (iface, &multi_in, "Xception2", nullptr, &xception, &xception2, &error) == FALSE);
assert (xception2->errorCode == 2002);
- assert (xception == NULL);
+ assert (xception == nullptr);
g_error_free (error);
- error = NULL;
+ error = nullptr;
g_object_unref (xception2);
g_object_unref (multi_in);
- xception2 = NULL;
- multi_in = NULL;
+ xception2 = nullptr;
+ multi_in = nullptr;
- multi_in = (TTestXtruct*) g_object_new (T_TEST_TYPE_XTRUCT, NULL);
- assert (t_test_thrift_test_client_test_multi_exception (iface, &multi_in, NULL , NULL, &xception, &xception2, &error) == TRUE);
- assert (error == NULL);
+ multi_in = (TTestXtruct*) g_object_new (T_TEST_TYPE_XTRUCT, nullptr);
+ assert (t_test_thrift_test_client_test_multi_exception (iface, &multi_in, nullptr , nullptr, &xception, &xception2, &error) == TRUE);
+ assert (error == nullptr);
g_object_unref(multi_in);
- multi_in = NULL;
+ multi_in = nullptr;
assert (t_test_thrift_test_client_test_oneway (iface, 1, &error) == TRUE);
- assert (error == NULL);
+ assert (error == nullptr);
/* sleep to let the oneway call go through */
sleep (5);
- thrift_transport_close (THRIFT_TRANSPORT(tsocket), NULL);
+ thrift_transport_close (THRIFT_TRANSPORT(tsocket), nullptr);
g_object_unref (client);
g_object_unref (protocol);
g_object_unref (tsocket);
diff --git a/lib/cpp/README.md b/lib/cpp/README.md
index af37627..8a897d1 100755
--- a/lib/cpp/README.md
+++ b/lib/cpp/README.md
@@ -252,6 +252,10 @@
THRIFT-4735:
Qt4 support was removed.
+THRIFT-4762:
+Added `const` specifier to `TTransport::getOrigin()`. This changes its function signature.
+It's recommended to add the `override` specifier in implementations derived from `TTransport`.
+
## 0.11.0
Older versions of thrift depended on the <boost/smart_ptr.hpp> classes which
diff --git a/lib/cpp/src/thrift/TApplicationException.h b/lib/cpp/src/thrift/TApplicationException.h
index 60618fb..cd1b3e7 100644
--- a/lib/cpp/src/thrift/TApplicationException.h
+++ b/lib/cpp/src/thrift/TApplicationException.h
@@ -57,7 +57,7 @@
TApplicationException(TApplicationExceptionType type, const std::string& message)
: TException(message), type_(type) {}
- virtual ~TApplicationException() noexcept {}
+ ~TApplicationException() noexcept override = default;
/**
* Returns an error code that provides information about the type of error
@@ -67,7 +67,7 @@
*/
TApplicationExceptionType getType() const { return type_; }
- virtual const char* what() const noexcept {
+ const char* what() const noexcept override {
if (message_.empty()) {
switch (type_) {
case UNKNOWN:
diff --git a/lib/cpp/src/thrift/TBase.h b/lib/cpp/src/thrift/TBase.h
index a274bcd..cc31c34 100644
--- a/lib/cpp/src/thrift/TBase.h
+++ b/lib/cpp/src/thrift/TBase.h
@@ -28,7 +28,7 @@
class TBase {
public:
- virtual ~TBase(){};
+ virtual ~TBase()= default;;
virtual uint32_t read(protocol::TProtocol* iprot) = 0;
virtual uint32_t write(protocol::TProtocol* oprot) const = 0;
};
diff --git a/lib/cpp/src/thrift/TDispatchProcessor.h b/lib/cpp/src/thrift/TDispatchProcessor.h
index 28d347d..ae522b2 100644
--- a/lib/cpp/src/thrift/TDispatchProcessor.h
+++ b/lib/cpp/src/thrift/TDispatchProcessor.h
@@ -33,15 +33,15 @@
template <class Protocol_>
class TDispatchProcessorT : public TProcessor {
public:
- virtual bool process(std::shared_ptr<protocol::TProtocol> in,
+ bool process(std::shared_ptr<protocol::TProtocol> in,
std::shared_ptr<protocol::TProtocol> out,
- void* connectionContext) {
+ void* connectionContext) override {
protocol::TProtocol* inRaw = in.get();
protocol::TProtocol* outRaw = out.get();
// Try to dynamic cast to the template protocol type
- Protocol_* specificIn = dynamic_cast<Protocol_*>(inRaw);
- Protocol_* specificOut = dynamic_cast<Protocol_*>(outRaw);
+ auto* specificIn = dynamic_cast<Protocol_*>(inRaw);
+ auto* specificOut = dynamic_cast<Protocol_*>(outRaw);
if (specificIn && specificOut) {
return processFast(specificIn, specificOut, connectionContext);
}
@@ -105,9 +105,9 @@
*/
class TDispatchProcessor : public TProcessor {
public:
- virtual bool process(std::shared_ptr<protocol::TProtocol> in,
+ bool process(std::shared_ptr<protocol::TProtocol> in,
std::shared_ptr<protocol::TProtocol> out,
- void* connectionContext) {
+ void* connectionContext) override {
std::string fname;
protocol::TMessageType mtype;
int32_t seqid;
diff --git a/lib/cpp/src/thrift/TOutput.cpp b/lib/cpp/src/thrift/TOutput.cpp
index af36137..f25b566 100644
--- a/lib/cpp/src/thrift/TOutput.cpp
+++ b/lib/cpp/src/thrift/TOutput.cpp
@@ -62,7 +62,7 @@
#endif
char* heap_buf = (char*)malloc((need + 1) * sizeof(char));
- if (heap_buf == NULL) {
+ if (heap_buf == nullptr) {
#ifdef _MSC_VER
va_start(ap, message);
vsnprintf_s(stack_buf, STACK_BUF_SIZE, _TRUNCATE, message, ap);
diff --git a/lib/cpp/src/thrift/TProcessor.h b/lib/cpp/src/thrift/TProcessor.h
index 6a46466..65bf3d4 100644
--- a/lib/cpp/src/thrift/TProcessor.h
+++ b/lib/cpp/src/thrift/TProcessor.h
@@ -35,7 +35,7 @@
*/
class TProcessorEventHandler {
public:
- virtual ~TProcessorEventHandler() {}
+ virtual ~TProcessorEventHandler() = default;
/**
* Called before calling other callback methods.
@@ -46,7 +46,7 @@
virtual void* getContext(const char* fn_name, void* serverContext) {
(void)fn_name;
(void)serverContext;
- return NULL;
+ return nullptr;
}
/**
@@ -108,7 +108,7 @@
}
protected:
- TProcessorEventHandler() {}
+ TProcessorEventHandler() = default;
};
/**
@@ -119,10 +119,10 @@
TProcessorContextFreer(TProcessorEventHandler* handler, void* context, const char* method)
: handler_(handler), context_(context), method_(method) {}
~TProcessorContextFreer() {
- if (handler_ != NULL)
+ if (handler_ != nullptr)
handler_->freeContext(context_, method_);
}
- void unregister() { handler_ = NULL; }
+ void unregister() { handler_ = nullptr; }
private:
apache::thrift::TProcessorEventHandler* handler_;
@@ -139,7 +139,7 @@
*/
class TProcessor {
public:
- virtual ~TProcessor() {}
+ virtual ~TProcessor() = default;
virtual bool process(std::shared_ptr<protocol::TProtocol> in,
std::shared_ptr<protocol::TProtocol> out,
@@ -156,7 +156,7 @@
}
protected:
- TProcessor() {}
+ TProcessor() = default;
std::shared_ptr<TProcessorEventHandler> eventHandler_;
};
@@ -202,7 +202,7 @@
class TProcessorFactory {
public:
- virtual ~TProcessorFactory() {}
+ virtual ~TProcessorFactory() = default;
/**
* Get the TProcessor to use for a particular connection.
@@ -218,7 +218,7 @@
public:
TSingletonProcessorFactory(std::shared_ptr<TProcessor> processor) : processor_(processor) {}
- std::shared_ptr<TProcessor> getProcessor(const TConnectionInfo&) { return processor_; }
+ std::shared_ptr<TProcessor> getProcessor(const TConnectionInfo&) override { return processor_; }
private:
std::shared_ptr<TProcessor> processor_;
diff --git a/lib/cpp/src/thrift/Thrift.h b/lib/cpp/src/thrift/Thrift.h
index 6322742..951cc28 100644
--- a/lib/cpp/src/thrift/Thrift.h
+++ b/lib/cpp/src/thrift/Thrift.h
@@ -79,9 +79,9 @@
TException(const std::string& message) : message_(message) {}
- virtual ~TException() noexcept {}
+ ~TException() noexcept override = default;
- virtual const char* what() const noexcept {
+ const char* what() const noexcept override {
if (message_.empty()) {
return "Default TException.";
} else {
@@ -98,14 +98,14 @@
template <class E>
static TDelayedException* delayException(const E& e);
virtual void throw_it() = 0;
- virtual ~TDelayedException(){};
+ virtual ~TDelayedException()= default;;
};
template <class E>
class TExceptionWrapper : public TDelayedException {
public:
TExceptionWrapper(const E& e) : e_(e) {}
- virtual void throw_it() {
+ void throw_it() override {
E temp(e_);
delete this;
throw temp;
diff --git a/lib/cpp/src/thrift/async/TAsyncBufferProcessor.h b/lib/cpp/src/thrift/async/TAsyncBufferProcessor.h
index 9c96b14..e3c3597 100644
--- a/lib/cpp/src/thrift/async/TAsyncBufferProcessor.h
+++ b/lib/cpp/src/thrift/async/TAsyncBufferProcessor.h
@@ -37,7 +37,7 @@
virtual void process(std::function<void(bool healthy)> _return,
std::shared_ptr<transport::TBufferBase> ibuf,
std::shared_ptr<transport::TBufferBase> obuf) = 0;
- virtual ~TAsyncBufferProcessor() {}
+ virtual ~TAsyncBufferProcessor() = default;
};
}
}
diff --git a/lib/cpp/src/thrift/async/TAsyncChannel.h b/lib/cpp/src/thrift/async/TAsyncChannel.h
index d7ace96..22cf383 100644
--- a/lib/cpp/src/thrift/async/TAsyncChannel.h
+++ b/lib/cpp/src/thrift/async/TAsyncChannel.h
@@ -41,7 +41,7 @@
public:
typedef std::function<void()> VoidCallback;
- virtual ~TAsyncChannel() {}
+ virtual ~TAsyncChannel() = default;
// is the channel in a good state?
virtual bool good() const = 0;
diff --git a/lib/cpp/src/thrift/async/TAsyncDispatchProcessor.h b/lib/cpp/src/thrift/async/TAsyncDispatchProcessor.h
index 59db597..2a694ac 100644
--- a/lib/cpp/src/thrift/async/TAsyncDispatchProcessor.h
+++ b/lib/cpp/src/thrift/async/TAsyncDispatchProcessor.h
@@ -34,15 +34,15 @@
template <class Protocol_>
class TAsyncDispatchProcessorT : public TAsyncProcessor {
public:
- virtual void process(std::function<void(bool success)> _return,
+ void process(std::function<void(bool success)> _return,
std::shared_ptr<protocol::TProtocol> in,
- std::shared_ptr<protocol::TProtocol> out) {
+ std::shared_ptr<protocol::TProtocol> out) override {
protocol::TProtocol* inRaw = in.get();
protocol::TProtocol* outRaw = out.get();
// Try to dynamic cast to the template protocol type
- Protocol_* specificIn = dynamic_cast<Protocol_*>(inRaw);
- Protocol_* specificOut = dynamic_cast<Protocol_*>(outRaw);
+ auto* specificIn = dynamic_cast<Protocol_*>(inRaw);
+ auto* specificOut = dynamic_cast<Protocol_*>(outRaw);
if (specificIn && specificOut) {
return processFast(_return, specificIn, specificOut);
}
@@ -106,9 +106,9 @@
*/
class TAsyncDispatchProcessor : public TAsyncProcessor {
public:
- virtual void process(std::function<void(bool success)> _return,
+ void process(std::function<void(bool success)> _return,
std::shared_ptr<protocol::TProtocol> in,
- std::shared_ptr<protocol::TProtocol> out) {
+ std::shared_ptr<protocol::TProtocol> out) override {
protocol::TProtocol* inRaw = in.get();
protocol::TProtocol* outRaw = out.get();
diff --git a/lib/cpp/src/thrift/async/TAsyncProcessor.h b/lib/cpp/src/thrift/async/TAsyncProcessor.h
index fdb976d..0192339 100644
--- a/lib/cpp/src/thrift/async/TAsyncProcessor.h
+++ b/lib/cpp/src/thrift/async/TAsyncProcessor.h
@@ -35,7 +35,7 @@
class TAsyncProcessor {
public:
- virtual ~TAsyncProcessor() {}
+ virtual ~TAsyncProcessor() = default;
virtual void process(std::function<void(bool success)> _return,
std::shared_ptr<protocol::TProtocol> in,
@@ -53,14 +53,14 @@
}
protected:
- TAsyncProcessor() {}
+ TAsyncProcessor() = default;
std::shared_ptr<TProcessorEventHandler> eventHandler_;
};
class TAsyncProcessorFactory {
public:
- virtual ~TAsyncProcessorFactory() {}
+ virtual ~TAsyncProcessorFactory() = default;
/**
* Get the TAsyncProcessor to use for a particular connection.
diff --git a/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.h b/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.h
index 8052cf3..ace72b6 100644
--- a/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.h
+++ b/lib/cpp/src/thrift/async/TAsyncProtocolProcessor.h
@@ -34,11 +34,11 @@
std::shared_ptr<apache::thrift::protocol::TProtocolFactory> pfact)
: underlying_(underlying), pfact_(pfact) {}
- virtual void process(std::function<void(bool healthy)> _return,
+ void process(std::function<void(bool healthy)> _return,
std::shared_ptr<apache::thrift::transport::TBufferBase> ibuf,
- std::shared_ptr<apache::thrift::transport::TBufferBase> obuf);
+ std::shared_ptr<apache::thrift::transport::TBufferBase> obuf) override;
- virtual ~TAsyncProtocolProcessor() {}
+ ~TAsyncProtocolProcessor() override = default;
private:
static void finish(std::function<void(bool healthy)> _return,
diff --git a/lib/cpp/src/thrift/async/TConcurrentClientSyncInfo.cpp b/lib/cpp/src/thrift/async/TConcurrentClientSyncInfo.cpp
index c7e27c0..952394b 100644
--- a/lib/cpp/src/thrift/async/TConcurrentClientSyncInfo.cpp
+++ b/lib/cpp/src/thrift/async/TConcurrentClientSyncInfo.cpp
@@ -75,7 +75,7 @@
MonitorPtr monitor;
{
Guard seqidGuard(seqidMutex_);
- MonitorMap::iterator i = seqidToMonitorMap_.find(rseqid);
+ auto i = seqidToMonitorMap_.find(rseqid);
if(i == seqidToMonitorMap_.end())
throwBadSeqId_();
monitor = i->second;
@@ -140,7 +140,7 @@
{
wakeupSomeone_ = true;
stop_ = true;
- for(MonitorMap::iterator i = seqidToMonitorMap_.begin(); i != seqidToMonitorMap_.end(); ++i)
+ for(auto i = seqidToMonitorMap_.begin(); i != seqidToMonitorMap_.end(); ++i)
i->second->notify();
}
diff --git a/lib/cpp/src/thrift/async/TEvhttpClientChannel.cpp b/lib/cpp/src/thrift/async/TEvhttpClientChannel.cpp
index 6af8104..7656596 100644
--- a/lib/cpp/src/thrift/async/TEvhttpClientChannel.cpp
+++ b/lib/cpp/src/thrift/async/TEvhttpClientChannel.cpp
@@ -41,15 +41,15 @@
struct event_base* eb,
struct evdns_base* dnsbase)
- : host_(host), path_(path), conn_(NULL) {
+ : host_(host), path_(path), conn_(nullptr) {
conn_ = evhttp_connection_base_new(eb, dnsbase, address, port);
- if (conn_ == NULL) {
+ if (conn_ == nullptr) {
throw TException("evhttp_connection_new failed");
}
}
TEvhttpClientChannel::~TEvhttpClientChannel() {
- if (conn_ != NULL) {
+ if (conn_ != nullptr) {
evhttp_connection_free(conn_);
}
}
@@ -58,7 +58,7 @@
apache::thrift::transport::TMemoryBuffer* sendBuf,
apache::thrift::transport::TMemoryBuffer* recvBuf) {
struct evhttp_request* req = evhttp_request_new(response, this);
- if (req == NULL) {
+ if (req == nullptr) {
throw TException("evhttp_request_new failed");
}
@@ -110,7 +110,7 @@
assert(!completionQueue_.empty());
Completion completion = completionQueue_.front();
completionQueue_.pop();
- if (req == NULL) {
+ if (req == nullptr) {
try {
completion.first();
} catch (const TTransportException& e) {
@@ -142,7 +142,7 @@
}
/* static */ void TEvhttpClientChannel::response(struct evhttp_request* req, void* arg) {
- TEvhttpClientChannel* self = (TEvhttpClientChannel*)arg;
+ auto* self = (TEvhttpClientChannel*)arg;
try {
self->finish(req);
} catch (std::exception& e) {
diff --git a/lib/cpp/src/thrift/async/TEvhttpClientChannel.h b/lib/cpp/src/thrift/async/TEvhttpClientChannel.h
index a321f41..f742726 100644
--- a/lib/cpp/src/thrift/async/TEvhttpClientChannel.h
+++ b/lib/cpp/src/thrift/async/TEvhttpClientChannel.h
@@ -52,24 +52,24 @@
const char* address,
int port,
struct event_base* eb,
- struct evdns_base *dnsbase = 0);
- ~TEvhttpClientChannel();
+ struct evdns_base *dnsbase = nullptr);
+ ~TEvhttpClientChannel() override;
- virtual void sendAndRecvMessage(const VoidCallback& cob,
+ void sendAndRecvMessage(const VoidCallback& cob,
apache::thrift::transport::TMemoryBuffer* sendBuf,
- apache::thrift::transport::TMemoryBuffer* recvBuf);
+ apache::thrift::transport::TMemoryBuffer* recvBuf) override;
- virtual void sendMessage(const VoidCallback& cob,
- apache::thrift::transport::TMemoryBuffer* message);
- virtual void recvMessage(const VoidCallback& cob,
- apache::thrift::transport::TMemoryBuffer* message);
+ void sendMessage(const VoidCallback& cob,
+ apache::thrift::transport::TMemoryBuffer* message) override;
+ void recvMessage(const VoidCallback& cob,
+ apache::thrift::transport::TMemoryBuffer* message) override;
void finish(struct evhttp_request* req);
// XXX
- virtual bool good() const { return true; }
- virtual bool error() const { return false; }
- virtual bool timedOut() const { return false; }
+ bool good() const override { return true; }
+ bool error() const override { return false; }
+ bool timedOut() const override { return false; }
private:
static void response(struct evhttp_request* req, void* arg);
diff --git a/lib/cpp/src/thrift/async/TEvhttpServer.cpp b/lib/cpp/src/thrift/async/TEvhttpServer.cpp
index bdc3266..7d2cf21 100644
--- a/lib/cpp/src/thrift/async/TEvhttpServer.cpp
+++ b/lib/cpp/src/thrift/async/TEvhttpServer.cpp
@@ -46,24 +46,24 @@
};
TEvhttpServer::TEvhttpServer(std::shared_ptr<TAsyncBufferProcessor> processor)
- : processor_(processor), eb_(NULL), eh_(NULL) {
+ : processor_(processor), eb_(nullptr), eh_(nullptr) {
}
TEvhttpServer::TEvhttpServer(std::shared_ptr<TAsyncBufferProcessor> processor, int port)
- : processor_(processor), eb_(NULL), eh_(NULL) {
+ : processor_(processor), eb_(nullptr), eh_(nullptr) {
// Create event_base and evhttp.
eb_ = event_base_new();
- if (eb_ == NULL) {
+ if (eb_ == nullptr) {
throw TException("event_base_new failed");
}
eh_ = evhttp_new(eb_);
- if (eh_ == NULL) {
+ if (eh_ == nullptr) {
event_base_free(eb_);
throw TException("evhttp_new failed");
}
// Bind to port.
- int ret = evhttp_bind_socket(eh_, NULL, port);
+ int ret = evhttp_bind_socket(eh_, nullptr, port);
if (ret < 0) {
evhttp_free(eh_);
event_base_free(eb_);
@@ -77,16 +77,16 @@
}
TEvhttpServer::~TEvhttpServer() {
- if (eh_ != NULL) {
+ if (eh_ != nullptr) {
evhttp_free(eh_);
}
- if (eb_ != NULL) {
+ if (eb_ != nullptr) {
event_base_free(eb_);
}
}
int TEvhttpServer::serve() {
- if (eb_ == NULL) {
+ if (eb_ == nullptr) {
throw TException("Unexpected call to TEvhttpServer::serve");
}
return event_base_dispatch(eb_);
@@ -103,12 +103,12 @@
try {
static_cast<TEvhttpServer*>(self)->process(req);
} catch (std::exception& e) {
- evhttp_send_reply(req, HTTP_INTERNAL, e.what(), 0);
+ evhttp_send_reply(req, HTTP_INTERNAL, e.what(), nullptr);
}
}
void TEvhttpServer::process(struct evhttp_request* req) {
- RequestContext* ctx = new RequestContext(req);
+ auto* ctx = new RequestContext(req);
return processor_->process(std::bind(&TEvhttpServer::complete,
this,
ctx,
@@ -131,7 +131,7 @@
}
struct evbuffer* buf = evbuffer_new();
- if (buf == NULL) {
+ if (buf == nullptr) {
// TODO: Log an error.
std::cerr << "evbuffer_new failed " << __FILE__ << ":" << __LINE__ << std::endl;
} else {
@@ -147,7 +147,7 @@
}
evhttp_send_reply(ctx->req, code, reason, buf);
- if (buf != NULL) {
+ if (buf != nullptr) {
evbuffer_free(buf);
}
}
diff --git a/lib/cpp/src/thrift/concurrency/Exception.h b/lib/cpp/src/thrift/concurrency/Exception.h
index 6438fda..947fc9f 100644
--- a/lib/cpp/src/thrift/concurrency/Exception.h
+++ b/lib/cpp/src/thrift/concurrency/Exception.h
@@ -35,7 +35,7 @@
class IllegalStateException : public apache::thrift::TException {
public:
- IllegalStateException() {}
+ IllegalStateException() = default;
IllegalStateException(const std::string& message) : TException(message) {}
};
@@ -53,7 +53,7 @@
class SystemResourceException : public apache::thrift::TException {
public:
- SystemResourceException() {}
+ SystemResourceException() = default;
SystemResourceException(const std::string& message) : TException(message) {}
};
diff --git a/lib/cpp/src/thrift/concurrency/FunctionRunner.h b/lib/cpp/src/thrift/concurrency/FunctionRunner.h
index 8ad176e..4688344 100644
--- a/lib/cpp/src/thrift/concurrency/FunctionRunner.h
+++ b/lib/cpp/src/thrift/concurrency/FunctionRunner.h
@@ -96,7 +96,7 @@
*/
FunctionRunner(const BoolFunc& cob, int intervalMs) : repFunc_(cob), intervalMs_(intervalMs) {}
- void run() {
+ void run() override {
if (repFunc_) {
while (repFunc_()) {
THRIFT_SLEEP_USEC(intervalMs_ * 1000);
diff --git a/lib/cpp/src/thrift/concurrency/Monitor.cpp b/lib/cpp/src/thrift/concurrency/Monitor.cpp
index 99d52b3..dc92efd 100644
--- a/lib/cpp/src/thrift/concurrency/Monitor.cpp
+++ b/lib/cpp/src/thrift/concurrency/Monitor.cpp
@@ -41,11 +41,11 @@
class Monitor::Impl {
public:
- Impl() : ownedMutex_(new Mutex()), conditionVariable_(), mutex_(NULL) { init(ownedMutex_.get()); }
+ Impl() : ownedMutex_(new Mutex()), conditionVariable_(), mutex_(nullptr) { init(ownedMutex_.get()); }
- Impl(Mutex* mutex) : ownedMutex_(), conditionVariable_(), mutex_(NULL) { init(mutex); }
+ Impl(Mutex* mutex) : ownedMutex_(), conditionVariable_(), mutex_(nullptr) { init(mutex); }
- Impl(Monitor* monitor) : ownedMutex_(), conditionVariable_(), mutex_(NULL) {
+ Impl(Monitor* monitor) : ownedMutex_(), conditionVariable_(), mutex_(nullptr) {
init(&(monitor->mutex()));
}
@@ -81,7 +81,7 @@
}
assert(mutex_);
- std::timed_mutex* mutexImpl = static_cast<std::timed_mutex*>(mutex_->getUnderlyingImpl());
+ auto* mutexImpl = static_cast<std::timed_mutex*>(mutex_->getUnderlyingImpl());
assert(mutexImpl);
std::unique_lock<std::timed_mutex> lock(*mutexImpl, std::adopt_lock);
@@ -97,7 +97,7 @@
*/
int waitForTime(const std::chrono::time_point<std::chrono::steady_clock>& abstime) {
assert(mutex_);
- std::timed_mutex* mutexImpl = static_cast<std::timed_mutex*>(mutex_->getUnderlyingImpl());
+ auto* mutexImpl = static_cast<std::timed_mutex*>(mutex_->getUnderlyingImpl());
assert(mutexImpl);
std::unique_lock<std::timed_mutex> lock(*mutexImpl, std::adopt_lock);
@@ -113,7 +113,7 @@
*/
int waitForever() {
assert(mutex_);
- std::timed_mutex* mutexImpl = static_cast<std::timed_mutex*>(mutex_->getUnderlyingImpl());
+ auto* mutexImpl = static_cast<std::timed_mutex*>(mutex_->getUnderlyingImpl());
assert(mutexImpl);
std::unique_lock<std::timed_mutex> lock(*mutexImpl, std::adopt_lock);
diff --git a/lib/cpp/src/thrift/concurrency/Mutex.h b/lib/cpp/src/thrift/concurrency/Mutex.h
index 5e0f85b..27e386e 100644
--- a/lib/cpp/src/thrift/concurrency/Mutex.h
+++ b/lib/cpp/src/thrift/concurrency/Mutex.h
@@ -40,7 +40,7 @@
class Mutex {
public:
Mutex();
- virtual ~Mutex() {}
+ virtual ~Mutex() = default;
virtual void lock() const;
virtual bool trylock() const;
@@ -62,11 +62,11 @@
value.lock();
} else if (timeout < 0) {
if (!value.trylock()) {
- mutex_ = NULL;
+ mutex_ = nullptr;
}
} else {
if (!value.timedlock(timeout)) {
- mutex_ = NULL;
+ mutex_ = nullptr;
}
}
}
@@ -76,7 +76,7 @@
}
}
- operator bool() const { return (mutex_ != NULL); }
+ operator bool() const { return (mutex_ != nullptr); }
private:
const Mutex* mutex_;
diff --git a/lib/cpp/src/thrift/concurrency/Thread.h b/lib/cpp/src/thrift/concurrency/Thread.h
index f8a3f51..bced240 100644
--- a/lib/cpp/src/thrift/concurrency/Thread.h
+++ b/lib/cpp/src/thrift/concurrency/Thread.h
@@ -39,7 +39,7 @@
class Runnable {
public:
- virtual ~Runnable(){};
+ virtual ~Runnable()= default;;
virtual void run() = 0;
/**
diff --git a/lib/cpp/src/thrift/concurrency/ThreadManager.cpp b/lib/cpp/src/thrift/concurrency/ThreadManager.cpp
index 4c7c372..c889660 100644
--- a/lib/cpp/src/thrift/concurrency/ThreadManager.cpp
+++ b/lib/cpp/src/thrift/concurrency/ThreadManager.cpp
@@ -64,19 +64,19 @@
maxMonitor_(&mutex_),
workerMonitor_(&mutex_) {}
- ~Impl() { stop(); }
+ ~Impl() override { stop(); }
- void start();
- void stop();
+ void start() override;
+ void stop() override;
- ThreadManager::STATE state() const { return state_; }
+ ThreadManager::STATE state() const override { return state_; }
- shared_ptr<ThreadFactory> threadFactory() const {
+ shared_ptr<ThreadFactory> threadFactory() const override {
Guard g(mutex_);
return threadFactory_;
}
- void threadFactory(shared_ptr<ThreadFactory> value) {
+ void threadFactory(shared_ptr<ThreadFactory> value) override {
Guard g(mutex_);
if (threadFactory_ && threadFactory_->isDetached() != value->isDetached()) {
throw InvalidArgumentException();
@@ -84,33 +84,33 @@
threadFactory_ = value;
}
- void addWorker(size_t value);
+ void addWorker(size_t value) override;
- void removeWorker(size_t value);
+ void removeWorker(size_t value) override;
- size_t idleWorkerCount() const { return idleCount_; }
+ size_t idleWorkerCount() const override { return idleCount_; }
- size_t workerCount() const {
+ size_t workerCount() const override {
Guard g(mutex_);
return workerCount_;
}
- size_t pendingTaskCount() const {
+ size_t pendingTaskCount() const override {
Guard g(mutex_);
return tasks_.size();
}
- size_t totalTaskCount() const {
+ size_t totalTaskCount() const override {
Guard g(mutex_);
return tasks_.size() + workerCount_ - idleCount_;
}
- size_t pendingTaskCountMax() const {
+ size_t pendingTaskCountMax() const override {
Guard g(mutex_);
return pendingTaskCountMax_;
}
- size_t expiredTaskCount() const {
+ size_t expiredTaskCount() const override {
Guard g(mutex_);
return expiredCount_;
}
@@ -120,17 +120,17 @@
pendingTaskCountMax_ = value;
}
- void add(shared_ptr<Runnable> value, int64_t timeout, int64_t expiration);
+ void add(shared_ptr<Runnable> value, int64_t timeout, int64_t expiration) override;
- void remove(shared_ptr<Runnable> task);
+ void remove(shared_ptr<Runnable> task) override;
- shared_ptr<Runnable> removeNextPending();
+ shared_ptr<Runnable> removeNextPending() override;
- void removeExpiredTasks() {
+ void removeExpiredTasks() override {
removeExpired(false);
}
- void setExpireCallback(ExpireCallback expireCallback);
+ void setExpireCallback(ExpireCallback expireCallback) override;
private:
/**
@@ -188,9 +188,9 @@
}
}
- ~Task() {}
+ ~Task() override = default;
- void run() {
+ void run() override {
if (state_ == EXECUTING) {
runnable_->run();
state_ = COMPLETE;
@@ -214,7 +214,7 @@
public:
Worker(ThreadManager::Impl* manager) : manager_(manager), state_(UNINITIALIZED) {}
- ~Worker() {}
+ ~Worker() override = default;
private:
bool isActive() const {
@@ -229,7 +229,7 @@
* As long as worker thread is running, pull tasks off the task queue and
* execute.
*/
- void run() {
+ void run() override {
Guard g(manager_->mutex_);
/**
@@ -352,7 +352,7 @@
workerMaxCount_ += value;
workers_.insert(newThreads.begin(), newThreads.end());
- for (std::set<shared_ptr<Thread> >::iterator ix = newThreads.begin(); ix != newThreads.end();
+ for (auto ix = newThreads.begin(); ix != newThreads.end();
++ix) {
shared_ptr<ThreadManager::Worker> worker
= dynamic_pointer_cast<ThreadManager::Worker, Runnable>((*ix)->runnable());
@@ -430,7 +430,7 @@
workerMonitor_.wait();
}
- for (std::set<shared_ptr<Thread> >::iterator ix = deadWorkers_.begin();
+ for (auto ix = deadWorkers_.begin();
ix != deadWorkers_.end();
++ix) {
@@ -497,7 +497,7 @@
"started");
}
- for (TaskQueue::iterator it = tasks_.begin(); it != tasks_.end(); ++it)
+ for (auto it = tasks_.begin(); it != tasks_.end(); ++it)
{
if ((*it)->getRunnable() == task)
{
@@ -532,7 +532,7 @@
}
auto now = std::chrono::steady_clock::now();
- for (TaskQueue::iterator it = tasks_.begin(); it != tasks_.end(); )
+ for (auto it = tasks_.begin(); it != tasks_.end(); )
{
if ((*it)->getExpireTime() && *((*it)->getExpireTime()) < now) {
if (expireCallback_) {
@@ -562,7 +562,7 @@
SimpleThreadManager(size_t workerCount = 4, size_t pendingTaskCountMax = 0)
: workerCount_(workerCount), pendingTaskCountMax_(pendingTaskCountMax) {}
- void start() {
+ void start() override {
ThreadManager::Impl::pendingTaskCountMax(pendingTaskCountMax_);
ThreadManager::Impl::start();
addWorker(workerCount_);
diff --git a/lib/cpp/src/thrift/concurrency/ThreadManager.h b/lib/cpp/src/thrift/concurrency/ThreadManager.h
index 605e363..7b202ca 100644
--- a/lib/cpp/src/thrift/concurrency/ThreadManager.h
+++ b/lib/cpp/src/thrift/concurrency/ThreadManager.h
@@ -55,12 +55,12 @@
class ThreadManager {
protected:
- ThreadManager() {}
+ ThreadManager() = default;
public:
typedef std::function<void(std::shared_ptr<Runnable>)> ExpireCallback;
- virtual ~ThreadManager() {}
+ virtual ~ThreadManager() = default;
/**
* Starts the thread manager. Verifies all attributes have been properly
diff --git a/lib/cpp/src/thrift/concurrency/TimerManager.cpp b/lib/cpp/src/thrift/concurrency/TimerManager.cpp
index edd336b..df59900 100644
--- a/lib/cpp/src/thrift/concurrency/TimerManager.cpp
+++ b/lib/cpp/src/thrift/concurrency/TimerManager.cpp
@@ -43,9 +43,9 @@
Task(shared_ptr<Runnable> runnable) : runnable_(runnable), state_(WAITING) {}
- ~Task() {}
+ ~Task() override = default;
- void run() {
+ void run() override {
if (state_ == EXECUTING) {
runnable_->run();
state_ = COMPLETE;
@@ -67,7 +67,7 @@
public:
Dispatcher(TimerManager* manager) : manager_(manager) {}
- ~Dispatcher() {}
+ ~Dispatcher() override = default;
/**
* Dispatcher entry point
@@ -75,7 +75,7 @@
* As long as dispatcher thread is running, pull tasks off the task taskMap_
* and execute.
*/
- void run() {
+ void run() override {
{
Synchronized s(manager_->monitor_);
if (manager_->state_ == TimerManager::STARTING) {
@@ -108,7 +108,7 @@
}
if (manager_->state_ == TimerManager::STARTED) {
- for (task_iterator ix = manager_->taskMap_.begin(); ix != expiredTaskEnd; ix++) {
+ for (auto ix = manager_->taskMap_.begin(); ix != expiredTaskEnd; ix++) {
shared_ptr<TimerManager::Task> task = ix->second;
expiredTasks.insert(task);
task->it_ = manager_->taskMap_.end();
@@ -121,7 +121,7 @@
}
}
- for (std::set<shared_ptr<Task> >::iterator ix = expiredTasks.begin();
+ for (auto ix = expiredTasks.begin();
ix != expiredTasks.end();
++ix) {
(*ix)->run();
@@ -221,7 +221,7 @@
taskMap_.clear();
// Remove dispatcher's reference to us.
- dispatcher_->manager_ = NULL;
+ dispatcher_->manager_ = nullptr;
}
}
@@ -280,7 +280,7 @@
throw IllegalStateException();
}
bool found = false;
- for (task_iterator ix = taskMap_.begin(); ix != taskMap_.end();) {
+ for (auto ix = taskMap_.begin(); ix != taskMap_.end();) {
if (*ix->second == task) {
found = true;
taskCount_--;
diff --git a/lib/cpp/src/thrift/processor/PeekProcessor.cpp b/lib/cpp/src/thrift/processor/PeekProcessor.cpp
index 07f6ba5..4cd58b8 100644
--- a/lib/cpp/src/thrift/processor/PeekProcessor.cpp
+++ b/lib/cpp/src/thrift/processor/PeekProcessor.cpp
@@ -31,8 +31,7 @@
memoryBuffer_.reset(new TMemoryBuffer());
targetTransport_ = memoryBuffer_;
}
-PeekProcessor::~PeekProcessor() {
-}
+PeekProcessor::~PeekProcessor() = default;
void PeekProcessor::initialize(std::shared_ptr<TProcessor> actualProcessor,
std::shared_ptr<TProtocolFactory> protocolFactory,
diff --git a/lib/cpp/src/thrift/processor/PeekProcessor.h b/lib/cpp/src/thrift/processor/PeekProcessor.h
index efac2b9..ae565fc 100644
--- a/lib/cpp/src/thrift/processor/PeekProcessor.h
+++ b/lib/cpp/src/thrift/processor/PeekProcessor.h
@@ -40,7 +40,7 @@
public:
PeekProcessor();
- virtual ~PeekProcessor();
+ ~PeekProcessor() override;
// Input here: actualProcessor - the underlying processor
// protocolFactory - the protocol factory used to wrap the memory buffer
@@ -56,9 +56,9 @@
void setTargetTransport(std::shared_ptr<apache::thrift::transport::TTransport> targetTransport);
- virtual bool process(std::shared_ptr<apache::thrift::protocol::TProtocol> in,
+ bool process(std::shared_ptr<apache::thrift::protocol::TProtocol> in,
std::shared_ptr<apache::thrift::protocol::TProtocol> out,
- void* connectionContext);
+ void* connectionContext) override;
// The following three functions can be overloaded by child classes to
// achieve desired peeking behavior
diff --git a/lib/cpp/src/thrift/processor/TMultiplexedProcessor.h b/lib/cpp/src/thrift/processor/TMultiplexedProcessor.h
index 2aa7f75..85c0aff 100644
--- a/lib/cpp/src/thrift/processor/TMultiplexedProcessor.h
+++ b/lib/cpp/src/thrift/processor/TMultiplexedProcessor.h
@@ -42,7 +42,7 @@
const int32_t _seqid)
: TProtocolDecorator(_protocol), name(_name), type(_type), seqid(_seqid) {}
- uint32_t readMessageBegin_virt(std::string& _name, TMessageType& _type, int32_t& _seqid) {
+ uint32_t readMessageBegin_virt(std::string& _name, TMessageType& _type, int32_t& _seqid) override {
_name = name;
_type = type;
@@ -149,7 +149,7 @@
*/
bool process(std::shared_ptr<protocol::TProtocol> in,
std::shared_ptr<protocol::TProtocol> out,
- void* connectionContext) {
+ void* connectionContext) override {
std::string name;
protocol::TMessageType type;
int32_t seqid;
@@ -174,7 +174,7 @@
// name and the name of the method to call.
if (tokens.size() == 2) {
// Search for a processor associated with this service name.
- services_t::iterator it = services.find(tokens[0]);
+ auto it = services.find(tokens[0]);
if (it != services.end()) {
std::shared_ptr<TProcessor> processor = it->second;
diff --git a/lib/cpp/src/thrift/protocol/TBinaryProtocol.h b/lib/cpp/src/thrift/protocol/TBinaryProtocol.h
index 9067758..6bd5fb8 100644
--- a/lib/cpp/src/thrift/protocol/TBinaryProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TBinaryProtocol.h
@@ -201,7 +201,7 @@
strict_read_(strict_read),
strict_write_(strict_write) {}
- virtual ~TBinaryProtocolFactoryT() {}
+ ~TBinaryProtocolFactoryT() override = default;
void setStringSizeLimit(int32_t string_limit) { string_limit_ = string_limit; }
@@ -212,7 +212,7 @@
strict_write_ = strict_write;
}
- std::shared_ptr<TProtocol> getProtocol(std::shared_ptr<TTransport> trans) {
+ std::shared_ptr<TProtocol> getProtocol(std::shared_ptr<TTransport> trans) override {
std::shared_ptr<Transport_> specific_trans = std::dynamic_pointer_cast<Transport_>(trans);
TProtocol* prot;
if (specific_trans) {
diff --git a/lib/cpp/src/thrift/protocol/TBinaryProtocol.tcc b/lib/cpp/src/thrift/protocol/TBinaryProtocol.tcc
index fe73992..2964f25 100644
--- a/lib/cpp/src/thrift/protocol/TBinaryProtocol.tcc
+++ b/lib/cpp/src/thrift/protocol/TBinaryProtocol.tcc
@@ -144,21 +144,21 @@
template <class Transport_, class ByteOrder_>
uint32_t TBinaryProtocolT<Transport_, ByteOrder_>::writeI16(const int16_t i16) {
- int16_t net = (int16_t)ByteOrder_::toWire16(i16);
+ auto net = (int16_t)ByteOrder_::toWire16(i16);
this->trans_->write((uint8_t*)&net, 2);
return 2;
}
template <class Transport_, class ByteOrder_>
uint32_t TBinaryProtocolT<Transport_, ByteOrder_>::writeI32(const int32_t i32) {
- int32_t net = (int32_t)ByteOrder_::toWire32(i32);
+ auto net = (int32_t)ByteOrder_::toWire32(i32);
this->trans_->write((uint8_t*)&net, 4);
return 4;
}
template <class Transport_, class ByteOrder_>
uint32_t TBinaryProtocolT<Transport_, ByteOrder_>::writeI64(const int64_t i64) {
- int64_t net = (int64_t)ByteOrder_::toWire64(i64);
+ auto net = (int64_t)ByteOrder_::toWire64(i64);
this->trans_->write((uint8_t*)&net, 8);
return 8;
}
@@ -168,7 +168,7 @@
static_assert(sizeof(double) == sizeof(uint64_t), "sizeof(double) == sizeof(uint64_t)");
static_assert(std::numeric_limits<double>::is_iec559, "std::numeric_limits<double>::is_iec559");
- uint64_t bits = bitwise_cast<uint64_t>(dub);
+ auto bits = bitwise_cast<uint64_t>(dub);
bits = ByteOrder_::toWire64(bits);
this->trans_->write((uint8_t*)&bits, 8);
return 8;
@@ -179,7 +179,7 @@
uint32_t TBinaryProtocolT<Transport_, ByteOrder_>::writeString(const StrType& str) {
if (str.size() > static_cast<size_t>((std::numeric_limits<int32_t>::max)()))
throw TProtocolException(TProtocolException::SIZE_LIMIT);
- uint32_t size = static_cast<uint32_t>(str.size());
+ auto size = static_cast<uint32_t>(str.size());
uint32_t result = writeI32((int32_t)size);
if (size > 0) {
this->trans_->write((uint8_t*)str.data(), size);
@@ -437,7 +437,7 @@
// Try to borrow first
const uint8_t* borrow_buf;
uint32_t got = size;
- if ((borrow_buf = this->trans_->borrow(NULL, &got))) {
+ if ((borrow_buf = this->trans_->borrow(nullptr, &got))) {
str.assign((const char*)borrow_buf, size);
this->trans_->consume(size);
return size;
diff --git a/lib/cpp/src/thrift/protocol/TCompactProtocol.h b/lib/cpp/src/thrift/protocol/TCompactProtocol.h
index 5cfb47d..2930aba 100644
--- a/lib/cpp/src/thrift/protocol/TCompactProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TCompactProtocol.h
@@ -79,10 +79,10 @@
trans_(trans.get()),
lastFieldId_(0),
string_limit_(0),
- string_buf_(NULL),
+ string_buf_(nullptr),
string_buf_size_(0),
container_limit_(0) {
- booleanField_.name = NULL;
+ booleanField_.name = nullptr;
boolValue_.hasBoolValue = false;
}
@@ -93,14 +93,14 @@
trans_(trans.get()),
lastFieldId_(0),
string_limit_(string_limit),
- string_buf_(NULL),
+ string_buf_(nullptr),
string_buf_size_(0),
container_limit_(container_limit) {
- booleanField_.name = NULL;
+ booleanField_.name = nullptr;
boolValue_.hasBoolValue = false;
}
- ~TCompactProtocolT() { free(string_buf_); }
+ ~TCompactProtocolT() override { free(string_buf_); }
/**
* Writing functions
@@ -233,13 +233,13 @@
TCompactProtocolFactoryT(int32_t string_limit, int32_t container_limit)
: string_limit_(string_limit), container_limit_(container_limit) {}
- virtual ~TCompactProtocolFactoryT() {}
+ ~TCompactProtocolFactoryT() override = default;
void setStringSizeLimit(int32_t string_limit) { string_limit_ = string_limit; }
void setContainerSizeLimit(int32_t container_limit) { container_limit_ = container_limit; }
- std::shared_ptr<TProtocol> getProtocol(std::shared_ptr<TTransport> trans) {
+ std::shared_ptr<TProtocol> getProtocol(std::shared_ptr<TTransport> trans) override {
std::shared_ptr<Transport_> specific_trans = std::dynamic_pointer_cast<Transport_>(trans);
TProtocol* prot;
if (specific_trans) {
diff --git a/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc b/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc
index 8efec6e..d1e342e 100644
--- a/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc
+++ b/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc
@@ -198,7 +198,7 @@
uint32_t TCompactProtocolT<Transport_>::writeBool(const bool value) {
uint32_t wsize = 0;
- if (booleanField_.name != NULL) {
+ if (booleanField_.name != nullptr) {
// we haven't written the field header yet
wsize
+= writeFieldBeginInternal(booleanField_.name,
@@ -207,7 +207,7 @@
static_cast<int8_t>(value
? detail::compact::CT_BOOLEAN_TRUE
: detail::compact::CT_BOOLEAN_FALSE));
- booleanField_.name = NULL;
+ booleanField_.name = nullptr;
} else {
// we're not part of a field, so just write the value
wsize
@@ -256,7 +256,7 @@
static_assert(sizeof(double) == sizeof(uint64_t), "sizeof(double) == sizeof(uint64_t)");
static_assert(std::numeric_limits<double>::is_iec559, "std::numeric_limits<double>::is_iec559");
- uint64_t bits = bitwise_cast<uint64_t>(dub);
+ auto bits = bitwise_cast<uint64_t>(dub);
bits = THRIFT_htolell(bits);
trans_->write((uint8_t*)&bits, 8);
return 8;
@@ -274,7 +274,7 @@
uint32_t TCompactProtocolT<Transport_>::writeBinary(const std::string& str) {
if(str.size() > (std::numeric_limits<uint32_t>::max)())
throw TProtocolException(TProtocolException::SIZE_LIMIT);
- uint32_t ssize = static_cast<uint32_t>(str.size());
+ auto ssize = static_cast<uint32_t>(str.size());
uint32_t wsize = writeVarint32(ssize) ;
// checking ssize + wsize > uint_max, but we don't want to overflow while checking for overflows.
// transforming the check to ssize > uint_max - wsize
@@ -488,7 +488,7 @@
}
// mask off the 4 MSB of the type header. it could contain a field id delta.
- int16_t modifier = (int16_t)(((uint8_t)byte & 0xf0) >> 4);
+ auto modifier = (int16_t)(((uint8_t)byte & 0xf0) >> 4);
if (modifier == 0) {
// not a delta, look ahead for the zigzag varint field id.
rsize += readI16(fieldId);
@@ -695,9 +695,9 @@
}
// Use the heap here to prevent stack overflow for v. large strings
- if (size > string_buf_size_ || string_buf_ == NULL) {
+ if (size > string_buf_size_ || string_buf_ == nullptr) {
void* new_string_buf = std::realloc(string_buf_, (uint32_t)size);
- if (new_string_buf == NULL) {
+ if (new_string_buf == nullptr) {
throw std::bad_alloc();
}
string_buf_ = (uint8_t*)new_string_buf;
@@ -735,7 +735,7 @@
const uint8_t* borrowed = trans_->borrow(buf, &buf_size);
// Fast path.
- if (borrowed != NULL) {
+ if (borrowed != nullptr) {
while (true) {
uint8_t byte = borrowed[rsize];
rsize++;
diff --git a/lib/cpp/src/thrift/protocol/TDebugProtocol.h b/lib/cpp/src/thrift/protocol/TDebugProtocol.h
index c079624..41bb0d4 100644
--- a/lib/cpp/src/thrift/protocol/TDebugProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TDebugProtocol.h
@@ -138,10 +138,10 @@
*/
class TDebugProtocolFactory : public TProtocolFactory {
public:
- TDebugProtocolFactory() {}
- virtual ~TDebugProtocolFactory() {}
+ TDebugProtocolFactory() = default;
+ ~TDebugProtocolFactory() override = default;
- std::shared_ptr<TProtocol> getProtocol(std::shared_ptr<TTransport> trans) {
+ std::shared_ptr<TProtocol> getProtocol(std::shared_ptr<TTransport> trans) override {
return std::shared_ptr<TProtocol>(new TDebugProtocol(trans));
}
};
@@ -159,7 +159,7 @@
std::string ThriftDebugString(const ThriftStruct& ts) {
using namespace apache::thrift::transport;
using namespace apache::thrift::protocol;
- TMemoryBuffer* buffer = new TMemoryBuffer;
+ auto* buffer = new TMemoryBuffer;
std::shared_ptr<TTransport> trans(buffer);
TDebugProtocol protocol(trans);
diff --git a/lib/cpp/src/thrift/protocol/THeaderProtocol.h b/lib/cpp/src/thrift/protocol/THeaderProtocol.h
index e5e2b65..0d50185 100644
--- a/lib/cpp/src/thrift/protocol/THeaderProtocol.h
+++ b/lib/cpp/src/thrift/protocol/THeaderProtocol.h
@@ -63,7 +63,7 @@
resetProtocol();
}
- ~THeaderProtocol() {}
+ ~THeaderProtocol() override = default;
/**
* Functions to work with headers by calling into THeaderTransport
@@ -190,16 +190,16 @@
class THeaderProtocolFactory : public TProtocolFactory {
public:
- virtual std::shared_ptr<TProtocol> getProtocol(std::shared_ptr<transport::TTransport> trans) {
- THeaderProtocol* headerProtocol
+ std::shared_ptr<TProtocol> getProtocol(std::shared_ptr<transport::TTransport> trans) override {
+ auto* headerProtocol
= new THeaderProtocol(trans, trans, T_BINARY_PROTOCOL);
return std::shared_ptr<TProtocol>(headerProtocol);
}
- virtual std::shared_ptr<TProtocol> getProtocol(
+ std::shared_ptr<TProtocol> getProtocol(
std::shared_ptr<transport::TTransport> inTrans,
- std::shared_ptr<transport::TTransport> outTrans) {
- THeaderProtocol* headerProtocol = new THeaderProtocol(inTrans, outTrans, T_BINARY_PROTOCOL);
+ std::shared_ptr<transport::TTransport> outTrans) override {
+ auto* headerProtocol = new THeaderProtocol(inTrans, outTrans, T_BINARY_PROTOCOL);
return std::shared_ptr<TProtocol>(headerProtocol);
}
};
diff --git a/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp b/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp
index db407f2..dcd498f 100644
--- a/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp
+++ b/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp
@@ -303,9 +303,9 @@
class TJSONContext {
public:
- TJSONContext(){};
+ TJSONContext()= default;;
- virtual ~TJSONContext(){};
+ virtual ~TJSONContext()= default;;
/**
* Write context data to the transport. Default is to do nothing.
@@ -336,7 +336,7 @@
public:
JSONPairContext() : first_(true), colon_(true) {}
- uint32_t write(TTransport& trans) {
+ uint32_t write(TTransport& trans) override {
if (first_) {
first_ = false;
colon_ = true;
@@ -348,7 +348,7 @@
}
}
- uint32_t read(TJSONProtocol::LookaheadReader& reader) {
+ uint32_t read(TJSONProtocol::LookaheadReader& reader) override {
if (first_) {
first_ = false;
colon_ = true;
@@ -361,7 +361,7 @@
}
// Numbers must be turned into strings if they are the key part of a pair
- virtual bool escapeNum() { return colon_; }
+ bool escapeNum() override { return colon_; }
private:
bool first_;
@@ -374,7 +374,7 @@
public:
JSONListContext() : first_(true) {}
- uint32_t write(TTransport& trans) {
+ uint32_t write(TTransport& trans) override {
if (first_) {
first_ = false;
return 0;
@@ -384,7 +384,7 @@
}
}
- uint32_t read(TJSONProtocol::LookaheadReader& reader) {
+ uint32_t read(TJSONProtocol::LookaheadReader& reader) override {
if (first_) {
first_ = false;
return 0;
@@ -404,8 +404,7 @@
reader_(*ptrans) {
}
-TJSONProtocol::~TJSONProtocol() {
-}
+TJSONProtocol::~TJSONProtocol() = default;
void TJSONProtocol::pushContext(std::shared_ptr<TJSONContext> c) {
contexts_.push(context_);
@@ -477,10 +476,10 @@
result += 2; // For quotes
trans_->write(&kJSONStringDelimiter, 1);
uint8_t b[4];
- const uint8_t* bytes = (const uint8_t*)str.c_str();
+ const auto* bytes = (const uint8_t*)str.c_str();
if (str.length() > (std::numeric_limits<uint32_t>::max)())
throw TProtocolException(TProtocolException::SIZE_LIMIT);
- uint32_t len = static_cast<uint32_t>(str.length());
+ auto len = static_cast<uint32_t>(str.length());
while (len >= 3) {
// Encode 3 bytes at a time
base64_encode(bytes, 3, b);
@@ -798,10 +797,10 @@
uint32_t TJSONProtocol::readJSONBase64(std::string& str) {
std::string tmp;
uint32_t result = readJSONString(tmp);
- uint8_t* b = (uint8_t*)tmp.c_str();
+ auto* b = (uint8_t*)tmp.c_str();
if (tmp.length() > (std::numeric_limits<uint32_t>::max)())
throw TProtocolException(TProtocolException::SIZE_LIMIT);
- uint32_t len = static_cast<uint32_t>(tmp.length());
+ auto len = static_cast<uint32_t>(tmp.length());
str.clear();
// Ignore padding
if (len >= 2) {
@@ -1065,7 +1064,7 @@
// readByte() must be handled properly because boost::lexical cast sees int8_t
// as a text type instead of an integer type
uint32_t TJSONProtocol::readByte(int8_t& byte) {
- int16_t tmp = (int16_t)byte;
+ auto tmp = (int16_t)byte;
uint32_t result = readJSONInteger(tmp);
assert(tmp < 256);
byte = (int8_t)tmp;
diff --git a/lib/cpp/src/thrift/protocol/TJSONProtocol.h b/lib/cpp/src/thrift/protocol/TJSONProtocol.h
index 9c2f872..020e61c 100644
--- a/lib/cpp/src/thrift/protocol/TJSONProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TJSONProtocol.h
@@ -98,7 +98,7 @@
public:
TJSONProtocol(std::shared_ptr<TTransport> ptrans);
- ~TJSONProtocol();
+ ~TJSONProtocol() override;
private:
void pushContext(std::shared_ptr<TJSONContext> c);
@@ -286,11 +286,11 @@
*/
class TJSONProtocolFactory : public TProtocolFactory {
public:
- TJSONProtocolFactory() {}
+ TJSONProtocolFactory() = default;
- virtual ~TJSONProtocolFactory() {}
+ ~TJSONProtocolFactory() override = default;
- std::shared_ptr<TProtocol> getProtocol(std::shared_ptr<TTransport> trans) {
+ std::shared_ptr<TProtocol> getProtocol(std::shared_ptr<TTransport> trans) override {
return std::shared_ptr<TProtocol>(new TJSONProtocol(trans));
}
};
@@ -308,7 +308,7 @@
std::string ThriftJSONString(const ThriftStruct& ts) {
using namespace apache::thrift::transport;
using namespace apache::thrift::protocol;
- TMemoryBuffer* buffer = new TMemoryBuffer;
+ auto* buffer = new TMemoryBuffer;
std::shared_ptr<TTransport> trans(buffer);
TJSONProtocol protocol(trans);
diff --git a/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.h b/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.h
index 94bd82e..0dc9605 100644
--- a/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.h
@@ -69,7 +69,7 @@
*/
TMultiplexedProtocol(shared_ptr<TProtocol> _protocol, const std::string& _serviceName)
: TProtocolDecorator(_protocol), serviceName(_serviceName), separator(":") {}
- virtual ~TMultiplexedProtocol() {}
+ ~TMultiplexedProtocol() override = default;
/**
* Prepends the service name to the function name, separated by TMultiplexedProtocol::SEPARATOR.
@@ -82,7 +82,7 @@
*/
uint32_t writeMessageBegin_virt(const std::string& _name,
const TMessageType _type,
- const int32_t _seqid);
+ const int32_t _seqid) override;
private:
const std::string serviceName;
diff --git a/lib/cpp/src/thrift/protocol/TProtocol.cpp b/lib/cpp/src/thrift/protocol/TProtocol.cpp
index c378aca..b460455 100644
--- a/lib/cpp/src/thrift/protocol/TProtocol.cpp
+++ b/lib/cpp/src/thrift/protocol/TProtocol.cpp
@@ -23,11 +23,11 @@
namespace thrift {
namespace protocol {
-TProtocol::~TProtocol() {}
+TProtocol::~TProtocol() = default;
uint32_t TProtocol::skip_virt(TType type) {
return ::apache::thrift::protocol::skip(*this, type);
}
-TProtocolFactory::~TProtocolFactory() {}
+TProtocolFactory::~TProtocolFactory() = default;
}}} // apache::thrift::protocol
diff --git a/lib/cpp/src/thrift/protocol/TProtocol.h b/lib/cpp/src/thrift/protocol/TProtocol.h
index bbc6816..a38660f 100644
--- a/lib/cpp/src/thrift/protocol/TProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TProtocol.h
@@ -583,7 +583,7 @@
std::shared_ptr<TTransport> ptrans_;
private:
- TProtocol() {}
+ TProtocol() = default;
uint32_t input_recursion_depth_;
uint32_t output_recursion_depth_;
uint32_t recursion_limit_;
@@ -594,7 +594,7 @@
*/
class TProtocolFactory {
public:
- TProtocolFactory() {}
+ TProtocolFactory() = default;
virtual ~TProtocolFactory();
diff --git a/lib/cpp/src/thrift/protocol/TProtocolDecorator.h b/lib/cpp/src/thrift/protocol/TProtocolDecorator.h
index 743a0f4..5258159 100644
--- a/lib/cpp/src/thrift/protocol/TProtocolDecorator.h
+++ b/lib/cpp/src/thrift/protocol/TProtocolDecorator.h
@@ -39,107 +39,107 @@
*/
class TProtocolDecorator : public TProtocol {
public:
- virtual ~TProtocolDecorator() {}
+ ~TProtocolDecorator() override = default;
// Desc: Initializes the protocol decorator object.
TProtocolDecorator(shared_ptr<TProtocol> proto)
: TProtocol(proto->getTransport()), protocol(proto) {}
- virtual uint32_t writeMessageBegin_virt(const std::string& name,
+ uint32_t writeMessageBegin_virt(const std::string& name,
const TMessageType messageType,
- const int32_t seqid) {
+ const int32_t seqid) override {
return protocol->writeMessageBegin(name, messageType, seqid);
}
- virtual uint32_t writeMessageEnd_virt() { return protocol->writeMessageEnd(); }
- virtual uint32_t writeStructBegin_virt(const char* name) {
+ uint32_t writeMessageEnd_virt() override { return protocol->writeMessageEnd(); }
+ uint32_t writeStructBegin_virt(const char* name) override {
return protocol->writeStructBegin(name);
}
- virtual uint32_t writeStructEnd_virt() { return protocol->writeStructEnd(); }
+ uint32_t writeStructEnd_virt() override { return protocol->writeStructEnd(); }
- virtual uint32_t writeFieldBegin_virt(const char* name,
+ uint32_t writeFieldBegin_virt(const char* name,
const TType fieldType,
- const int16_t fieldId) {
+ const int16_t fieldId) override {
return protocol->writeFieldBegin(name, fieldType, fieldId);
}
- virtual uint32_t writeFieldEnd_virt() { return protocol->writeFieldEnd(); }
- virtual uint32_t writeFieldStop_virt() { return protocol->writeFieldStop(); }
+ uint32_t writeFieldEnd_virt() override { return protocol->writeFieldEnd(); }
+ uint32_t writeFieldStop_virt() override { return protocol->writeFieldStop(); }
- virtual uint32_t writeMapBegin_virt(const TType keyType,
+ uint32_t writeMapBegin_virt(const TType keyType,
const TType valType,
- const uint32_t size) {
+ const uint32_t size) override {
return protocol->writeMapBegin(keyType, valType, size);
}
- virtual uint32_t writeMapEnd_virt() { return protocol->writeMapEnd(); }
+ uint32_t writeMapEnd_virt() override { return protocol->writeMapEnd(); }
- virtual uint32_t writeListBegin_virt(const TType elemType, const uint32_t size) {
+ uint32_t writeListBegin_virt(const TType elemType, const uint32_t size) override {
return protocol->writeListBegin(elemType, size);
}
- virtual uint32_t writeListEnd_virt() { return protocol->writeListEnd(); }
+ uint32_t writeListEnd_virt() override { return protocol->writeListEnd(); }
- virtual uint32_t writeSetBegin_virt(const TType elemType, const uint32_t size) {
+ uint32_t writeSetBegin_virt(const TType elemType, const uint32_t size) override {
return protocol->writeSetBegin(elemType, size);
}
- virtual uint32_t writeSetEnd_virt() { return protocol->writeSetEnd(); }
+ uint32_t writeSetEnd_virt() override { return protocol->writeSetEnd(); }
- virtual uint32_t writeBool_virt(const bool value) { return protocol->writeBool(value); }
- virtual uint32_t writeByte_virt(const int8_t byte) { return protocol->writeByte(byte); }
- virtual uint32_t writeI16_virt(const int16_t i16) { return protocol->writeI16(i16); }
- virtual uint32_t writeI32_virt(const int32_t i32) { return protocol->writeI32(i32); }
- virtual uint32_t writeI64_virt(const int64_t i64) { return protocol->writeI64(i64); }
+ uint32_t writeBool_virt(const bool value) override { return protocol->writeBool(value); }
+ uint32_t writeByte_virt(const int8_t byte) override { return protocol->writeByte(byte); }
+ uint32_t writeI16_virt(const int16_t i16) override { return protocol->writeI16(i16); }
+ uint32_t writeI32_virt(const int32_t i32) override { return protocol->writeI32(i32); }
+ uint32_t writeI64_virt(const int64_t i64) override { return protocol->writeI64(i64); }
- virtual uint32_t writeDouble_virt(const double dub) { return protocol->writeDouble(dub); }
- virtual uint32_t writeString_virt(const std::string& str) { return protocol->writeString(str); }
- virtual uint32_t writeBinary_virt(const std::string& str) { return protocol->writeBinary(str); }
+ uint32_t writeDouble_virt(const double dub) override { return protocol->writeDouble(dub); }
+ uint32_t writeString_virt(const std::string& str) override { return protocol->writeString(str); }
+ uint32_t writeBinary_virt(const std::string& str) override { return protocol->writeBinary(str); }
- virtual uint32_t readMessageBegin_virt(std::string& name,
+ uint32_t readMessageBegin_virt(std::string& name,
TMessageType& messageType,
- int32_t& seqid) {
+ int32_t& seqid) override {
return protocol->readMessageBegin(name, messageType, seqid);
}
- virtual uint32_t readMessageEnd_virt() { return protocol->readMessageEnd(); }
+ uint32_t readMessageEnd_virt() override { return protocol->readMessageEnd(); }
- virtual uint32_t readStructBegin_virt(std::string& name) {
+ uint32_t readStructBegin_virt(std::string& name) override {
return protocol->readStructBegin(name);
}
- virtual uint32_t readStructEnd_virt() { return protocol->readStructEnd(); }
+ uint32_t readStructEnd_virt() override { return protocol->readStructEnd(); }
- virtual uint32_t readFieldBegin_virt(std::string& name, TType& fieldType, int16_t& fieldId) {
+ uint32_t readFieldBegin_virt(std::string& name, TType& fieldType, int16_t& fieldId) override {
return protocol->readFieldBegin(name, fieldType, fieldId);
}
- virtual uint32_t readFieldEnd_virt() { return protocol->readFieldEnd(); }
+ uint32_t readFieldEnd_virt() override { return protocol->readFieldEnd(); }
- virtual uint32_t readMapBegin_virt(TType& keyType, TType& valType, uint32_t& size) {
+ uint32_t readMapBegin_virt(TType& keyType, TType& valType, uint32_t& size) override {
return protocol->readMapBegin(keyType, valType, size);
}
- virtual uint32_t readMapEnd_virt() { return protocol->readMapEnd(); }
+ uint32_t readMapEnd_virt() override { return protocol->readMapEnd(); }
- virtual uint32_t readListBegin_virt(TType& elemType, uint32_t& size) {
+ uint32_t readListBegin_virt(TType& elemType, uint32_t& size) override {
return protocol->readListBegin(elemType, size);
}
- virtual uint32_t readListEnd_virt() { return protocol->readListEnd(); }
+ uint32_t readListEnd_virt() override { return protocol->readListEnd(); }
- virtual uint32_t readSetBegin_virt(TType& elemType, uint32_t& size) {
+ uint32_t readSetBegin_virt(TType& elemType, uint32_t& size) override {
return protocol->readSetBegin(elemType, size);
}
- virtual uint32_t readSetEnd_virt() { return protocol->readSetEnd(); }
+ uint32_t readSetEnd_virt() override { return protocol->readSetEnd(); }
- virtual uint32_t readBool_virt(bool& value) { return protocol->readBool(value); }
- virtual uint32_t readBool_virt(std::vector<bool>::reference value) {
+ uint32_t readBool_virt(bool& value) override { return protocol->readBool(value); }
+ uint32_t readBool_virt(std::vector<bool>::reference value) override {
return protocol->readBool(value);
}
- virtual uint32_t readByte_virt(int8_t& byte) { return protocol->readByte(byte); }
+ uint32_t readByte_virt(int8_t& byte) override { return protocol->readByte(byte); }
- virtual uint32_t readI16_virt(int16_t& i16) { return protocol->readI16(i16); }
- virtual uint32_t readI32_virt(int32_t& i32) { return protocol->readI32(i32); }
- virtual uint32_t readI64_virt(int64_t& i64) { return protocol->readI64(i64); }
+ uint32_t readI16_virt(int16_t& i16) override { return protocol->readI16(i16); }
+ uint32_t readI32_virt(int32_t& i32) override { return protocol->readI32(i32); }
+ uint32_t readI64_virt(int64_t& i64) override { return protocol->readI64(i64); }
- virtual uint32_t readDouble_virt(double& dub) { return protocol->readDouble(dub); }
+ uint32_t readDouble_virt(double& dub) override { return protocol->readDouble(dub); }
- virtual uint32_t readString_virt(std::string& str) { return protocol->readString(str); }
- virtual uint32_t readBinary_virt(std::string& str) { return protocol->readBinary(str); }
+ uint32_t readString_virt(std::string& str) override { return protocol->readString(str); }
+ uint32_t readBinary_virt(std::string& str) override { return protocol->readBinary(str); }
private:
shared_ptr<TProtocol> protocol;
diff --git a/lib/cpp/src/thrift/protocol/TProtocolException.h b/lib/cpp/src/thrift/protocol/TProtocolException.h
index 10178e1..3d44365 100644
--- a/lib/cpp/src/thrift/protocol/TProtocolException.h
+++ b/lib/cpp/src/thrift/protocol/TProtocolException.h
@@ -59,7 +59,7 @@
TProtocolException(TProtocolExceptionType type, const std::string& message)
: apache::thrift::TException(message), type_(type) {}
- virtual ~TProtocolException() noexcept {}
+ ~TProtocolException() noexcept override = default;
/**
* Returns an error code that provides information about the type of error
@@ -69,7 +69,7 @@
*/
TProtocolExceptionType getType() const { return type_; }
- virtual const char* what() const noexcept {
+ const char* what() const noexcept override {
if (message_.empty()) {
switch (type_) {
case UNKNOWN:
diff --git a/lib/cpp/src/thrift/protocol/TVirtualProtocol.h b/lib/cpp/src/thrift/protocol/TVirtualProtocol.h
index 4eea579..b7fe929 100644
--- a/lib/cpp/src/thrift/protocol/TVirtualProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TVirtualProtocol.h
@@ -315,81 +315,81 @@
* Writing functions.
*/
- virtual uint32_t writeMessageBegin_virt(const std::string& name,
+ uint32_t writeMessageBegin_virt(const std::string& name,
const TMessageType messageType,
- const int32_t seqid) {
+ const int32_t seqid) override {
return static_cast<Protocol_*>(this)->writeMessageBegin(name, messageType, seqid);
}
- virtual uint32_t writeMessageEnd_virt() {
+ uint32_t writeMessageEnd_virt() override {
return static_cast<Protocol_*>(this)->writeMessageEnd();
}
- virtual uint32_t writeStructBegin_virt(const char* name) {
+ uint32_t writeStructBegin_virt(const char* name) override {
return static_cast<Protocol_*>(this)->writeStructBegin(name);
}
- virtual uint32_t writeStructEnd_virt() { return static_cast<Protocol_*>(this)->writeStructEnd(); }
+ uint32_t writeStructEnd_virt() override { return static_cast<Protocol_*>(this)->writeStructEnd(); }
- virtual uint32_t writeFieldBegin_virt(const char* name,
+ uint32_t writeFieldBegin_virt(const char* name,
const TType fieldType,
- const int16_t fieldId) {
+ const int16_t fieldId) override {
return static_cast<Protocol_*>(this)->writeFieldBegin(name, fieldType, fieldId);
}
- virtual uint32_t writeFieldEnd_virt() { return static_cast<Protocol_*>(this)->writeFieldEnd(); }
+ uint32_t writeFieldEnd_virt() override { return static_cast<Protocol_*>(this)->writeFieldEnd(); }
- virtual uint32_t writeFieldStop_virt() { return static_cast<Protocol_*>(this)->writeFieldStop(); }
+ uint32_t writeFieldStop_virt() override { return static_cast<Protocol_*>(this)->writeFieldStop(); }
- virtual uint32_t writeMapBegin_virt(const TType keyType,
+ uint32_t writeMapBegin_virt(const TType keyType,
const TType valType,
- const uint32_t size) {
+ const uint32_t size) override {
return static_cast<Protocol_*>(this)->writeMapBegin(keyType, valType, size);
}
- virtual uint32_t writeMapEnd_virt() { return static_cast<Protocol_*>(this)->writeMapEnd(); }
+ uint32_t writeMapEnd_virt() override { return static_cast<Protocol_*>(this)->writeMapEnd(); }
- virtual uint32_t writeListBegin_virt(const TType elemType, const uint32_t size) {
+ uint32_t writeListBegin_virt(const TType elemType, const uint32_t size) override {
return static_cast<Protocol_*>(this)->writeListBegin(elemType, size);
}
- virtual uint32_t writeListEnd_virt() { return static_cast<Protocol_*>(this)->writeListEnd(); }
+ uint32_t writeListEnd_virt() override { return static_cast<Protocol_*>(this)->writeListEnd(); }
- virtual uint32_t writeSetBegin_virt(const TType elemType, const uint32_t size) {
+ uint32_t writeSetBegin_virt(const TType elemType, const uint32_t size) override {
return static_cast<Protocol_*>(this)->writeSetBegin(elemType, size);
}
- virtual uint32_t writeSetEnd_virt() { return static_cast<Protocol_*>(this)->writeSetEnd(); }
+ uint32_t writeSetEnd_virt() override { return static_cast<Protocol_*>(this)->writeSetEnd(); }
- virtual uint32_t writeBool_virt(const bool value) {
+ uint32_t writeBool_virt(const bool value) override {
return static_cast<Protocol_*>(this)->writeBool(value);
}
- virtual uint32_t writeByte_virt(const int8_t byte) {
+ uint32_t writeByte_virt(const int8_t byte) override {
return static_cast<Protocol_*>(this)->writeByte(byte);
}
- virtual uint32_t writeI16_virt(const int16_t i16) {
+ uint32_t writeI16_virt(const int16_t i16) override {
return static_cast<Protocol_*>(this)->writeI16(i16);
}
- virtual uint32_t writeI32_virt(const int32_t i32) {
+ uint32_t writeI32_virt(const int32_t i32) override {
return static_cast<Protocol_*>(this)->writeI32(i32);
}
- virtual uint32_t writeI64_virt(const int64_t i64) {
+ uint32_t writeI64_virt(const int64_t i64) override {
return static_cast<Protocol_*>(this)->writeI64(i64);
}
- virtual uint32_t writeDouble_virt(const double dub) {
+ uint32_t writeDouble_virt(const double dub) override {
return static_cast<Protocol_*>(this)->writeDouble(dub);
}
- virtual uint32_t writeString_virt(const std::string& str) {
+ uint32_t writeString_virt(const std::string& str) override {
return static_cast<Protocol_*>(this)->writeString(str);
}
- virtual uint32_t writeBinary_virt(const std::string& str) {
+ uint32_t writeBinary_virt(const std::string& str) override {
return static_cast<Protocol_*>(this)->writeBinary(str);
}
@@ -397,81 +397,81 @@
* Reading functions
*/
- virtual uint32_t readMessageBegin_virt(std::string& name,
+ uint32_t readMessageBegin_virt(std::string& name,
TMessageType& messageType,
- int32_t& seqid) {
+ int32_t& seqid) override {
return static_cast<Protocol_*>(this)->readMessageBegin(name, messageType, seqid);
}
- virtual uint32_t readMessageEnd_virt() { return static_cast<Protocol_*>(this)->readMessageEnd(); }
+ uint32_t readMessageEnd_virt() override { return static_cast<Protocol_*>(this)->readMessageEnd(); }
- virtual uint32_t readStructBegin_virt(std::string& name) {
+ uint32_t readStructBegin_virt(std::string& name) override {
return static_cast<Protocol_*>(this)->readStructBegin(name);
}
- virtual uint32_t readStructEnd_virt() { return static_cast<Protocol_*>(this)->readStructEnd(); }
+ uint32_t readStructEnd_virt() override { return static_cast<Protocol_*>(this)->readStructEnd(); }
- virtual uint32_t readFieldBegin_virt(std::string& name, TType& fieldType, int16_t& fieldId) {
+ uint32_t readFieldBegin_virt(std::string& name, TType& fieldType, int16_t& fieldId) override {
return static_cast<Protocol_*>(this)->readFieldBegin(name, fieldType, fieldId);
}
- virtual uint32_t readFieldEnd_virt() { return static_cast<Protocol_*>(this)->readFieldEnd(); }
+ uint32_t readFieldEnd_virt() override { return static_cast<Protocol_*>(this)->readFieldEnd(); }
- virtual uint32_t readMapBegin_virt(TType& keyType, TType& valType, uint32_t& size) {
+ uint32_t readMapBegin_virt(TType& keyType, TType& valType, uint32_t& size) override {
return static_cast<Protocol_*>(this)->readMapBegin(keyType, valType, size);
}
- virtual uint32_t readMapEnd_virt() { return static_cast<Protocol_*>(this)->readMapEnd(); }
+ uint32_t readMapEnd_virt() override { return static_cast<Protocol_*>(this)->readMapEnd(); }
- virtual uint32_t readListBegin_virt(TType& elemType, uint32_t& size) {
+ uint32_t readListBegin_virt(TType& elemType, uint32_t& size) override {
return static_cast<Protocol_*>(this)->readListBegin(elemType, size);
}
- virtual uint32_t readListEnd_virt() { return static_cast<Protocol_*>(this)->readListEnd(); }
+ uint32_t readListEnd_virt() override { return static_cast<Protocol_*>(this)->readListEnd(); }
- virtual uint32_t readSetBegin_virt(TType& elemType, uint32_t& size) {
+ uint32_t readSetBegin_virt(TType& elemType, uint32_t& size) override {
return static_cast<Protocol_*>(this)->readSetBegin(elemType, size);
}
- virtual uint32_t readSetEnd_virt() { return static_cast<Protocol_*>(this)->readSetEnd(); }
+ uint32_t readSetEnd_virt() override { return static_cast<Protocol_*>(this)->readSetEnd(); }
- virtual uint32_t readBool_virt(bool& value) {
+ uint32_t readBool_virt(bool& value) override {
return static_cast<Protocol_*>(this)->readBool(value);
}
- virtual uint32_t readBool_virt(std::vector<bool>::reference value) {
+ uint32_t readBool_virt(std::vector<bool>::reference value) override {
return static_cast<Protocol_*>(this)->readBool(value);
}
- virtual uint32_t readByte_virt(int8_t& byte) {
+ uint32_t readByte_virt(int8_t& byte) override {
return static_cast<Protocol_*>(this)->readByte(byte);
}
- virtual uint32_t readI16_virt(int16_t& i16) {
+ uint32_t readI16_virt(int16_t& i16) override {
return static_cast<Protocol_*>(this)->readI16(i16);
}
- virtual uint32_t readI32_virt(int32_t& i32) {
+ uint32_t readI32_virt(int32_t& i32) override {
return static_cast<Protocol_*>(this)->readI32(i32);
}
- virtual uint32_t readI64_virt(int64_t& i64) {
+ uint32_t readI64_virt(int64_t& i64) override {
return static_cast<Protocol_*>(this)->readI64(i64);
}
- virtual uint32_t readDouble_virt(double& dub) {
+ uint32_t readDouble_virt(double& dub) override {
return static_cast<Protocol_*>(this)->readDouble(dub);
}
- virtual uint32_t readString_virt(std::string& str) {
+ uint32_t readString_virt(std::string& str) override {
return static_cast<Protocol_*>(this)->readString(str);
}
- virtual uint32_t readBinary_virt(std::string& str) {
+ uint32_t readBinary_virt(std::string& str) override {
return static_cast<Protocol_*>(this)->readBinary(str);
}
- virtual uint32_t skip_virt(TType type) { return static_cast<Protocol_*>(this)->skip(type); }
+ uint32_t skip_virt(TType type) override { return static_cast<Protocol_*>(this)->skip(type); }
/*
* Provide a default skip() implementation that uses non-virtual read
@@ -484,7 +484,7 @@
* correct parent implementation, if desired.
*/
uint32_t skip(TType type) {
- Protocol_* const prot = static_cast<Protocol_*>(this);
+ auto* const prot = static_cast<Protocol_*>(this);
return ::apache::thrift::protocol::skip(*prot, type);
}
diff --git a/lib/cpp/src/thrift/qt/TQIODeviceTransport.cpp b/lib/cpp/src/thrift/qt/TQIODeviceTransport.cpp
index f77c993..78c3b39 100644
--- a/lib/cpp/src/thrift/qt/TQIODeviceTransport.cpp
+++ b/lib/cpp/src/thrift/qt/TQIODeviceTransport.cpp
@@ -157,7 +157,7 @@
uint8_t* TQIODeviceTransport::borrow(uint8_t* buf, uint32_t* len) {
(void)buf;
(void)len;
- return NULL;
+ return nullptr;
}
void TQIODeviceTransport::consume(uint32_t len) {
diff --git a/lib/cpp/src/thrift/qt/TQIODeviceTransport.h b/lib/cpp/src/thrift/qt/TQIODeviceTransport.h
index 91ce8d5..e0cdd18 100644
--- a/lib/cpp/src/thrift/qt/TQIODeviceTransport.h
+++ b/lib/cpp/src/thrift/qt/TQIODeviceTransport.h
@@ -37,12 +37,12 @@
: public apache::thrift::transport::TVirtualTransport<TQIODeviceTransport> {
public:
explicit TQIODeviceTransport(std::shared_ptr<QIODevice> dev);
- virtual ~TQIODeviceTransport();
+ ~TQIODeviceTransport() override;
- void open();
+ void open() override;
bool isOpen();
- bool peek();
- void close();
+ bool peek() override;
+ void close() override;
uint32_t readAll(uint8_t* buf, uint32_t len);
uint32_t read(uint8_t* buf, uint32_t len);
@@ -50,7 +50,7 @@
void write(const uint8_t* buf, uint32_t len);
uint32_t write_partial(const uint8_t* buf, uint32_t len);
- void flush();
+ void flush() override;
uint8_t* borrow(uint8_t* buf, uint32_t* len);
void consume(uint32_t len);
diff --git a/lib/cpp/src/thrift/qt/TQTcpServer.cpp b/lib/cpp/src/thrift/qt/TQTcpServer.cpp
index 99aad07..bd39893 100644
--- a/lib/cpp/src/thrift/qt/TQTcpServer.cpp
+++ b/lib/cpp/src/thrift/qt/TQTcpServer.cpp
@@ -67,8 +67,7 @@
connect(server.get(), SIGNAL(newConnection()), SLOT(processIncoming()));
}
-TQTcpServer::~TQTcpServer() {
-}
+TQTcpServer::~TQTcpServer() = default;
void TQTcpServer::processIncoming() {
while (server_->hasPendingConnections()) {
@@ -100,7 +99,7 @@
}
void TQTcpServer::beginDecode() {
- QTcpSocket* connection(qobject_cast<QTcpSocket*>(sender()));
+ auto* connection(qobject_cast<QTcpSocket*>(sender()));
Q_ASSERT(connection);
if (ctxMap_.find(connection) == ctxMap_.end()) {
@@ -125,7 +124,7 @@
}
void TQTcpServer::socketClosed() {
- QTcpSocket* connection(qobject_cast<QTcpSocket*>(sender()));
+ auto* connection(qobject_cast<QTcpSocket*>(sender()));
Q_ASSERT(connection);
scheduleDeleteConnectionContext(connection);
}
diff --git a/lib/cpp/src/thrift/qt/TQTcpServer.h b/lib/cpp/src/thrift/qt/TQTcpServer.h
index 8e3fe3a..25994ab 100644
--- a/lib/cpp/src/thrift/qt/TQTcpServer.h
+++ b/lib/cpp/src/thrift/qt/TQTcpServer.h
@@ -50,8 +50,8 @@
TQTcpServer(std::shared_ptr<QTcpServer> server,
std::shared_ptr<TAsyncProcessor> processor,
std::shared_ptr<apache::thrift::protocol::TProtocolFactory> protocolFactory,
- QObject* parent = NULL);
- virtual ~TQTcpServer();
+ QObject* parent = nullptr);
+ ~TQTcpServer() override;
private Q_SLOTS:
void processIncoming();
diff --git a/lib/cpp/src/thrift/server/TConnectedClient.cpp b/lib/cpp/src/thrift/server/TConnectedClient.cpp
index acdaa77..9a78e3e 100644
--- a/lib/cpp/src/thrift/server/TConnectedClient.cpp
+++ b/lib/cpp/src/thrift/server/TConnectedClient.cpp
@@ -42,11 +42,10 @@
outputProtocol_(outputProtocol),
eventHandler_(eventHandler),
client_(client),
- opaqueContext_(0) {
+ opaqueContext_(nullptr) {
}
-TConnectedClient::~TConnectedClient() {
-}
+TConnectedClient::~TConnectedClient() = default;
void TConnectedClient::run() {
if (eventHandler_) {
diff --git a/lib/cpp/src/thrift/server/TConnectedClient.h b/lib/cpp/src/thrift/server/TConnectedClient.h
index 19e70c1..071571a 100644
--- a/lib/cpp/src/thrift/server/TConnectedClient.h
+++ b/lib/cpp/src/thrift/server/TConnectedClient.h
@@ -58,7 +58,7 @@
/**
* Destructor.
*/
- virtual ~TConnectedClient();
+ ~TConnectedClient() override;
/**
* Drive the client until it is done.
@@ -76,7 +76,7 @@
* handle unexpected exceptions by logging
* cleanup()
*/
- virtual void run() /* override */;
+ void run() override /* override */;
protected:
/**
diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.cpp b/lib/cpp/src/thrift/server/TNonblockingServer.cpp
index bee3e3b..4e62324 100644
--- a/lib/cpp/src/thrift/server/TNonblockingServer.cpp
+++ b/lib/cpp/src/thrift/server/TNonblockingServer.cpp
@@ -215,7 +215,7 @@
/// Constructor
TConnection(std::shared_ptr<TSocket> socket,
TNonblockingIOThread* ioThread) {
- readBuffer_ = NULL;
+ readBuffer_ = nullptr;
readBufferSize_ = 0;
ioThread_ = ioThread;
@@ -327,7 +327,7 @@
serverEventHandler_(connection_->getServerEventHandler()),
connectionContext_(connection_->getConnectionContext()) {}
- void run() {
+ void run() override {
try {
for (;;) {
if (serverEventHandler_) {
@@ -380,7 +380,7 @@
readBufferPos_ = 0;
readWant_ = 0;
- writeBuffer_ = NULL;
+ writeBuffer_ = nullptr;
writeBufferSize_ = 0;
writeBufferPos_ = 0;
largestWriteBufferSize_ = 0;
@@ -407,7 +407,7 @@
if (serverEventHandler_) {
connectionContext_ = serverEventHandler_->createContext(inputProtocol_, outputProtocol_);
} else {
- connectionContext_ = NULL;
+ connectionContext_ = nullptr;
}
// Get the processor
@@ -570,7 +570,7 @@
// Currently if there is no output protocol factory,
// we assume header transport (without having to create
// a new transport and check)
- return getOutputProtocolFactory() == NULL;
+ return getOutputProtocolFactory() == nullptr;
}
/**
@@ -687,7 +687,7 @@
socketState_ = SOCKET_SEND;
// Put the frame size into the write buffer
- int32_t frameSize = (int32_t)htonl(writeBufferSize_ - 4);
+ auto frameSize = (int32_t)htonl(writeBufferSize_ - 4);
memcpy(writeBuffer_, &frameSize, 4);
// Socket into write mode
@@ -720,7 +720,7 @@
case APP_INIT:
// Clear write buffer variables
- writeBuffer_ = NULL;
+ writeBuffer_ = nullptr;
writeBufferPos_ = 0;
writeBufferSize_ = 0;
@@ -749,8 +749,8 @@
newSize *= 2;
}
- uint8_t* newBuffer = (uint8_t*)std::realloc(readBuffer_, newSize);
- if (newBuffer == NULL) {
+ auto* newBuffer = (uint8_t*)std::realloc(readBuffer_, newSize);
+ if (newBuffer == nullptr) {
// nothing else to be done...
throw std::bad_alloc();
}
@@ -829,7 +829,7 @@
event_base_set(ioThread_->getEventBase(), &event_);
// Add the event
- if (event_add(&event_, 0) == -1) {
+ if (event_add(&event_, nullptr) == -1) {
GlobalOutput.perror("TConnection::setFlags(): could not event_add", THRIFT_GET_SOCKET_ERROR);
}
}
@@ -843,7 +843,7 @@
if (serverEventHandler_) {
serverEventHandler_->deleteContext(connectionContext_, inputProtocol_, outputProtocol_);
}
- ioThread_ = NULL;
+ ioThread_ = nullptr;
// Close the socket
tSocket_->close();
@@ -862,7 +862,7 @@
void TNonblockingServer::TConnection::checkIdleBufferMemLimit(size_t readLimit, size_t writeLimit) {
if (readLimit > 0 && readBufferSize_ > readLimit) {
free(readBuffer_);
- readBuffer_ = NULL;
+ readBuffer_ = nullptr;
readBufferSize_ = 0;
}
@@ -910,7 +910,7 @@
TNonblockingIOThread* ioThread = ioThreads_[selectedThreadIdx].get();
// Check the connection stack to see if we can re-use
- TConnection* result = NULL;
+ TConnection* result = nullptr;
if (connectionStack_.empty()) {
result = new TConnection(socket, ioThread);
++numTConnections_;
@@ -979,7 +979,7 @@
TConnection* clientConnection = createConnection(clientSocket);
// Fail fast if we could not create a TConnection object
- if (clientConnection == NULL) {
+ if (clientConnection == nullptr) {
GlobalOutput.printf("thriftServerEventHandler: failed TConnection factory");
clientSocket->close();
return;
@@ -1143,7 +1143,7 @@
void TNonblockingServer::serve() {
if (ioThreads_.empty())
- registerEvents(NULL);
+ registerEvents(nullptr);
// Run the primary (listener) IO thread loop in our main thread; this will
// only return when the server is shutting down.
@@ -1164,7 +1164,7 @@
number_(number),
listenSocket_(listenSocket),
useHighPriority_(useHighPriority),
- eventBase_(NULL),
+ eventBase_(nullptr),
ownEventBase_(false) {
notificationPipeFDs_[0] = -1;
notificationPipeFDs_[1] = -1;
@@ -1231,9 +1231,9 @@
void TNonblockingIOThread::registerEvents() {
threadId_ = Thread::get_current();
- assert(eventBase_ == 0);
+ assert(eventBase_ == nullptr);
eventBase_ = getServer()->getUserEventBase();
- if (eventBase_ == NULL) {
+ if (eventBase_ == nullptr) {
eventBase_ = event_base_new();
ownEventBase_ = true;
}
@@ -1255,7 +1255,7 @@
event_base_set(eventBase_, &serverEvent_);
// Add the event and start up the server
- if (-1 == event_add(&serverEvent_, 0)) {
+ if (-1 == event_add(&serverEvent_, nullptr)) {
throw TException(
"TNonblockingServer::serve(): "
"event_add() failed on server listen event");
@@ -1276,7 +1276,7 @@
event_base_set(eventBase_, ¬ificationEvent_);
// Add the event and start up the server
- if (-1 == event_add(¬ificationEvent_, 0)) {
+ if (-1 == event_add(¬ificationEvent_, nullptr)) {
throw TException(
"TNonblockingServer::serve(): "
"event_add() failed on task-done notification event");
@@ -1368,16 +1368,16 @@
/* static */
void TNonblockingIOThread::notifyHandler(evutil_socket_t fd, short which, void* v) {
- TNonblockingIOThread* ioThread = (TNonblockingIOThread*)v;
+ auto* ioThread = (TNonblockingIOThread*)v;
assert(ioThread);
(void)which;
while (true) {
- TNonblockingServer::TConnection* connection = 0;
+ TNonblockingServer::TConnection* connection = nullptr;
const int kSize = sizeof(connection);
long nBytes = recv(fd, cast_sockopt(&connection), kSize, 0);
if (nBytes == kSize) {
- if (connection == NULL) {
+ if (connection == nullptr) {
// this is the command to stop our thread, exit the handler!
ioThread->breakLoop(false);
return;
@@ -1420,7 +1420,7 @@
// same thread, this means the thread can't be blocking in the event
// loop either.
if (!Thread::is_current(threadId_)) {
- notify(NULL);
+ notify(nullptr);
} else {
// cause the loop to stop ASAP - even if it has things to do in it
event_base_loopbreak(eventBase_);
@@ -1457,14 +1457,14 @@
}
void TNonblockingIOThread::run() {
- if (eventBase_ == NULL) {
+ if (eventBase_ == nullptr) {
registerEvents();
}
if (useHighPriority_) {
setCurrentThreadHighPriority(true);
}
- if (eventBase_ != NULL)
+ if (eventBase_ != nullptr)
{
GlobalOutput.printf("TNonblockingServer: IO thread #%d entering loop...", number_);
// Run libevent engine, never returns, invokes calls to eventHandler
diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.h b/lib/cpp/src/thrift/server/TNonblockingServer.h
index 2c2389c..82bc375 100644
--- a/lib/cpp/src/thrift/server/TNonblockingServer.h
+++ b/lib/cpp/src/thrift/server/TNonblockingServer.h
@@ -280,7 +280,7 @@
numIOThreads_ = DEFAULT_IO_THREADS;
nextIOThread_ = 0;
useHighPriorityIOThreads_ = false;
- userEventBase_ = NULL;
+ userEventBase_ = nullptr;
threadPoolProcessing_ = false;
numTConnections_ = 0;
numActiveProcessors_ = 0;
@@ -376,7 +376,7 @@
setThreadManager(threadManager);
}
- ~TNonblockingServer();
+ ~TNonblockingServer() override;
void setThreadManager(std::shared_ptr<ThreadManager> threadManager);
@@ -669,12 +669,12 @@
* Main workhorse function, starts up the server listening on a port and
* loops over the libevent handler.
*/
- void serve();
+ void serve() override;
/**
* Causes the server to terminate gracefully (can be called from any thread).
*/
- void stop();
+ void stop() override;
/// Creates a socket to listen on and binds it to the local port.
void createAndListenOnSocket();
@@ -741,7 +741,7 @@
THRIFT_SOCKET listenSocket,
bool useHighPriority);
- ~TNonblockingIOThread();
+ ~TNonblockingIOThread() override;
// Returns the event-base for this thread.
event_base* getEventBase() const { return eventBase_; }
@@ -772,7 +772,7 @@
bool notify(TNonblockingServer::TConnection* conn);
// Enters the event loop and does not return until a call to stop().
- virtual void run();
+ void run() override;
// Exits the event loop as soon as possible.
void stop();
diff --git a/lib/cpp/src/thrift/server/TServer.h b/lib/cpp/src/thrift/server/TServer.h
index 3c6d818..d2eabde 100644
--- a/lib/cpp/src/thrift/server/TServer.h
+++ b/lib/cpp/src/thrift/server/TServer.h
@@ -48,7 +48,7 @@
*/
class TServerEventHandler {
public:
- virtual ~TServerEventHandler() {}
+ virtual ~TServerEventHandler() = default;
/**
* Called before the server begins.
@@ -62,7 +62,7 @@
std::shared_ptr<TProtocol> output) {
(void)input;
(void)output;
- return NULL;
+ return nullptr;
}
/**
@@ -89,7 +89,7 @@
/**
* Prevent direct instantiation.
*/
- TServerEventHandler() {}
+ TServerEventHandler() = default;
};
/**
@@ -98,14 +98,14 @@
*/
class TServer : public concurrency::Runnable {
public:
- virtual ~TServer() {}
+ ~TServer() override = default;
virtual void serve() = 0;
virtual void stop() {}
// Allows running the server as a Runnable thread
- virtual void run() { serve(); }
+ void run() override { serve(); }
std::shared_ptr<TProcessorFactory> getProcessorFactory() { return processorFactory_; }
diff --git a/lib/cpp/src/thrift/server/TServerFramework.cpp b/lib/cpp/src/thrift/server/TServerFramework.cpp
index cbeaa24..35f3b25 100644
--- a/lib/cpp/src/thrift/server/TServerFramework.cpp
+++ b/lib/cpp/src/thrift/server/TServerFramework.cpp
@@ -91,8 +91,7 @@
limit_(INT64_MAX) {
}
-TServerFramework::~TServerFramework() {
-}
+TServerFramework::~TServerFramework() = default;
template <typename T>
static void releaseOneDescriptor(const string& name, T& pTransport) {
diff --git a/lib/cpp/src/thrift/server/TServerFramework.h b/lib/cpp/src/thrift/server/TServerFramework.h
index eaacce5..dac79ef 100644
--- a/lib/cpp/src/thrift/server/TServerFramework.h
+++ b/lib/cpp/src/thrift/server/TServerFramework.h
@@ -75,7 +75,7 @@
const std::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory,
const std::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory);
- virtual ~TServerFramework();
+ ~TServerFramework() override;
/**
* Accept clients from the TServerTransport and add them for processing.
@@ -84,12 +84,12 @@
* Post-conditions (return guarantees):
* The serverTransport will be closed.
*/
- virtual void serve();
+ void serve() override;
/**
* Interrupt serve() so that it meets post-conditions and returns.
*/
- virtual void stop();
+ void stop() override;
/**
* Get the concurrent client limit.
diff --git a/lib/cpp/src/thrift/server/TSimpleServer.cpp b/lib/cpp/src/thrift/server/TSimpleServer.cpp
index 716234d..ba7a183 100644
--- a/lib/cpp/src/thrift/server/TSimpleServer.cpp
+++ b/lib/cpp/src/thrift/server/TSimpleServer.cpp
@@ -78,8 +78,7 @@
TServerFramework::setConcurrentClientLimit(1);
}
-TSimpleServer::~TSimpleServer() {
-}
+TSimpleServer::~TSimpleServer() = default;
/**
* The main body of customized implementation for TSimpleServer is quite simple:
diff --git a/lib/cpp/src/thrift/server/TSimpleServer.h b/lib/cpp/src/thrift/server/TSimpleServer.h
index 4549225..3afeb79 100644
--- a/lib/cpp/src/thrift/server/TSimpleServer.h
+++ b/lib/cpp/src/thrift/server/TSimpleServer.h
@@ -61,14 +61,14 @@
const std::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory,
const std::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory);
- virtual ~TSimpleServer();
+ ~TSimpleServer() override;
protected:
- virtual void onClientConnected(const std::shared_ptr<TConnectedClient>& pClient) /* override */;
- virtual void onClientDisconnected(TConnectedClient* pClient) /* override */;
+ void onClientConnected(const std::shared_ptr<TConnectedClient>& pClient) override /* override */;
+ void onClientDisconnected(TConnectedClient* pClient) override /* override */;
private:
- void setConcurrentClientLimit(int64_t newLimit); // hide
+ void setConcurrentClientLimit(int64_t newLimit) override; // hide
};
}
}
diff --git a/lib/cpp/src/thrift/server/TThreadPoolServer.cpp b/lib/cpp/src/thrift/server/TThreadPoolServer.cpp
index ee345a9..121dde3 100644
--- a/lib/cpp/src/thrift/server/TThreadPoolServer.cpp
+++ b/lib/cpp/src/thrift/server/TThreadPoolServer.cpp
@@ -91,8 +91,7 @@
taskExpiration_(0) {
}
-TThreadPoolServer::~TThreadPoolServer() {
-}
+TThreadPoolServer::~TThreadPoolServer() = default;
void TThreadPoolServer::serve() {
TServerFramework::serve();
diff --git a/lib/cpp/src/thrift/server/TThreadPoolServer.h b/lib/cpp/src/thrift/server/TThreadPoolServer.h
index 121998c..a9411b8 100644
--- a/lib/cpp/src/thrift/server/TThreadPoolServer.h
+++ b/lib/cpp/src/thrift/server/TThreadPoolServer.h
@@ -69,13 +69,13 @@
const std::shared_ptr<apache::thrift::concurrency::ThreadManager>& threadManager
= apache::thrift::concurrency::ThreadManager::newSimpleThreadManager());
- virtual ~TThreadPoolServer();
+ ~TThreadPoolServer() override;
/**
* Post-conditions (return guarantees):
* There will be no clients connected.
*/
- virtual void serve();
+ void serve() override;
virtual int64_t getTimeout() const;
virtual void setTimeout(int64_t value);
@@ -86,8 +86,8 @@
virtual std::shared_ptr<apache::thrift::concurrency::ThreadManager> getThreadManager() const;
protected:
- virtual void onClientConnected(const std::shared_ptr<TConnectedClient>& pClient) /* override */;
- virtual void onClientDisconnected(TConnectedClient* pClient) /* override */;
+ void onClientConnected(const std::shared_ptr<TConnectedClient>& pClient) override /* override */;
+ void onClientDisconnected(TConnectedClient* pClient) override /* override */;
std::shared_ptr<apache::thrift::concurrency::ThreadManager> threadManager_;
std::atomic<int64_t> timeout_;
diff --git a/lib/cpp/src/thrift/server/TThreadedServer.cpp b/lib/cpp/src/thrift/server/TThreadedServer.cpp
index ed2d80d..79dcc70 100644
--- a/lib/cpp/src/thrift/server/TThreadedServer.cpp
+++ b/lib/cpp/src/thrift/server/TThreadedServer.cpp
@@ -89,8 +89,7 @@
threadFactory_(threadFactory) {
}
-TThreadedServer::~TThreadedServer() {
-}
+TThreadedServer::~TThreadedServer() = default;
void TThreadedServer::serve() {
TServerFramework::serve();
@@ -107,7 +106,7 @@
void TThreadedServer::drainDeadClients() {
// we're in a monitor here
while (!deadClientMap_.empty()) {
- ClientMap::iterator it = deadClientMap_.begin();
+ auto it = deadClientMap_.begin();
it->second->join();
deadClientMap_.erase(it);
}
@@ -125,9 +124,9 @@
void TThreadedServer::onClientDisconnected(TConnectedClient* pClient) {
Synchronized sync(clientMonitor_);
drainDeadClients(); // use the outgoing thread to do some maintenance on our dead client backlog
- ClientMap::iterator it = activeClientMap_.find(pClient);
+ auto it = activeClientMap_.find(pClient);
if (it != activeClientMap_.end()) {
- ClientMap::iterator end = it;
+ auto end = it;
deadClientMap_.insert(it, ++end);
activeClientMap_.erase(it);
}
@@ -140,8 +139,7 @@
: pClient_(pClient) {
}
-TThreadedServer::TConnectedClientRunner::~TConnectedClientRunner() {
-}
+TThreadedServer::TConnectedClientRunner::~TConnectedClientRunner() = default;
void TThreadedServer::TConnectedClientRunner::run() /* override */ {
pClient_->run(); // Run the client
diff --git a/lib/cpp/src/thrift/server/TThreadedServer.h b/lib/cpp/src/thrift/server/TThreadedServer.h
index 9fc9d11..756e5a0 100644
--- a/lib/cpp/src/thrift/server/TThreadedServer.h
+++ b/lib/cpp/src/thrift/server/TThreadedServer.h
@@ -77,13 +77,13 @@
= std::shared_ptr<apache::thrift::concurrency::ThreadFactory>(
new apache::thrift::concurrency::ThreadFactory(false)));
- virtual ~TThreadedServer();
+ ~TThreadedServer() override;
/**
* Post-conditions (return guarantees):
* There will be no clients connected.
*/
- virtual void serve();
+ void serve() override;
protected:
/**
@@ -95,12 +95,12 @@
/**
* Implementation of TServerFramework::onClientConnected
*/
- virtual void onClientConnected(const std::shared_ptr<TConnectedClient>& pClient) /* override */;
+ void onClientConnected(const std::shared_ptr<TConnectedClient>& pClient) override /* override */;
/**
* Implementation of TServerFramework::onClientDisconnected
*/
- virtual void onClientDisconnected(TConnectedClient *pClient) /* override */;
+ void onClientDisconnected(TConnectedClient *pClient) override /* override */;
std::shared_ptr<apache::thrift::concurrency::ThreadFactory> threadFactory_;
@@ -115,8 +115,8 @@
{
public:
TConnectedClientRunner(const std::shared_ptr<TConnectedClient>& pClient);
- virtual ~TConnectedClientRunner();
- void run() /* override */;
+ ~TConnectedClientRunner() override;
+ void run() override /* override */;
private:
std::shared_ptr<TConnectedClient> pClient_;
};
diff --git a/lib/cpp/src/thrift/transport/TBufferTransports.cpp b/lib/cpp/src/thrift/transport/TBufferTransports.cpp
index 9ac2f84..4bb8713 100644
--- a/lib/cpp/src/thrift/transport/TBufferTransports.cpp
+++ b/lib/cpp/src/thrift/transport/TBufferTransports.cpp
@@ -29,7 +29,7 @@
namespace transport {
uint32_t TBufferedTransport::readSlow(uint8_t* buf, uint32_t len) {
- uint32_t have = static_cast<uint32_t>(rBound_ - rBase_);
+ auto have = static_cast<uint32_t>(rBound_ - rBase_);
// We should only take the slow path if we can't satisfy the read
// with the data already in the buffer.
@@ -61,8 +61,8 @@
}
void TBufferedTransport::writeSlow(const uint8_t* buf, uint32_t len) {
- uint32_t have_bytes = static_cast<uint32_t>(wBase_ - wBuf_.get());
- uint32_t space = static_cast<uint32_t>(wBound_ - wBase_);
+ auto have_bytes = static_cast<uint32_t>(wBase_ - wBuf_.get());
+ auto space = static_cast<uint32_t>(wBound_ - wBase_);
// We should only take the slow path if we can't accommodate the write
// with the free space already in the buffer.
assert(wBound_ - wBase_ < static_cast<ptrdiff_t>(len));
@@ -114,12 +114,12 @@
(void)len;
// Simply return NULL. We don't know if there is actually data available on
// the underlying transport, so calling read() might block.
- return NULL;
+ return nullptr;
}
void TBufferedTransport::flush() {
// Write out any data waiting in the write buffer.
- uint32_t have_bytes = static_cast<uint32_t>(wBase_ - wBuf_.get());
+ auto have_bytes = static_cast<uint32_t>(wBase_ - wBuf_.get());
if (have_bytes > 0) {
// Note that we reset wBase_ prior to the underlying write
// to ensure we're in a sane state (i.e. internal buffer cleaned)
@@ -134,7 +134,7 @@
uint32_t TFramedTransport::readSlow(uint8_t* buf, uint32_t len) {
uint32_t want = len;
- uint32_t have = static_cast<uint32_t>(rBound_ - rBase_);
+ auto have = static_cast<uint32_t>(rBound_ - rBase_);
// We should only take the slow path if we can't satisfy the read
// with the data already in the buffer.
@@ -217,7 +217,7 @@
void TFramedTransport::writeSlow(const uint8_t* buf, uint32_t len) {
// Double buffer size until sufficient.
- uint32_t have = static_cast<uint32_t>(wBase_ - wBuf_.get());
+ auto have = static_cast<uint32_t>(wBase_ - wBuf_.get());
uint32_t new_size = wBufSize_;
if (len + have < have /* overflow */ || len + have > 0x7fffffff) {
throw TTransportException(TTransportException::BAD_ARGS,
@@ -231,7 +231,7 @@
// so we can use realloc here.
// Allocate new buffer.
- uint8_t* new_buf = new uint8_t[new_size];
+ auto* new_buf = new uint8_t[new_size];
// Copy the old buffer to the new one.
memcpy(new_buf, wBuf_.get(), have);
@@ -292,12 +292,12 @@
// Don't try to be clever with shifting buffers.
// If the fast path failed let the protocol use its slow path.
// Besides, who is going to try to borrow across messages?
- return NULL;
+ return nullptr;
}
uint32_t TFramedTransport::readEnd() {
// include framing bytes
- uint32_t bytes_read = static_cast<uint32_t>(rBound_ - rBuf_.get() + sizeof(uint32_t));
+ auto bytes_read = static_cast<uint32_t>(rBound_ - rBuf_.get() + sizeof(uint32_t));
if (rBufSize_ > bufReclaimThresh_) {
rBufSize_ = 0;
@@ -335,7 +335,7 @@
uint32_t TMemoryBuffer::readAppendToString(std::string& str, uint32_t len) {
// Don't get some stupid assertion failure.
- if (buffer_ == NULL) {
+ if (buffer_ == nullptr) {
return 0;
}
@@ -372,8 +372,8 @@
}
// Allocate into a new pointer so we don't bork ours if it fails.
- uint8_t* new_buffer = static_cast<uint8_t*>(std::realloc(buffer_, new_size));
- if (new_buffer == NULL) {
+ auto* new_buffer = static_cast<uint8_t*>(std::realloc(buffer_, new_size));
+ if (new_buffer == nullptr) {
throw std::bad_alloc();
}
@@ -408,7 +408,7 @@
*len = available_read();
return rBase_;
}
- return NULL;
+ return nullptr;
}
}
}
diff --git a/lib/cpp/src/thrift/transport/TBufferTransports.h b/lib/cpp/src/thrift/transport/TBufferTransports.h
index 7012275..a008fa1 100644
--- a/lib/cpp/src/thrift/transport/TBufferTransports.h
+++ b/lib/cpp/src/thrift/transport/TBufferTransports.h
@@ -148,7 +148,7 @@
* performance-sensitive operation, so it is okay to just leave it to
* the concrete class to set up pointers correctly.
*/
- TBufferBase() : rBase_(NULL), rBound_(NULL), wBase_(NULL), wBound_(NULL) {}
+ TBufferBase() : rBase_(nullptr), rBound_(nullptr), wBase_(nullptr), wBound_(nullptr) {}
/// Convenience mutator for setting the read buffer.
void setReadBuffer(uint8_t* buf, uint32_t len) {
@@ -162,7 +162,7 @@
wBound_ = buf + len;
}
- virtual ~TBufferBase() {}
+ ~TBufferBase() override = default;
/// Reads begin here.
uint8_t* rBase_;
@@ -215,32 +215,32 @@
initPointers();
}
- void open() { transport_->open(); }
+ void open() override { transport_->open(); }
bool isOpen() { return transport_->isOpen(); }
- bool peek() {
+ bool peek() override {
if (rBase_ == rBound_) {
setReadBuffer(rBuf_.get(), transport_->read(rBuf_.get(), rBufSize_));
}
return (rBound_ > rBase_);
}
- void close() {
+ void close() override {
flush();
transport_->close();
}
- virtual uint32_t readSlow(uint8_t* buf, uint32_t len);
+ uint32_t readSlow(uint8_t* buf, uint32_t len) override;
- virtual void writeSlow(const uint8_t* buf, uint32_t len);
+ void writeSlow(const uint8_t* buf, uint32_t len) override;
void flush() override;
/**
* Returns the origin of the underlying transport
*/
- virtual const std::string getOrigin() { return transport_->getOrigin(); }
+ const std::string getOrigin() const override { return transport_->getOrigin(); }
/**
* The following behavior is currently implemented by TBufferedTransport,
@@ -253,7 +253,7 @@
* will ever have to be copied again. For optimial performance,
* stay under this limit.
*/
- virtual const uint8_t* borrowSlow(uint8_t* buf, uint32_t* len);
+ const uint8_t* borrowSlow(uint8_t* buf, uint32_t* len) override;
std::shared_ptr<TTransport> getUnderlyingTransport() { return transport_; }
@@ -284,9 +284,9 @@
*/
class TBufferedTransportFactory : public TTransportFactory {
public:
- TBufferedTransportFactory() {}
+ TBufferedTransportFactory() = default;
- virtual ~TBufferedTransportFactory() {}
+ ~TBufferedTransportFactory() override = default;
/**
* Wraps the transport into a buffered one.
@@ -343,13 +343,13 @@
initPointers();
}
- void open() { transport_->open(); }
+ void open() override { transport_->open(); }
bool isOpen() { return transport_->isOpen(); }
- bool peek() { return (rBase_ < rBound_) || transport_->peek(); }
+ bool peek() override { return (rBase_ < rBound_) || transport_->peek(); }
- void close() {
+ void close() override {
flush();
transport_->close();
}
@@ -360,11 +360,11 @@
void flush() override;
- uint32_t readEnd();
+ uint32_t readEnd() override;
- uint32_t writeEnd();
+ uint32_t writeEnd() override;
- const uint8_t* borrowSlow(uint8_t* buf, uint32_t* len);
+ const uint8_t* borrowSlow(uint8_t* buf, uint32_t* len) override;
std::shared_ptr<TTransport> getUnderlyingTransport() { return transport_; }
@@ -377,7 +377,7 @@
/**
* Returns the origin of the underlying transport
*/
- virtual const std::string getOrigin() { return transport_->getOrigin(); }
+ const std::string getOrigin() const override { return transport_->getOrigin(); }
/**
* Set the maximum size of the frame at read
@@ -399,7 +399,7 @@
virtual bool readFrame();
void initPointers() {
- setReadBuffer(NULL, 0);
+ setReadBuffer(nullptr, 0);
setWriteBuffer(wBuf_.get(), wBufSize_);
// Pad the buffer so we can insert the size later.
@@ -423,9 +423,9 @@
*/
class TFramedTransportFactory : public TTransportFactory {
public:
- TFramedTransportFactory() {}
+ TFramedTransportFactory() = default;
- virtual ~TFramedTransportFactory() {}
+ ~TFramedTransportFactory() override = default;
/**
* Wraps the transport into a framed one.
@@ -451,10 +451,10 @@
maxBufferSize_ = (std::numeric_limits<uint32_t>::max)();
- if (buf == NULL && size != 0) {
+ if (buf == nullptr && size != 0) {
assert(owner);
buf = (uint8_t*)std::malloc(size);
- if (buf == NULL) {
+ if (buf == nullptr) {
throw std::bad_alloc();
}
}
@@ -503,7 +503,7 @@
* Construct a TMemoryBuffer with a default-sized buffer,
* owned by the TMemoryBuffer object.
*/
- TMemoryBuffer() { initCommon(NULL, defaultSize, true, 0); }
+ TMemoryBuffer() { initCommon(nullptr, defaultSize, true, 0); }
/**
* Construct a TMemoryBuffer with a buffer of a specified size,
@@ -511,7 +511,7 @@
*
* @param sz The initial size of the buffer.
*/
- TMemoryBuffer(uint32_t sz) { initCommon(NULL, sz, true, 0); }
+ TMemoryBuffer(uint32_t sz) { initCommon(nullptr, sz, true, 0); }
/**
* Construct a TMemoryBuffer with buf as its initial contents.
@@ -524,7 +524,7 @@
* @param policy See @link MemoryPolicy @endlink .
*/
TMemoryBuffer(uint8_t* buf, uint32_t sz, MemoryPolicy policy = OBSERVE) {
- if (buf == NULL && sz != 0) {
+ if (buf == nullptr && sz != 0) {
throw TTransportException(TTransportException::BAD_ARGS,
"TMemoryBuffer given null buffer with non-zero size.");
}
@@ -535,7 +535,7 @@
initCommon(buf, sz, policy == TAKE_OWNERSHIP, sz);
break;
case COPY:
- initCommon(NULL, sz, true, 0);
+ initCommon(nullptr, sz, true, 0);
this->write(buf, sz);
break;
default:
@@ -544,7 +544,7 @@
}
}
- ~TMemoryBuffer() {
+ ~TMemoryBuffer() override {
if (owner_) {
std::free(buffer_);
}
@@ -552,11 +552,11 @@
bool isOpen() { return true; }
- bool peek() { return (rBase_ < wBase_); }
+ bool peek() override { return (rBase_ < wBase_); }
- void open() {}
+ void open() override {}
- void close() {}
+ void close() override {}
// TODO(dreiss): Make bufPtr const.
void getBuffer(uint8_t** bufPtr, uint32_t* sz) {
@@ -565,7 +565,7 @@
}
std::string getBufferAsString() {
- if (buffer_ == NULL) {
+ if (buffer_ == nullptr) {
return "";
}
uint8_t* buf;
@@ -575,7 +575,7 @@
}
void appendBufferToString(std::string& str) {
- if (buffer_ == NULL) {
+ if (buffer_ == nullptr) {
return;
}
uint8_t* buf;
@@ -634,9 +634,9 @@
uint32_t readAppendToString(std::string& str, uint32_t len);
// return number of bytes read
- uint32_t readEnd() {
+ uint32_t readEnd() override {
// This cast should be safe, because buffer_'s size is a uint32_t
- uint32_t bytes = static_cast<uint32_t>(rBase_ - buffer_);
+ auto bytes = static_cast<uint32_t>(rBase_ - buffer_);
if (rBase_ == wBase_) {
resetBuffer();
}
@@ -644,7 +644,7 @@
}
// Return number of bytes written
- uint32_t writeEnd() {
+ uint32_t writeEnd() override {
// This cast should be safe, because buffer_'s size is a uint32_t
return static_cast<uint32_t>(wBase_ - buffer_);
}
@@ -719,11 +719,11 @@
// Compute the position and available data for reading.
void computeRead(uint32_t len, uint8_t** out_start, uint32_t* out_give);
- uint32_t readSlow(uint8_t* buf, uint32_t len);
+ uint32_t readSlow(uint8_t* buf, uint32_t len) override;
- void writeSlow(const uint8_t* buf, uint32_t len);
+ void writeSlow(const uint8_t* buf, uint32_t len) override;
- const uint8_t* borrowSlow(uint8_t* buf, uint32_t* len);
+ const uint8_t* borrowSlow(uint8_t* buf, uint32_t* len) override;
// Data buffer
uint8_t* buffer_;
diff --git a/lib/cpp/src/thrift/transport/TFDTransport.h b/lib/cpp/src/thrift/transport/TFDTransport.h
index 5593d43..ede5ccb 100644
--- a/lib/cpp/src/thrift/transport/TFDTransport.h
+++ b/lib/cpp/src/thrift/transport/TFDTransport.h
@@ -43,7 +43,7 @@
TFDTransport(int fd, ClosePolicy close_policy = NO_CLOSE_ON_DESTROY)
: fd_(fd), close_policy_(close_policy) {}
- ~TFDTransport() {
+ ~TFDTransport() override {
if (close_policy_ == CLOSE_ON_DESTROY) {
try {
close();
@@ -55,9 +55,9 @@
bool isOpen() { return fd_ >= 0; }
- void open() {}
+ void open() override {}
- void close();
+ void close() override;
uint32_t read(uint8_t* buf, uint32_t len);
diff --git a/lib/cpp/src/thrift/transport/TFileTransport.cpp b/lib/cpp/src/thrift/transport/TFileTransport.cpp
index 5df2778..1eefb89 100644
--- a/lib/cpp/src/thrift/transport/TFileTransport.cpp
+++ b/lib/cpp/src/thrift/transport/TFileTransport.cpp
@@ -65,8 +65,8 @@
TFileTransport::TFileTransport(string path, bool readOnly)
: readState_(),
- readBuff_(NULL),
- currentEvent_(NULL),
+ readBuff_(nullptr),
+ currentEvent_(nullptr),
readBuffSize_(DEFAULT_READ_BUFF_SIZE),
readTimeout_(NO_TAIL_READ_TIMEOUT),
chunkSize_(DEFAULT_CHUNK_SIZE),
@@ -78,8 +78,8 @@
eofSleepTime_(DEFAULT_EOF_SLEEP_TIME_US),
corruptedEventSleepTime_(DEFAULT_CORRUPTED_SLEEP_TIME_US),
writerThreadIOErrorSleepTime_(DEFAULT_WRITER_THREAD_SLEEP_TIME_US),
- dequeueBuffer_(NULL),
- enqueueBuffer_(NULL),
+ dequeueBuffer_(nullptr),
+ enqueueBuffer_(nullptr),
notFull_(&mutex_),
notEmpty_(&mutex_),
closing_(false),
@@ -141,22 +141,22 @@
if (dequeueBuffer_) {
delete dequeueBuffer_;
- dequeueBuffer_ = NULL;
+ dequeueBuffer_ = nullptr;
}
if (enqueueBuffer_) {
delete enqueueBuffer_;
- enqueueBuffer_ = NULL;
+ enqueueBuffer_ = nullptr;
}
if (readBuff_) {
delete[] readBuff_;
- readBuff_ = NULL;
+ readBuff_ = nullptr;
}
if (currentEvent_) {
delete currentEvent_;
- currentEvent_ = NULL;
+ currentEvent_ = nullptr;
}
// close logfile
@@ -275,7 +275,7 @@
// return immediately if the transport is closing
swap = false;
} else {
- if (deadline != NULL) {
+ if (deadline != nullptr) {
// if we were handed a deadline time struct, do a timed wait
notEmpty_.waitForTime(*deadline);
} else {
@@ -362,7 +362,7 @@
if (swapEventBuffers(&ts_next_flush)) {
eventInfo* outEvent;
- while (NULL != (outEvent = dequeueBuffer_->getNext())) {
+ while (nullptr != (outEvent = dequeueBuffer_->getNext())) {
// Remove an event from the buffer and write it out to disk. If there is any IO error, for
// instance,
// the output file is unmounted or deleted, then this event is dropped. However, the writer
@@ -422,9 +422,9 @@
if (chunk1 != chunk2) {
// refetch the offset to keep in sync
offset_ = THRIFT_LSEEK(fd_, 0, SEEK_CUR);
- int32_t padding = (int32_t)((offset_ / chunkSize_ + 1) * chunkSize_ - offset_);
+ auto padding = (int32_t)((offset_ / chunkSize_ + 1) * chunkSize_ - offset_);
- uint8_t* zeros = new uint8_t[padding];
+ auto* zeros = new uint8_t[padding];
memset(zeros, '\0', padding);
boost::scoped_array<uint8_t> array(zeros);
if (-1 == ::write(fd_, zeros, padding)) {
@@ -587,7 +587,7 @@
memcpy(buf, currentEvent_->eventBuff_ + currentEvent_->eventBuffPos_, remaining);
}
delete (currentEvent_);
- currentEvent_ = NULL;
+ currentEvent_ = nullptr;
return remaining;
}
@@ -630,12 +630,12 @@
} else if (readTimeout_ == NO_TAIL_READ_TIMEOUT) {
// reset state
readState_.resetState(0);
- return NULL;
+ return nullptr;
} else if (readTimeout_ > 0) {
// timeout already expired once
if (readTries > 0) {
readState_.resetState(0);
- return NULL;
+ return nullptr;
} else {
THRIFT_SLEEP_USEC(readTimeout_ * 1000);
readTries++;
@@ -709,7 +709,7 @@
eventInfo* completeEvent = readState_.event_;
completeEvent->eventBuffPos_ = 0;
- readState_.event_ = NULL;
+ readState_.event_ = nullptr;
readState_.resetState(readState_.bufferPtr_);
// exit criteria
@@ -778,7 +778,7 @@
// pretty hosed at this stage, rewind the file back to the last successful
// point and punt on the error
readState_.resetState(readState_.lastDispatchPtr_);
- currentEvent_ = NULL;
+ currentEvent_ = nullptr;
char errorMsg[1024];
sprintf(errorMsg,
"TFileTransport: log file corrupted at offset: %lu",
@@ -827,7 +827,7 @@
off_t newOffset = off_t(chunk) * chunkSize_;
offset_ = ::THRIFT_LSEEK(fd_, newOffset, SEEK_SET);
readState_.resetAllValues();
- currentEvent_ = NULL;
+ currentEvent_ = nullptr;
if (offset_ == -1) {
GlobalOutput("TFileTransport: lseek error in seekToChunk");
throw TTransportException("TFileTransport: lseek error in seekToChunk");
@@ -841,7 +841,7 @@
shared_ptr<eventInfo> event;
while ((offset_ + readState_.bufferPtr_) < minEndOffset) {
event.reset(readEvent());
- if (event.get() == NULL) {
+ if (event.get() == nullptr) {
break;
}
}
@@ -918,7 +918,7 @@
delete buffer_[i];
}
delete[] buffer_;
- buffer_ = NULL;
+ buffer_ = nullptr;
}
}
@@ -943,7 +943,7 @@
return buffer_[readPoint_++];
} else {
// no more entries
- return NULL;
+ return nullptr;
}
}
@@ -1020,7 +1020,7 @@
// bad form to use exceptions for flow control but there is really
// no other way around it
try {
- processor_->process(inputProtocol, outputProtocol, NULL);
+ processor_->process(inputProtocol, outputProtocol, nullptr);
numProcessed++;
if ((numEvents > 0) && (numProcessed == numEvents)) {
return;
@@ -1051,7 +1051,7 @@
// bad form to use exceptions for flow control but there is really
// no other way around it
try {
- processor_->process(inputProtocol, outputProtocol, NULL);
+ processor_->process(inputProtocol, outputProtocol, nullptr);
if (curChunk != inputTransport_->getCurChunk()) {
break;
}
diff --git a/lib/cpp/src/thrift/transport/TFileTransport.h b/lib/cpp/src/thrift/transport/TFileTransport.h
index e7c1ca6..0df5cf9 100644
--- a/lib/cpp/src/thrift/transport/TFileTransport.h
+++ b/lib/cpp/src/thrift/transport/TFileTransport.h
@@ -48,7 +48,7 @@
uint32_t eventSize_;
uint32_t eventBuffPos_;
- eventInfo() : eventBuff_(NULL), eventSize_(0), eventBuffPos_(0){};
+ eventInfo() : eventBuff_(nullptr), eventSize_(0), eventBuffPos_(0){};
~eventInfo() {
if (eventBuff_) {
delete[] eventBuff_;
@@ -85,7 +85,7 @@
if (event_) {
delete (event_);
}
- event_ = 0;
+ event_ = nullptr;
}
inline uint32_t getEventSize() {
@@ -94,7 +94,7 @@
}
readState() {
- event_ = 0;
+ event_ = nullptr;
resetAllValues();
}
@@ -174,24 +174,24 @@
class TFileTransport : public TFileReaderTransport, public TFileWriterTransport {
public:
TFileTransport(std::string path, bool readOnly = false);
- ~TFileTransport();
+ ~TFileTransport() override;
// TODO: what is the correct behaviour for this?
// the log file is generally always open
bool isOpen() const override { return true; }
void write(const uint8_t* buf, uint32_t len);
- void flush();
+ void flush() override;
uint32_t readAll(uint8_t* buf, uint32_t len);
uint32_t read(uint8_t* buf, uint32_t len);
bool peek() override;
// log-file specific functions
- void seekToChunk(int32_t chunk);
- void seekToEnd();
- uint32_t getNumChunks();
- uint32_t getCurChunk();
+ void seekToChunk(int32_t chunk) override;
+ void seekToEnd() override;
+ uint32_t getNumChunks() override;
+ uint32_t getCurChunk() override;
// for changing the output file
void resetOutputFile(int fd, std::string filename, off_t offset);
@@ -206,15 +206,15 @@
static const int32_t TAIL_READ_TIMEOUT = -1;
static const int32_t NO_TAIL_READ_TIMEOUT = 0;
- void setReadTimeout(int32_t readTimeout) { readTimeout_ = readTimeout; }
- int32_t getReadTimeout() { return readTimeout_; }
+ void setReadTimeout(int32_t readTimeout) override { readTimeout_ = readTimeout; }
+ int32_t getReadTimeout() override { return readTimeout_; }
- void setChunkSize(uint32_t chunkSize) {
+ void setChunkSize(uint32_t chunkSize) override {
if (chunkSize) {
chunkSize_ = chunkSize;
}
}
- uint32_t getChunkSize() { return chunkSize_; }
+ uint32_t getChunkSize() override { return chunkSize_; }
void setEventBufferSize(uint32_t bufferSize) {
if (bufferAndThreadInitialized_) {
@@ -273,7 +273,7 @@
// control for writer thread
static void* startWriterThread(void* ptr) {
static_cast<TFileTransport*>(ptr)->writerThread();
- return NULL;
+ return nullptr;
}
void writerThread();
diff --git a/lib/cpp/src/thrift/transport/THeaderTransport.cpp b/lib/cpp/src/thrift/transport/THeaderTransport.cpp
index 25084ec..b582d8d 100644
--- a/lib/cpp/src/thrift/transport/THeaderTransport.cpp
+++ b/lib/cpp/src/thrift/transport/THeaderTransport.cpp
@@ -197,7 +197,7 @@
readHeaders_.clear(); // Clear out any previous headers.
// skip over already processed magic(4), seqId(4), headerSize(2)
- uint8_t* ptr = reinterpret_cast<uint8_t*>(rBuf_.get() + 10);
+ auto* ptr = reinterpret_cast<uint8_t*>(rBuf_.get() + 10);
// Catch integer overflow, check for reasonable header size
if (headerSize >= 16384) {
@@ -275,9 +275,9 @@
stream.avail_in = sz;
// Setting these to 0 means use the default free/alloc functions
- stream.zalloc = (alloc_func)0;
- stream.zfree = (free_func)0;
- stream.opaque = (voidpf)0;
+ stream.zalloc = (alloc_func)nullptr;
+ stream.zfree = (free_func)nullptr;
+ stream.opaque = (voidpf)nullptr;
err = inflateInit(&stream);
if (err != Z_OK) {
throw TApplicationException(TApplicationException::MISSING_RESULT,
@@ -317,7 +317,7 @@
void THeaderTransport::resizeTransformBuffer(uint32_t additionalSize) {
if (tBufSize_ < wBufSize_ + DEFAULT_BUFFER_SIZE) {
uint32_t new_size = wBufSize_ + DEFAULT_BUFFER_SIZE + additionalSize;
- uint8_t* new_buf = new uint8_t[new_size];
+ auto* new_buf = new uint8_t[new_size];
tBuf_.reset(new_buf);
tBufSize_ = new_size;
}
@@ -337,9 +337,9 @@
stream.next_in = ptr;
stream.avail_in = sz;
- stream.zalloc = (alloc_func)0;
- stream.zfree = (free_func)0;
- stream.opaque = (voidpf)0;
+ stream.zalloc = (alloc_func)nullptr;
+ stream.zfree = (free_func)nullptr;
+ stream.opaque = (voidpf)nullptr;
err = deflateInit(&stream, Z_DEFAULT_COMPRESSION);
if (err != Z_OK) {
throw TTransportException(TTransportException::CORRUPTED_DATA,
@@ -389,7 +389,7 @@
* Automatically advances ptr to after the written portion
*/
void THeaderTransport::writeString(uint8_t*& ptr, const string& str) {
- int32_t strLen = safe_numeric_cast<int32_t>(str.length());
+ auto strLen = safe_numeric_cast<int32_t>(str.length());
ptr += writeVarint32(strLen, ptr);
memcpy(ptr, str.c_str(), strLen); // no need to write \0
ptr += strLen;
@@ -484,7 +484,7 @@
// write info headers
// for now only write kv-headers
- int32_t headerCount = safe_numeric_cast<int32_t>(writeHeaders_.size());
+ auto headerCount = safe_numeric_cast<int32_t>(writeHeaders_.size());
if (headerCount > 0) {
pkt += writeVarint32(infoIdType::KEYVALUE, pkt);
// Write key-value headers count
@@ -526,7 +526,7 @@
outTransport_->write(pktStart, szHbo - haveBytes + 4);
outTransport_->write(wBuf_.get(), haveBytes);
} else if (clientType == THRIFT_FRAMED_BINARY || clientType == THRIFT_FRAMED_COMPACT) {
- uint32_t szHbo = (uint32_t)haveBytes;
+ auto szHbo = (uint32_t)haveBytes;
uint32_t szNbo = htonl(szHbo);
outTransport_->write(reinterpret_cast<uint8_t*>(&szNbo), 4);
diff --git a/lib/cpp/src/thrift/transport/THeaderTransport.h b/lib/cpp/src/thrift/transport/THeaderTransport.h
index 350702d..d1e9d43 100644
--- a/lib/cpp/src/thrift/transport/THeaderTransport.h
+++ b/lib/cpp/src/thrift/transport/THeaderTransport.h
@@ -82,7 +82,7 @@
seqId(0),
flags(0),
tBufSize_(0),
- tBuf_(NULL) {
+ tBuf_(nullptr) {
if (!transport_) throw std::invalid_argument("transport is empty");
initBuffers();
}
@@ -96,13 +96,13 @@
seqId(0),
flags(0),
tBufSize_(0),
- tBuf_(NULL) {
+ tBuf_(nullptr) {
if (!transport_) throw std::invalid_argument("inTransport is empty");
if (!outTransport_) throw std::invalid_argument("outTransport is empty");
initBuffers();
}
- virtual uint32_t readSlow(uint8_t* buf, uint32_t len);
+ uint32_t readSlow(uint8_t* buf, uint32_t len) override;
void flush() override;
void resizeTransformBuffer(uint32_t additionalSize = 0);
@@ -175,13 +175,13 @@
* Returns true if a frame was read successfully, or false on EOF.
* (Raises a TTransportException if EOF occurs after a partial frame.)
*/
- virtual bool readFrame();
+ bool readFrame() override;
void ensureReadBuffer(uint32_t sz);
uint32_t getWriteBytes();
void initBuffers() {
- setReadBuffer(NULL, 0);
+ setReadBuffer(nullptr, 0);
setWriteBuffer(wBuf_.get(), wBufSize_);
}
@@ -257,9 +257,9 @@
*/
class THeaderTransportFactory : public TTransportFactory {
public:
- THeaderTransportFactory() {}
+ THeaderTransportFactory() = default;
- virtual ~THeaderTransportFactory() {}
+ ~THeaderTransportFactory() override = default;
/**
* Wraps the transport into a header one.
diff --git a/lib/cpp/src/thrift/transport/THttpClient.cpp b/lib/cpp/src/thrift/transport/THttpClient.cpp
index d152197..04566c9 100644
--- a/lib/cpp/src/thrift/transport/THttpClient.cpp
+++ b/lib/cpp/src/thrift/transport/THttpClient.cpp
@@ -44,12 +44,11 @@
path_(path) {
}
-THttpClient::~THttpClient() {
-}
+THttpClient::~THttpClient() = default;
void THttpClient::parseHeader(char* header) {
char* colon = strchr(header, ':');
- if (colon == NULL) {
+ if (colon == nullptr) {
return;
}
char* value = colon + 1;
@@ -68,7 +67,7 @@
char* http = status;
char* code = strchr(http, ' ');
- if (code == NULL) {
+ if (code == nullptr) {
throw TTransportException(string("Bad Status: ") + status);
}
@@ -77,7 +76,7 @@
};
char* msg = strchr(code, ' ');
- if (msg == NULL) {
+ if (msg == nullptr) {
throw TTransportException(string("Bad Status: ") + status);
}
*msg = '\0';
diff --git a/lib/cpp/src/thrift/transport/THttpClient.h b/lib/cpp/src/thrift/transport/THttpClient.h
index 31f593f..fdca505 100644
--- a/lib/cpp/src/thrift/transport/THttpClient.h
+++ b/lib/cpp/src/thrift/transport/THttpClient.h
@@ -32,7 +32,7 @@
THttpClient(std::string host, int port, std::string path = "");
- virtual ~THttpClient();
+ ~THttpClient() override;
void flush() override;
@@ -40,8 +40,8 @@
std::string host_;
std::string path_;
- virtual void parseHeader(char* header);
- virtual bool parseStatusLine(char* status);
+ void parseHeader(char* header) override;
+ bool parseStatusLine(char* status) override;
};
}
}
diff --git a/lib/cpp/src/thrift/transport/THttpServer.cpp b/lib/cpp/src/thrift/transport/THttpServer.cpp
index 96b2480..94ac681 100644
--- a/lib/cpp/src/thrift/transport/THttpServer.cpp
+++ b/lib/cpp/src/thrift/transport/THttpServer.cpp
@@ -37,8 +37,7 @@
THttpServer::THttpServer(std::shared_ptr<TTransport> transport) : THttpTransport(transport) {
}
-THttpServer::~THttpServer() {
-}
+THttpServer::~THttpServer() = default;
#if defined(_MSC_VER) || defined(__MINGW32__)
#define THRIFT_GMTIME(TM, TIME) gmtime_s(&TM, &TIME)
@@ -52,14 +51,14 @@
void THttpServer::parseHeader(char* header) {
char* colon = strchr(header, ':');
- if (colon == NULL) {
+ if (colon == nullptr) {
return;
}
size_t sz = colon - header;
char* value = colon + 1;
if (THRIFT_strncasecmp(header, "Transfer-Encoding", sz) == 0) {
- if (THRIFT_strcasestr(value, "chunked") != NULL) {
+ if (THRIFT_strcasestr(value, "chunked") != nullptr) {
chunked_ = true;
}
} else if (THRIFT_strncasecmp(header, "Content-length", sz) == 0) {
@@ -74,7 +73,7 @@
char* method = status;
char* path = strchr(method, ' ');
- if (path == NULL) {
+ if (path == nullptr) {
throw TTransportException(string("Bad Status: ") + status);
}
@@ -83,7 +82,7 @@
};
char* http = strchr(path, ' ');
- if (http == NULL) {
+ if (http == nullptr) {
throw TTransportException(string("Bad Status: ") + status);
}
*http = '\0';
@@ -149,7 +148,7 @@
= {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
char buff[128];
- time_t t = time(NULL);
+ time_t t = time(nullptr);
struct tm tmb;
THRIFT_GMTIME(tmb, t);
diff --git a/lib/cpp/src/thrift/transport/THttpServer.h b/lib/cpp/src/thrift/transport/THttpServer.h
index d72cb13..0e83399 100644
--- a/lib/cpp/src/thrift/transport/THttpServer.h
+++ b/lib/cpp/src/thrift/transport/THttpServer.h
@@ -30,14 +30,14 @@
public:
THttpServer(std::shared_ptr<TTransport> transport);
- virtual ~THttpServer();
+ ~THttpServer() override;
void flush() override;
protected:
void readHeaders();
- virtual void parseHeader(char* header);
- virtual bool parseStatusLine(char* status);
+ void parseHeader(char* header) override;
+ bool parseStatusLine(char* status) override;
std::string getTimeRFC1123();
};
@@ -46,9 +46,9 @@
*/
class THttpServerTransportFactory : public TTransportFactory {
public:
- THttpServerTransportFactory() {}
+ THttpServerTransportFactory() = default;
- virtual ~THttpServerTransportFactory() {}
+ ~THttpServerTransportFactory() override = default;
/**
* Wraps the transport into a buffered one.
diff --git a/lib/cpp/src/thrift/transport/THttpTransport.cpp b/lib/cpp/src/thrift/transport/THttpTransport.cpp
index 6ccc034..aea2b28 100644
--- a/lib/cpp/src/thrift/transport/THttpTransport.cpp
+++ b/lib/cpp/src/thrift/transport/THttpTransport.cpp
@@ -39,7 +39,7 @@
chunkedDone_(false),
chunkSize_(0),
contentLength_(0),
- httpBuf_(NULL),
+ httpBuf_(nullptr),
httpPos_(0),
httpBufLen_(0),
httpBufSize_(1024) {
@@ -48,14 +48,14 @@
void THttpTransport::init() {
httpBuf_ = (char*)std::malloc(httpBufSize_ + 1);
- if (httpBuf_ == NULL) {
+ if (httpBuf_ == nullptr) {
throw std::bad_alloc();
}
httpBuf_[httpBufLen_] = '\0';
}
THttpTransport::~THttpTransport() {
- if (httpBuf_ != NULL) {
+ if (httpBuf_ != nullptr) {
std::free(httpBuf_);
}
}
@@ -132,7 +132,7 @@
uint32_t THttpTransport::parseChunkSize(char* line) {
char* semi = strchr(line, ';');
- if (semi != NULL) {
+ if (semi != nullptr) {
*semi = '\0';
}
uint32_t size = 0;
@@ -166,12 +166,12 @@
char* THttpTransport::readLine() {
while (true) {
- char* eol = NULL;
+ char* eol = nullptr;
eol = strstr(httpBuf_ + httpPos_, CRLF);
// No CRLF yet?
- if (eol == NULL) {
+ if (eol == nullptr) {
// Shift whatever we have now to front and refill
shift();
refill();
@@ -203,7 +203,7 @@
if (avail <= (httpBufSize_ / 4)) {
httpBufSize_ *= 2;
char* tmpBuf = (char*)std::realloc(httpBuf_, httpBufSize_ + 1);
- if (tmpBuf == NULL) {
+ if (tmpBuf == nullptr) {
throw std::bad_alloc();
}
httpBuf_ = tmpBuf;
@@ -257,7 +257,7 @@
writeBuffer_.write(buf, len);
}
-const std::string THttpTransport::getOrigin() {
+const std::string THttpTransport::getOrigin() const {
std::ostringstream oss;
if (!origin_.empty()) {
oss << origin_ << ", ";
diff --git a/lib/cpp/src/thrift/transport/THttpTransport.h b/lib/cpp/src/thrift/transport/THttpTransport.h
index e46ab7f..1cf36b2 100644
--- a/lib/cpp/src/thrift/transport/THttpTransport.h
+++ b/lib/cpp/src/thrift/transport/THttpTransport.h
@@ -38,25 +38,25 @@
public:
THttpTransport(std::shared_ptr<TTransport> transport);
- virtual ~THttpTransport();
+ ~THttpTransport() override;
- void open() { transport_->open(); }
+ void open() override { transport_->open(); }
bool isOpen() { return transport_->isOpen(); }
- bool peek() { return transport_->peek(); }
+ bool peek() override { return transport_->peek(); }
- void close() { transport_->close(); }
+ void close() override { transport_->close(); }
uint32_t read(uint8_t* buf, uint32_t len);
- uint32_t readEnd();
+ uint32_t readEnd() override;
void write(const uint8_t* buf, uint32_t len);
- virtual void flush() = 0;
+ void flush() override = 0;
- virtual const std::string getOrigin();
+ const std::string getOrigin() const override;
protected:
std::shared_ptr<TTransport> transport_;
diff --git a/lib/cpp/src/thrift/transport/TNonblockingSSLServerSocket.h b/lib/cpp/src/thrift/transport/TNonblockingSSLServerSocket.h
index 215c405..a38bf12 100644
--- a/lib/cpp/src/thrift/transport/TNonblockingSSLServerSocket.h
+++ b/lib/cpp/src/thrift/transport/TNonblockingSSLServerSocket.h
@@ -66,7 +66,7 @@
std::shared_ptr<TSSLSocketFactory> factory);
protected:
- std::shared_ptr<TSocket> createSocket(THRIFT_SOCKET socket);
+ std::shared_ptr<TSocket> createSocket(THRIFT_SOCKET socket) override;
std::shared_ptr<TSSLSocketFactory> factory_;
};
}
diff --git a/lib/cpp/src/thrift/transport/TNonblockingServerSocket.cpp b/lib/cpp/src/thrift/transport/TNonblockingServerSocket.cpp
index 3d34cca..51990b0 100644
--- a/lib/cpp/src/thrift/transport/TNonblockingServerSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TNonblockingServerSocket.cpp
@@ -193,7 +193,7 @@
hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
// If address is not specified use wildcard address (NULL)
- TGetAddrInfoWrapper info(address_.empty() ? NULL : &address_[0], port, &hints);
+ TGetAddrInfoWrapper info(address_.empty() ? nullptr : &address_[0], port, &hints);
error = info.init();
if (error) {
@@ -206,13 +206,13 @@
// Pick the ipv6 address first since ipv4 addresses can be mapped
// into ipv6 space.
for (res = info.res(); res; res = res->ai_next) {
- if (res->ai_family == AF_INET6 || res->ai_next == NULL)
+ if (res->ai_family == AF_INET6 || res->ai_next == nullptr)
break;
}
if (!path_.empty()) {
serverSocket_ = socket(PF_UNIX, SOCK_STREAM, IPPROTO_IP);
- } else if (res != NULL) {
+ } else if (res != nullptr) {
serverSocket_ = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
}
@@ -372,7 +372,7 @@
// Unix Domain Socket
size_t len = path_.size() + 1;
- if (len > sizeof(((sockaddr_un*)NULL)->sun_path)) {
+ if (len > sizeof(((sockaddr_un*)nullptr)->sun_path)) {
errno_copy = THRIFT_GET_SOCKET_ERROR;
GlobalOutput.perror("TSocket::listen() Unix Domain socket path too long", errno_copy);
throw TTransportException(TTransportException::NOT_OPEN,
@@ -384,7 +384,7 @@
address.sun_family = AF_UNIX;
memcpy(address.sun_path, path_.c_str(), len);
- socklen_t structlen = static_cast<socklen_t>(sizeof(address));
+ auto structlen = static_cast<socklen_t>(sizeof(address));
if (!address.sun_path[0]) { // abstract namespace socket
#ifdef __linux__
@@ -428,10 +428,10 @@
GlobalOutput.perror("TNonblockingServerSocket::getPort() getsockname() ", errno_copy);
} else {
if (sa.ss_family == AF_INET6) {
- const struct sockaddr_in6* sin = reinterpret_cast<const struct sockaddr_in6*>(&sa);
+ const auto* sin = reinterpret_cast<const struct sockaddr_in6*>(&sa);
listenPort_ = ntohs(sin->sin6_port);
} else {
- const struct sockaddr_in* sin = reinterpret_cast<const struct sockaddr_in*>(&sa);
+ const auto* sin = reinterpret_cast<const struct sockaddr_in*>(&sa);
listenPort_ = ntohs(sin->sin_port);
}
}
diff --git a/lib/cpp/src/thrift/transport/TNonblockingServerSocket.h b/lib/cpp/src/thrift/transport/TNonblockingServerSocket.h
index 8466512..a68c28d 100644
--- a/lib/cpp/src/thrift/transport/TNonblockingServerSocket.h
+++ b/lib/cpp/src/thrift/transport/TNonblockingServerSocket.h
@@ -71,7 +71,7 @@
*/
TNonblockingServerSocket(const std::string& path);
- virtual ~TNonblockingServerSocket();
+ ~TNonblockingServerSocket() override;
void setSendTimeout(int sendTimeout);
void setRecvTimeout(int recvTimeout);
@@ -97,17 +97,17 @@
// socket, this is the place to do it.
void setAcceptCallback(const socket_func_t& acceptCallback) { acceptCallback_ = acceptCallback; }
- THRIFT_SOCKET getSocketFD() { return serverSocket_; }
+ THRIFT_SOCKET getSocketFD() override { return serverSocket_; }
- int getPort();
+ int getPort() override;
- int getListenPort();
+ int getListenPort() override;
void listen() override;
void close() override;
protected:
- std::shared_ptr<TSocket> acceptImpl();
+ std::shared_ptr<TSocket> acceptImpl() override;
virtual std::shared_ptr<TSocket> createSocket(THRIFT_SOCKET client);
private:
diff --git a/lib/cpp/src/thrift/transport/TNonblockingServerTransport.h b/lib/cpp/src/thrift/transport/TNonblockingServerTransport.h
index 3142e19..f811328 100644
--- a/lib/cpp/src/thrift/transport/TNonblockingServerTransport.h
+++ b/lib/cpp/src/thrift/transport/TNonblockingServerTransport.h
@@ -35,7 +35,7 @@
*/
class TNonblockingServerTransport {
public:
- virtual ~TNonblockingServerTransport() {}
+ virtual ~TNonblockingServerTransport() = default;
/**
* Starts the server transport listening for new connections. Prior to this
@@ -82,7 +82,7 @@
virtual void close() = 0;
protected:
- TNonblockingServerTransport() {}
+ TNonblockingServerTransport() = default;
/**
* Subclasses should implement this function for accept.
diff --git a/lib/cpp/src/thrift/transport/TSSLServerSocket.h b/lib/cpp/src/thrift/transport/TSSLServerSocket.h
index 8b75de8..44df432 100644
--- a/lib/cpp/src/thrift/transport/TSSLServerSocket.h
+++ b/lib/cpp/src/thrift/transport/TSSLServerSocket.h
@@ -66,7 +66,7 @@
std::shared_ptr<TSSLSocketFactory> factory);
protected:
- std::shared_ptr<TSocket> createSocket(THRIFT_SOCKET socket);
+ std::shared_ptr<TSocket> createSocket(THRIFT_SOCKET socket) override;
std::shared_ptr<TSSLSocketFactory> factory_;
};
}
diff --git a/lib/cpp/src/thrift/transport/TSSLSocket.cpp b/lib/cpp/src/thrift/transport/TSSLSocket.cpp
index 718e9b1..636bb2d 100644
--- a/lib/cpp/src/thrift/transport/TSSLSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TSSLSocket.cpp
@@ -95,7 +95,7 @@
}
static void dyn_lock(int mode, struct CRYPTO_dynlock_value* lock, const char*, int) {
- if (lock != NULL) {
+ if (lock != nullptr) {
if (mode & CRYPTO_LOCK) {
lock->mutex.lock();
} else {
@@ -180,7 +180,7 @@
throw TSSLException("SSL_CTX_new: Unknown protocol");
}
- if (ctx_ == NULL) {
+ if (ctx_ == nullptr) {
string errors;
buildErrors(errors);
throw TSSLException("SSL_CTX_new: " + errors);
@@ -196,15 +196,15 @@
}
SSLContext::~SSLContext() {
- if (ctx_ != NULL) {
+ if (ctx_ != nullptr) {
SSL_CTX_free(ctx_);
- ctx_ = NULL;
+ ctx_ = nullptr;
}
}
SSL* SSLContext::createSSL() {
SSL* ssl = SSL_new(ctx_);
- if (ssl == NULL) {
+ if (ssl == nullptr) {
string errors;
buildErrors(errors);
throw TSSLException("SSL_new: " + errors);
@@ -214,33 +214,33 @@
// TSSLSocket implementation
TSSLSocket::TSSLSocket(std::shared_ptr<SSLContext> ctx)
- : TSocket(), server_(false), ssl_(NULL), ctx_(ctx) {
+ : TSocket(), server_(false), ssl_(nullptr), ctx_(ctx) {
init();
}
TSSLSocket::TSSLSocket(std::shared_ptr<SSLContext> ctx, std::shared_ptr<THRIFT_SOCKET> interruptListener)
- : TSocket(), server_(false), ssl_(NULL), ctx_(ctx) {
+ : TSocket(), server_(false), ssl_(nullptr), ctx_(ctx) {
init();
interruptListener_ = interruptListener;
}
TSSLSocket::TSSLSocket(std::shared_ptr<SSLContext> ctx, THRIFT_SOCKET socket)
- : TSocket(socket), server_(false), ssl_(NULL), ctx_(ctx) {
+ : TSocket(socket), server_(false), ssl_(nullptr), ctx_(ctx) {
init();
}
TSSLSocket::TSSLSocket(std::shared_ptr<SSLContext> ctx, THRIFT_SOCKET socket, std::shared_ptr<THRIFT_SOCKET> interruptListener)
- : TSocket(socket, interruptListener), server_(false), ssl_(NULL), ctx_(ctx) {
+ : TSocket(socket, interruptListener), server_(false), ssl_(nullptr), ctx_(ctx) {
init();
}
TSSLSocket::TSSLSocket(std::shared_ptr<SSLContext> ctx, string host, int port)
- : TSocket(host, port), server_(false), ssl_(NULL), ctx_(ctx) {
+ : TSocket(host, port), server_(false), ssl_(nullptr), ctx_(ctx) {
init();
}
TSSLSocket::TSSLSocket(std::shared_ptr<SSLContext> ctx, string host, int port, std::shared_ptr<THRIFT_SOCKET> interruptListener)
- : TSocket(host, port), server_(false), ssl_(NULL), ctx_(ctx) {
+ : TSocket(host, port), server_(false), ssl_(nullptr), ctx_(ctx) {
init();
interruptListener_ = interruptListener;
}
@@ -267,7 +267,7 @@
}
bool TSSLSocket::isOpen() {
- if (ssl_ == NULL || !TSocket::isOpen()) {
+ if (ssl_ == nullptr || !TSocket::isOpen()) {
return false;
}
int shutdown = SSL_get_shutdown(ssl_);
@@ -334,7 +334,7 @@
* Note: This method is not libevent safe.
*/
void TSSLSocket::close() {
- if (ssl_ != NULL) {
+ if (ssl_ != nullptr) {
try {
int rc;
int errno_copy = 0;
@@ -375,7 +375,7 @@
GlobalOutput.printf("SSL_shutdown: %s", te.what());
}
SSL_free(ssl_);
- ssl_ = NULL;
+ ssl_ = nullptr;
handshakeCompleted_ = false;
ERR_remove_state(0);
}
@@ -552,14 +552,14 @@
void TSSLSocket::flush() {
// Don't throw exception if not open. Thrift servers close socket twice.
- if (ssl_ == NULL) {
+ if (ssl_ == nullptr) {
return;
}
initializeHandshake();
if (!checkHandshake())
throw TSSLException("BIO_flush: Handshake is not completed");
BIO* bio = SSL_get_wbio(ssl_);
- if (bio == NULL) {
+ if (bio == nullptr) {
throw TSSLException("SSL_get_wbio returns NULL");
}
if (BIO_flush(bio) != 1) {
@@ -597,7 +597,7 @@
return;
}
- if (ssl_ == NULL) {
+ if (ssl_ == nullptr) {
initializeHandshakeParams();
}
@@ -683,19 +683,19 @@
}
X509* cert = SSL_get_peer_certificate(ssl_);
- if (cert == NULL) {
+ if (cert == nullptr) {
// certificate is not present
if (SSL_get_verify_mode(ssl_) & SSL_VERIFY_FAIL_IF_NO_PEER_CERT) {
throw TSSLException("authorize: required certificate not present");
}
// certificate was optional: didn't intend to authorize remote
- if (server() && access_ != NULL) {
+ if (server() && access_ != nullptr) {
throw TSSLException("authorize: certificate required for authorization");
}
return;
}
// certificate is present
- if (access_ == NULL) {
+ if (access_ == nullptr) {
X509_free(cert);
return;
}
@@ -720,13 +720,13 @@
}
// extract subjectAlternativeName
- STACK_OF(GENERAL_NAME)* alternatives
- = (STACK_OF(GENERAL_NAME)*)X509_get_ext_d2i(cert, NID_subject_alt_name, NULL, NULL);
- if (alternatives != NULL) {
+ auto* alternatives
+ = (STACK_OF(GENERAL_NAME)*)X509_get_ext_d2i(cert, NID_subject_alt_name, nullptr, nullptr);
+ if (alternatives != nullptr) {
const int count = sk_GENERAL_NAME_num(alternatives);
for (int i = 0; decision == AccessManager::SKIP && i < count; i++) {
const GENERAL_NAME* name = sk_GENERAL_NAME_value(alternatives, i);
- if (name == NULL) {
+ if (name == nullptr) {
continue;
}
char* data = (char*)ASN1_STRING_data(name->d.ia5);
@@ -756,7 +756,7 @@
// extract commonName
X509_NAME* name = X509_get_subject_name(cert);
- if (name != NULL) {
+ if (name != nullptr) {
X509_NAME_ENTRY* entry;
unsigned char* utf8;
int last = -1;
@@ -765,7 +765,7 @@
if (last == -1)
break;
entry = X509_NAME_get_entry(name, last);
- if (entry == NULL)
+ if (entry == nullptr)
continue;
ASN1_STRING* common = X509_NAME_ENTRY_get_data(entry);
int size = ASN1_STRING_to_UTF8(&utf8, common);
@@ -795,7 +795,7 @@
bio = SSL_get_wbio(ssl_);
}
- if (bio == NULL) {
+ if (bio == nullptr) {
throw TSSLException("SSL_get_?bio returned NULL");
}
@@ -908,10 +908,10 @@
void TSSLSocketFactory::setup(std::shared_ptr<TSSLSocket> ssl) {
ssl->server(server());
- if (access_ == NULL && !server()) {
+ if (access_ == nullptr && !server()) {
access_ = std::shared_ptr<AccessManager>(new DefaultClientAccessManager);
}
- if (access_ != NULL) {
+ if (access_ != nullptr) {
ssl->access(access_);
}
}
@@ -935,11 +935,11 @@
} else {
mode = SSL_VERIFY_NONE;
}
- SSL_CTX_set_verify(ctx_->get(), mode, NULL);
+ SSL_CTX_set_verify(ctx_->get(), mode, nullptr);
}
void TSSLSocketFactory::loadCertificate(const char* path, const char* format) {
- if (path == NULL || format == NULL) {
+ if (path == nullptr || format == nullptr) {
throw TTransportException(TTransportException::BAD_ARGS,
"loadCertificateChain: either <path> or <format> is NULL");
}
@@ -956,7 +956,7 @@
}
void TSSLSocketFactory::loadPrivateKey(const char* path, const char* format) {
- if (path == NULL || format == NULL) {
+ if (path == nullptr || format == nullptr) {
throw TTransportException(TTransportException::BAD_ARGS,
"loadPrivateKey: either <path> or <format> is NULL");
}
@@ -971,7 +971,7 @@
}
void TSSLSocketFactory::loadTrustedCertificates(const char* path, const char* capath) {
- if (path == NULL) {
+ if (path == nullptr) {
throw TTransportException(TTransportException::BAD_ARGS,
"loadTrustedCertificates: <path> is NULL");
}
@@ -993,7 +993,7 @@
}
int TSSLSocketFactory::passwordCallback(char* password, int size, int, void* data) {
- TSSLSocketFactory* factory = (TSSLSocketFactory*)data;
+ auto* factory = (TSSLSocketFactory*)data;
string userPassword;
factory->getPassword(userPassword, size);
int length = static_cast<int>(userPassword.size());
@@ -1016,7 +1016,7 @@
errors += "; ";
}
const char* reason = ERR_reason_error_string(errorCode);
- if (reason == NULL) {
+ if (reason == nullptr) {
THRIFT_SNPRINTF(message, sizeof(message) - 1, "SSL error # %lu", errorCode);
reason = message;
}
@@ -1054,7 +1054,7 @@
Decision DefaultClientAccessManager::verify(const string& host,
const char* name,
int size) noexcept {
- if (host.empty() || name == NULL || size <= 0) {
+ if (host.empty() || name == nullptr || size <= 0) {
return SKIP;
}
return (matchName(host.c_str(), name, size) ? ALLOW : SKIP);
diff --git a/lib/cpp/src/thrift/transport/TSSLSocket.h b/lib/cpp/src/thrift/transport/TSSLSocket.h
index 5a87d1e..8f095dc 100644
--- a/lib/cpp/src/thrift/transport/TSSLSocket.h
+++ b/lib/cpp/src/thrift/transport/TSSLSocket.h
@@ -69,19 +69,19 @@
*/
class TSSLSocket : public TSocket {
public:
- ~TSSLSocket();
+ ~TSSLSocket() override;
/**
* TTransport interface.
*/
bool isOpen();
- bool peek();
- void open();
- void close();
- bool hasPendingDataToRead();
- uint32_t read(uint8_t* buf, uint32_t len);
- void write(const uint8_t* buf, uint32_t len);
- uint32_t write_partial(const uint8_t* buf, uint32_t len);
- void flush();
+ bool peek() override;
+ void open() override;
+ void close() override;
+ bool hasPendingDataToRead() override;
+ uint32_t read(uint8_t* buf, uint32_t len) override;
+ void write(const uint8_t* buf, uint32_t len) override;
+ uint32_t write_partial(const uint8_t* buf, uint32_t len) override;
+ void flush() override;
/**
* Set whether to use client or server side SSL handshake protocol.
*
@@ -273,7 +273,7 @@
*
* @param path Path to trusted certificate file
*/
- virtual void loadTrustedCertificates(const char* path, const char* capath = NULL);
+ virtual void loadTrustedCertificates(const char* path, const char* capath = nullptr);
/**
* Default randomize method.
*/
@@ -334,7 +334,7 @@
TSSLException(const std::string& message)
: TTransportException(TTransportException::INTERNAL_ERROR, message) {}
- virtual const char* what() const noexcept {
+ const char* what() const noexcept override {
if (message_.empty()) {
return "TSSLException";
} else {
@@ -373,7 +373,7 @@
/**
* Destructor
*/
- virtual ~AccessManager() {}
+ virtual ~AccessManager() = default;
/**
* Determine whether the peer should be granted access or not. It's called
* once after the SSL handshake completes successfully, before peer certificate
@@ -425,9 +425,9 @@
class DefaultClientAccessManager : public AccessManager {
public:
// AccessManager interface
- Decision verify(const sockaddr_storage& sa) noexcept;
- Decision verify(const std::string& host, const char* name, int size) noexcept;
- Decision verify(const sockaddr_storage& sa, const char* data, int size) noexcept;
+ Decision verify(const sockaddr_storage& sa) noexcept override;
+ Decision verify(const std::string& host, const char* name, int size) noexcept override;
+ Decision verify(const sockaddr_storage& sa, const char* data, int size) noexcept override;
};
}
}
diff --git a/lib/cpp/src/thrift/transport/TServerSocket.cpp b/lib/cpp/src/thrift/transport/TServerSocket.cpp
index 118b993..1732c82 100644
--- a/lib/cpp/src/thrift/transport/TServerSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TServerSocket.cpp
@@ -85,15 +85,15 @@
TGetAddrInfoWrapper::TGetAddrInfoWrapper(const char* node,
const char* service,
const struct addrinfo* hints)
- : node_(node), service_(service), hints_(hints), res_(NULL) {}
+ : node_(node), service_(service), hints_(hints), res_(nullptr) {}
TGetAddrInfoWrapper::~TGetAddrInfoWrapper() {
- if (this->res_ != NULL)
+ if (this->res_ != nullptr)
freeaddrinfo(this->res_);
}
int TGetAddrInfoWrapper::init() {
- if (this->res_ == NULL)
+ if (this->res_ == nullptr)
return getaddrinfo(this->node_, this->service_, this->hints_, &(this->res_));
return 0;
}
@@ -268,7 +268,7 @@
hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
// If address is not specified use wildcard address (NULL)
- TGetAddrInfoWrapper info(address_.empty() ? NULL : &address_[0], port, &hints);
+ TGetAddrInfoWrapper info(address_.empty() ? nullptr : &address_[0], port, &hints);
error = info.init();
if (error) {
@@ -281,13 +281,13 @@
// Pick the ipv6 address first since ipv4 addresses can be mapped
// into ipv6 space.
for (res = info.res(); res; res = res->ai_next) {
- if (res->ai_family == AF_INET6 || res->ai_next == NULL)
+ if (res->ai_family == AF_INET6 || res->ai_next == nullptr)
break;
}
if (!path_.empty()) {
serverSocket_ = socket(PF_UNIX, SOCK_STREAM, IPPROTO_IP);
- } else if (res != NULL) {
+ } else if (res != nullptr) {
serverSocket_ = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
}
@@ -434,7 +434,7 @@
// Unix Domain Socket
size_t len = path_.size() + 1;
- if (len > sizeof(((sockaddr_un*)NULL)->sun_path)) {
+ if (len > sizeof(((sockaddr_un*)nullptr)->sun_path)) {
errno_copy = THRIFT_GET_SOCKET_ERROR;
GlobalOutput.perror("TSocket::listen() Unix Domain socket path too long", errno_copy);
throw TTransportException(TTransportException::NOT_OPEN,
@@ -446,7 +446,7 @@
address.sun_family = AF_UNIX;
memcpy(address.sun_path, path_.c_str(), len);
- socklen_t structlen = static_cast<socklen_t>(sizeof(address));
+ auto structlen = static_cast<socklen_t>(sizeof(address));
if (!address.sun_path[0]) { // abstract namespace socket
#ifdef __linux__
@@ -490,10 +490,10 @@
GlobalOutput.perror("TServerSocket::getPort() getsockname() ", errno_copy);
} else {
if (sa.ss_family == AF_INET6) {
- const struct sockaddr_in6* sin = reinterpret_cast<const struct sockaddr_in6*>(&sa);
+ const auto* sin = reinterpret_cast<const struct sockaddr_in6*>(&sa);
port_ = ntohs(sin->sin6_port);
} else {
- const struct sockaddr_in* sin = reinterpret_cast<const struct sockaddr_in*>(&sa);
+ const auto* sin = reinterpret_cast<const struct sockaddr_in*>(&sa);
port_ = ntohs(sin->sin_port);
}
}
diff --git a/lib/cpp/src/thrift/transport/TServerSocket.h b/lib/cpp/src/thrift/transport/TServerSocket.h
index b23d2c1..d640968 100644
--- a/lib/cpp/src/thrift/transport/TServerSocket.h
+++ b/lib/cpp/src/thrift/transport/TServerSocket.h
@@ -96,7 +96,7 @@
*/
TServerSocket(const std::string& path);
- virtual ~TServerSocket();
+ ~TServerSocket() override;
void setSendTimeout(int sendTimeout);
void setRecvTimeout(int recvTimeout);
@@ -136,17 +136,17 @@
// \throws std::logic_error if listen() has been called
void setInterruptableChildren(bool enable);
- THRIFT_SOCKET getSocketFD() { return serverSocket_; }
+ THRIFT_SOCKET getSocketFD() override { return serverSocket_; }
int getPort();
- void listen();
- void interrupt();
- void interruptChildren();
- void close();
+ void listen() override;
+ void interrupt() override;
+ void interruptChildren() override;
+ void close() override;
protected:
- std::shared_ptr<TTransport> acceptImpl();
+ std::shared_ptr<TTransport> acceptImpl() override;
virtual std::shared_ptr<TSocket> createSocket(THRIFT_SOCKET client);
bool interruptableChildren_;
std::shared_ptr<THRIFT_SOCKET> pChildInterruptSockReader_; // if interruptableChildren_ this is shared with child TSockets
diff --git a/lib/cpp/src/thrift/transport/TServerTransport.h b/lib/cpp/src/thrift/transport/TServerTransport.h
index db7632a..f465bb3 100644
--- a/lib/cpp/src/thrift/transport/TServerTransport.h
+++ b/lib/cpp/src/thrift/transport/TServerTransport.h
@@ -35,7 +35,7 @@
*/
class TServerTransport {
public:
- virtual ~TServerTransport() {}
+ virtual ~TServerTransport() = default;
/**
* Starts the server transport listening for new connections. Prior to this
@@ -96,7 +96,7 @@
virtual void close() = 0;
protected:
- TServerTransport() {}
+ TServerTransport() = default;
/**
* Subclasses should implement this function for accept.
diff --git a/lib/cpp/src/thrift/transport/TShortReadTransport.h b/lib/cpp/src/thrift/transport/TShortReadTransport.h
index 118252d..2151606 100644
--- a/lib/cpp/src/thrift/transport/TShortReadTransport.h
+++ b/lib/cpp/src/thrift/transport/TShortReadTransport.h
@@ -43,11 +43,11 @@
bool isOpen() { return transport_->isOpen(); }
- bool peek() { return transport_->peek(); }
+ bool peek() override { return transport_->peek(); }
- void open() { transport_->open(); }
+ void open() override { transport_->open(); }
- void close() { transport_->close(); }
+ void close() override { transport_->close(); }
uint32_t read(uint8_t* buf, uint32_t len) {
if (len == 0) {
@@ -62,7 +62,7 @@
void write(const uint8_t* buf, uint32_t len) { transport_->write(buf, len); }
- void flush() { transport_->flush(); }
+ void flush() override { transport_->flush(); }
const uint8_t* borrow(uint8_t* buf, uint32_t* len) { return transport_->borrow(buf, len); }
diff --git a/lib/cpp/src/thrift/transport/TSocket.cpp b/lib/cpp/src/thrift/transport/TSocket.cpp
index 6d5f932..977834d 100644
--- a/lib/cpp/src/thrift/transport/TSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TSocket.cpp
@@ -324,7 +324,7 @@
#ifndef _WIN32
size_t len = path_.size() + 1;
- if (len > sizeof(((sockaddr_un*)NULL)->sun_path)) {
+ if (len > sizeof(((sockaddr_un*)nullptr)->sun_path)) {
int errno_copy = THRIFT_GET_SOCKET_ERROR;
GlobalOutput.perror("TSocket::open() Unix Domain socket path too long", errno_copy);
throw TTransportException(TTransportException::NOT_OPEN, " Unix Domain socket path too long");
@@ -334,7 +334,7 @@
address.sun_family = AF_UNIX;
memcpy(address.sun_path, path_.c_str(), len);
- socklen_t structlen = static_cast<socklen_t>(sizeof(address));
+ auto structlen = static_cast<socklen_t>(sizeof(address));
if (!address.sun_path[0]) { // abstract namespace socket
#ifdef __linux__
@@ -433,7 +433,7 @@
void TSocket::unix_open() {
if (!path_.empty()) {
// Unix Domain SOcket does not need addrinfo struct, so we pass NULL
- openConnection(NULL);
+ openConnection(nullptr);
}
}
@@ -453,8 +453,8 @@
}
struct addrinfo hints, *res, *res0;
- res = NULL;
- res0 = NULL;
+ res = nullptr;
+ res0 = nullptr;
int error;
char port[sizeof("65535")];
std::memset(&hints, 0, sizeof(hints));
@@ -540,7 +540,7 @@
// Read from the socket
struct timeval begin;
if (recvTimeout_ > 0) {
- THRIFT_GETTIMEOFDAY(&begin, NULL);
+ THRIFT_GETTIMEOFDAY(&begin, nullptr);
} else {
// if there is no read timeout we don't need the TOD to determine whether
// an THRIFT_EAGAIN is due to a timeout or an out-of-resource condition.
@@ -592,8 +592,8 @@
}
// check if this is the lack of resources or timeout case
struct timeval end;
- THRIFT_GETTIMEOFDAY(&end, NULL);
- uint32_t readElapsedMicros = static_cast<uint32_t>(((end.tv_sec - begin.tv_sec) * 1000 * 1000)
+ THRIFT_GETTIMEOFDAY(&end, nullptr);
+ auto readElapsedMicros = static_cast<uint32_t>(((end.tv_sec - begin.tv_sec) * 1000 * 1000)
+ (end.tv_usec - begin.tv_usec));
if (!eagainThresholdMicros || (readElapsedMicros < eagainThresholdMicros)) {
@@ -807,7 +807,7 @@
maxRecvRetries_ = maxRecvRetries;
}
-string TSocket::getSocketInfo() {
+string TSocket::getSocketInfo() const {
std::ostringstream oss;
if (path_.empty()) {
if (host_.empty() || port_ == 0) {
@@ -822,7 +822,7 @@
return oss.str();
}
-std::string TSocket::getPeerHost() {
+std::string TSocket::getPeerHost() const {
if (peerHost_.empty() && path_.empty()) {
struct sockaddr_storage addr;
struct sockaddr* addrPtr;
@@ -834,14 +834,14 @@
addrPtr = getCachedAddress(&addrLen);
- if (addrPtr == NULL) {
+ if (addrPtr == nullptr) {
addrLen = sizeof(addr);
if (getpeername(socket_, (sockaddr*)&addr, &addrLen) != 0) {
return peerHost_;
}
addrPtr = (sockaddr*)&addr;
- setCachedAddress(addrPtr, addrLen);
+ const_cast<TSocket&>(*this).setCachedAddress(addrPtr, addrLen);
}
char clienthost[NI_MAXHOST];
@@ -860,7 +860,7 @@
return peerHost_;
}
-std::string TSocket::getPeerAddress() {
+std::string TSocket::getPeerAddress() const {
if (peerAddress_.empty() && path_.empty()) {
struct sockaddr_storage addr;
struct sockaddr* addrPtr;
@@ -872,14 +872,14 @@
addrPtr = getCachedAddress(&addrLen);
- if (addrPtr == NULL) {
+ if (addrPtr == nullptr) {
addrLen = sizeof(addr);
if (getpeername(socket_, (sockaddr*)&addr, &addrLen) != 0) {
return peerAddress_;
}
addrPtr = (sockaddr*)&addr;
- setCachedAddress(addrPtr, addrLen);
+ const_cast<TSocket&>(*this).setCachedAddress(addrPtr, addrLen);
}
char clienthost[NI_MAXHOST];
@@ -899,7 +899,7 @@
return peerAddress_;
}
-int TSocket::getPeerPort() {
+int TSocket::getPeerPort() const {
getPeerAddress();
return peerPort_;
}
@@ -937,7 +937,7 @@
return (sockaddr*)&cachedPeerAddr_.ipv6;
default:
- return NULL;
+ return nullptr;
}
}
@@ -949,7 +949,7 @@
return useLowMinRto_;
}
-const std::string TSocket::getOrigin() {
+const std::string TSocket::getOrigin() const {
std::ostringstream oss;
oss << getPeerHost() << ":" << getPeerPort();
return oss.str();
diff --git a/lib/cpp/src/thrift/transport/TSocket.h b/lib/cpp/src/thrift/transport/TSocket.h
index 9dcd2d6..b0e8ade 100644
--- a/lib/cpp/src/thrift/transport/TSocket.h
+++ b/lib/cpp/src/thrift/transport/TSocket.h
@@ -74,7 +74,7 @@
/**
* Destroyes the socket object, closing it if necessary.
*/
- virtual ~TSocket();
+ ~TSocket() override;
/**
* Whether the socket is alive.
@@ -208,22 +208,22 @@
/**
* Get socket information formatted as a string <Host: x Port: x>
*/
- std::string getSocketInfo();
+ std::string getSocketInfo() const;
/**
* Returns the DNS name of the host to which the socket is connected
*/
- std::string getPeerHost();
+ std::string getPeerHost() const;
/**
* Returns the address of the host to which the socket is connected
*/
- std::string getPeerAddress();
+ std::string getPeerAddress() const;
/**
* Returns the port of the host to which the socket is connected
**/
- int getPeerPort();
+ int getPeerPort() const;
/**
* Returns the underlying socket file descriptor.
@@ -259,7 +259,7 @@
*
* @return string peer host identifier and port
*/
- virtual const std::string getOrigin();
+ const std::string getOrigin() const override;
/**
* Constructor to create socket from file descriptor.
@@ -295,13 +295,13 @@
THRIFT_SOCKET socket_;
/** Peer hostname */
- std::string peerHost_;
+ mutable std::string peerHost_;
/** Peer address */
- std::string peerAddress_;
+ mutable std::string peerAddress_;
/** Peer port */
- int peerPort_;
+ mutable int peerPort_;
/**
* A shared socket pointer that will interrupt a blocking read if data
diff --git a/lib/cpp/src/thrift/transport/TSocketPool.cpp b/lib/cpp/src/thrift/transport/TSocketPool.cpp
index 5477bbb..89eee6e 100644
--- a/lib/cpp/src/thrift/transport/TSocketPool.cpp
+++ b/lib/cpp/src/thrift/transport/TSocketPool.cpp
@@ -216,7 +216,7 @@
if (server->lastFailTime_ > 0) {
// The server was marked as down, so check if enough time has elapsed to retry
- time_t elapsedTime = time(NULL) - server->lastFailTime_;
+ time_t elapsedTime = time(nullptr) - server->lastFailTime_;
if (elapsedTime > retryInterval_) {
retryIntervalPassed = true;
}
@@ -245,7 +245,7 @@
if (server->consecutiveFailures_ > maxConsecutiveFailures_) {
// Mark server as down
server->consecutiveFailures_ = 0;
- server->lastFailTime_ = time(NULL);
+ server->lastFailTime_ = time(nullptr);
}
}
}
diff --git a/lib/cpp/src/thrift/transport/TSocketPool.h b/lib/cpp/src/thrift/transport/TSocketPool.h
index 18f101c..97a2b90 100644
--- a/lib/cpp/src/thrift/transport/TSocketPool.h
+++ b/lib/cpp/src/thrift/transport/TSocketPool.h
@@ -105,7 +105,7 @@
/**
* Destroyes the socket object, closing it if necessary.
*/
- virtual ~TSocketPool();
+ ~TSocketPool() override;
/**
* Add a server to the pool
@@ -155,12 +155,12 @@
/**
* Creates and opens the UNIX socket.
*/
- void open();
+ void open() override;
/*
* Closes the UNIX socket
*/
- void close();
+ void close() override;
protected:
void setCurrentServer(const std::shared_ptr<TSocketPoolServer>& server);
diff --git a/lib/cpp/src/thrift/transport/TTransport.h b/lib/cpp/src/thrift/transport/TTransport.h
index 0f92277..891bfe1 100644
--- a/lib/cpp/src/thrift/transport/TTransport.h
+++ b/lib/cpp/src/thrift/transport/TTransport.h
@@ -58,7 +58,7 @@
/**
* Virtual deconstructor.
*/
- virtual ~TTransport() {}
+ virtual ~TTransport() = default;
/**
* Whether this transport is open.
@@ -209,7 +209,7 @@
T_VIRTUAL_CALL();
return borrow_virt(buf, len);
}
- virtual const uint8_t* borrow_virt(uint8_t* /* buf */, uint32_t* /* len */) { return NULL; }
+ virtual const uint8_t* borrow_virt(uint8_t* /* buf */, uint32_t* /* len */) { return nullptr; }
/**
* Remove len bytes from the transport. This should always follow a borrow
@@ -236,13 +236,13 @@
*
* The returned value can be used in a log message for example
*/
- virtual const std::string getOrigin() { return "Unknown"; }
+ virtual const std::string getOrigin() const { return "Unknown"; }
protected:
/**
* Simple constructor.
*/
- TTransport() {}
+ TTransport() = default;
};
/**
@@ -253,9 +253,9 @@
*/
class TTransportFactory {
public:
- TTransportFactory() {}
+ TTransportFactory() = default;
- virtual ~TTransportFactory() {}
+ virtual ~TTransportFactory() = default;
/**
* Default implementation does nothing, just returns the transport given.
diff --git a/lib/cpp/src/thrift/transport/TTransportException.h b/lib/cpp/src/thrift/transport/TTransportException.h
index fb5f00c..38b7521 100644
--- a/lib/cpp/src/thrift/transport/TTransportException.h
+++ b/lib/cpp/src/thrift/transport/TTransportException.h
@@ -65,7 +65,7 @@
TTransportException(TTransportExceptionType type, const std::string& message, int errno_copy)
: apache::thrift::TException(message + ": " + TOutput::strerror_s(errno_copy)), type_(type) {}
- virtual ~TTransportException() noexcept {}
+ ~TTransportException() noexcept override = default;
/**
* Returns an error code that provides information about the type of error
@@ -75,7 +75,7 @@
*/
TTransportExceptionType getType() const noexcept { return type_; }
- virtual const char* what() const noexcept;
+ const char* what() const noexcept override;
protected:
/** Just like strerror_r but returns a C++ string object. */
diff --git a/lib/cpp/src/thrift/transport/TTransportUtils.cpp b/lib/cpp/src/thrift/transport/TTransportUtils.cpp
index eedcde1..69372f3 100644
--- a/lib/cpp/src/thrift/transport/TTransportUtils.cpp
+++ b/lib/cpp/src/thrift/transport/TTransportUtils.cpp
@@ -41,8 +41,8 @@
// Double the size of the underlying buffer if it is full
if (rLen_ == rBufSize_) {
rBufSize_ *= 2;
- uint8_t *tmpBuf = (uint8_t*)std::realloc(rBuf_, sizeof(uint8_t) * rBufSize_);
- if (tmpBuf == NULL) {
+ auto *tmpBuf = (uint8_t*)std::realloc(rBuf_, sizeof(uint8_t) * rBufSize_);
+ if (tmpBuf == nullptr) {
throw std::bad_alloc();
}
rBuf_ = tmpBuf;
@@ -77,8 +77,8 @@
while ((len + wLen_) >= newBufSize) {
newBufSize *= 2;
}
- uint8_t *tmpBuf= (uint8_t*)std::realloc(wBuf_, sizeof(uint8_t) * newBufSize);
- if (tmpBuf == NULL) {
+ auto *tmpBuf= (uint8_t*)std::realloc(wBuf_, sizeof(uint8_t) * newBufSize);
+ if (tmpBuf == nullptr) {
throw std::bad_alloc();
}
wBuf_ = tmpBuf;
@@ -108,8 +108,7 @@
: TPipedTransport(srcTrans, dstTrans), srcTrans_(srcTrans) {
}
-TPipedFileReaderTransport::~TPipedFileReaderTransport() {
-}
+TPipedFileReaderTransport::~TPipedFileReaderTransport() = default;
bool TPipedFileReaderTransport::isOpen() const {
return TPipedTransport::isOpen();
diff --git a/lib/cpp/src/thrift/transport/TTransportUtils.h b/lib/cpp/src/thrift/transport/TTransportUtils.h
index 8d67763..6cff76a 100644
--- a/lib/cpp/src/thrift/transport/TTransportUtils.h
+++ b/lib/cpp/src/thrift/transport/TTransportUtils.h
@@ -42,13 +42,13 @@
*/
class TNullTransport : public TVirtualTransport<TNullTransport> {
public:
- TNullTransport() {}
+ TNullTransport() = default;
- ~TNullTransport() {}
+ ~TNullTransport() override = default;
bool isOpen() { return true; }
- void open() {}
+ void open() override {}
void write(const uint8_t* /* buf */, uint32_t /* len */) { return; }
};
@@ -77,11 +77,11 @@
pipeOnWrite_ = false;
rBuf_ = (uint8_t*)std::malloc(sizeof(uint8_t) * rBufSize_);
- if (rBuf_ == NULL) {
+ if (rBuf_ == nullptr) {
throw std::bad_alloc();
}
wBuf_ = (uint8_t*)std::malloc(sizeof(uint8_t) * wBufSize_);
- if (wBuf_ == NULL) {
+ if (wBuf_ == nullptr) {
throw std::bad_alloc();
}
}
@@ -98,16 +98,16 @@
wLen_(0) {
rBuf_ = (uint8_t*)std::malloc(sizeof(uint8_t) * rBufSize_);
- if (rBuf_ == NULL) {
+ if (rBuf_ == nullptr) {
throw std::bad_alloc();
}
wBuf_ = (uint8_t*)std::malloc(sizeof(uint8_t) * wBufSize_);
- if (wBuf_ == NULL) {
+ if (wBuf_ == nullptr) {
throw std::bad_alloc();
}
}
- ~TPipedTransport() {
+ ~TPipedTransport() override {
std::free(rBuf_);
std::free(wBuf_);
}
@@ -119,8 +119,8 @@
// Double the size of the underlying buffer if it is full
if (rLen_ == rBufSize_) {
rBufSize_ *= 2;
- uint8_t * tmpBuf = (uint8_t*)std::realloc(rBuf_, sizeof(uint8_t) * rBufSize_);
- if (tmpBuf == NULL) {
+ auto * tmpBuf = (uint8_t*)std::realloc(rBuf_, sizeof(uint8_t) * rBufSize_);
+ if (tmpBuf == nullptr) {
throw std::bad_alloc();
}
rBuf_ = tmpBuf;
@@ -142,7 +142,7 @@
uint32_t read(uint8_t* buf, uint32_t len);
- uint32_t readEnd() {
+ uint32_t readEnd() override {
if (pipeOnRead_) {
dstTrans_->write(rBuf_, rPos_);
@@ -164,7 +164,7 @@
void write(const uint8_t* buf, uint32_t len);
- uint32_t writeEnd() {
+ uint32_t writeEnd() override {
if (pipeOnWrite_) {
dstTrans_->write(wBuf_, wLen_);
dstTrans_->flush();
@@ -172,7 +172,7 @@
return wLen_;
}
- void flush();
+ void flush() override;
std::shared_ptr<TTransport> getTargetTransport() { return dstTrans_; }
@@ -207,11 +207,11 @@
*/
class TPipedTransportFactory : public TTransportFactory {
public:
- TPipedTransportFactory() {}
+ TPipedTransportFactory() = default;
TPipedTransportFactory(std::shared_ptr<TTransport> dstTrans) {
initializeTargetTransport(dstTrans);
}
- virtual ~TPipedTransportFactory() {}
+ ~TPipedTransportFactory() override = default;
/**
* Wraps the base transport into a piped transport.
@@ -221,7 +221,7 @@
}
virtual void initializeTargetTransport(std::shared_ptr<TTransport> dstTrans) {
- if (dstTrans_.get() == NULL) {
+ if (dstTrans_.get() == nullptr) {
dstTrans_ = dstTrans;
} else {
throw TException("Target transport already initialized");
@@ -243,7 +243,7 @@
TPipedFileReaderTransport(std::shared_ptr<TFileReaderTransport> srcTrans,
std::shared_ptr<TTransport> dstTrans);
- ~TPipedFileReaderTransport();
+ ~TPipedFileReaderTransport() override;
// TTransport functions
bool isOpen() const override;
@@ -252,18 +252,18 @@
void close() override;
uint32_t read(uint8_t* buf, uint32_t len);
uint32_t readAll(uint8_t* buf, uint32_t len);
- uint32_t readEnd();
+ uint32_t readEnd() override;
void write(const uint8_t* buf, uint32_t len);
- uint32_t writeEnd();
- void flush();
+ uint32_t writeEnd() override;
+ void flush() override;
// TFileReaderTransport functions
- int32_t getReadTimeout();
- void setReadTimeout(int32_t readTimeout);
- uint32_t getNumChunks();
- uint32_t getCurChunk();
- void seekToChunk(int32_t chunk);
- void seekToEnd();
+ int32_t getReadTimeout() override;
+ void setReadTimeout(int32_t readTimeout) override;
+ uint32_t getNumChunks() override;
+ uint32_t getCurChunk() override;
+ void seekToChunk(int32_t chunk) override;
+ void seekToEnd() override;
/*
* Override TTransport *_virt() functions to invoke our implementations.
@@ -286,15 +286,15 @@
*/
class TPipedFileReaderTransportFactory : public TPipedTransportFactory {
public:
- TPipedFileReaderTransportFactory() {}
+ TPipedFileReaderTransportFactory() = default;
TPipedFileReaderTransportFactory(std::shared_ptr<TTransport> dstTrans)
: TPipedTransportFactory(dstTrans) {}
- virtual ~TPipedFileReaderTransportFactory() {}
+ ~TPipedFileReaderTransportFactory() override = default;
- std::shared_ptr<TTransport> getTransport(std::shared_ptr<TTransport> srcTrans) {
+ std::shared_ptr<TTransport> getTransport(std::shared_ptr<TTransport> srcTrans) override {
std::shared_ptr<TFileReaderTransport> pFileReaderTransport
= std::dynamic_pointer_cast<TFileReaderTransport>(srcTrans);
- if (pFileReaderTransport.get() != NULL) {
+ if (pFileReaderTransport.get() != nullptr) {
return getFileReaderTransport(pFileReaderTransport);
} else {
return std::shared_ptr<TTransport>();
diff --git a/lib/cpp/src/thrift/transport/TVirtualTransport.h b/lib/cpp/src/thrift/transport/TVirtualTransport.h
index b5518cc..0a04857 100644
--- a/lib/cpp/src/thrift/transport/TVirtualTransport.h
+++ b/lib/cpp/src/thrift/transport/TVirtualTransport.h
@@ -57,7 +57,7 @@
void consume(uint32_t len) { this->TTransport::consume_virt(len); }
protected:
- TTransportDefaults() {}
+ TTransportDefaults() = default;
};
/**
@@ -113,12 +113,12 @@
* the correct parent implementation, if desired.
*/
uint32_t readAll(uint8_t* buf, uint32_t len) {
- Transport_* trans = static_cast<Transport_*>(this);
+ auto* trans = static_cast<Transport_*>(this);
return ::apache::thrift::transport::readAll(*trans, buf, len);
}
protected:
- TVirtualTransport() {}
+ TVirtualTransport() = default;
/*
* Templatized constructors, to allow arguments to be passed to the Super_
diff --git a/lib/cpp/src/thrift/transport/TZlibTransport.cpp b/lib/cpp/src/thrift/transport/TZlibTransport.cpp
index e426dc3..ddceb99 100644
--- a/lib/cpp/src/thrift/transport/TZlibTransport.cpp
+++ b/lib/cpp/src/thrift/transport/TZlibTransport.cpp
@@ -331,7 +331,7 @@
*len = (uint32_t)readAvail();
return urbuf_ + urpos_;
}
- return NULL;
+ return nullptr;
}
void TZlibTransport::consume(uint32_t len) {
diff --git a/lib/cpp/src/thrift/transport/TZlibTransport.h b/lib/cpp/src/thrift/transport/TZlibTransport.h
index a9b2664..be2d198 100644
--- a/lib/cpp/src/thrift/transport/TZlibTransport.h
+++ b/lib/cpp/src/thrift/transport/TZlibTransport.h
@@ -36,9 +36,9 @@
TZlibTransportException(int status, const char* msg)
: TTransportException(TTransportException::INTERNAL_ERROR, errorMessage(status, msg)),
zlib_status_(status),
- zlib_msg_(msg == NULL ? "(null)" : msg) {}
+ zlib_msg_(msg == nullptr ? "(null)" : msg) {}
- virtual ~TZlibTransportException() noexcept {}
+ ~TZlibTransportException() noexcept override = default;
int getZlibStatus() { return zlib_status_; }
std::string getZlibMessage() { return zlib_msg_; }
@@ -93,12 +93,12 @@
crbuf_size_(crbuf_size),
uwbuf_size_(uwbuf_size),
cwbuf_size_(cwbuf_size),
- urbuf_(NULL),
- crbuf_(NULL),
- uwbuf_(NULL),
- cwbuf_(NULL),
- rstream_(NULL),
- wstream_(NULL),
+ urbuf_(nullptr),
+ crbuf_(nullptr),
+ uwbuf_(nullptr),
+ cwbuf_(nullptr),
+ rstream_(nullptr),
+ wstream_(nullptr),
comp_level_(comp_level) {
if (uwbuf_size_ < MIN_DIRECT_DEFLATE_SIZE) {
// Have to copy this into a local because of a linking issue.
@@ -136,20 +136,20 @@
* unflushed data. You must explicitly call flush() or finish() to ensure
* that data is actually written and flushed to the underlying transport.
*/
- ~TZlibTransport();
+ ~TZlibTransport() override;
bool isOpen();
- bool peek();
+ bool peek() override;
- void open() { transport_->open(); }
+ void open() override { transport_->open(); }
- void close() { transport_->close(); }
+ void close() override { transport_->close(); }
uint32_t read(uint8_t* buf, uint32_t len);
void write(const uint8_t* buf, uint32_t len);
- void flush();
+ void flush() override;
/**
* Finalize the zlib stream.
@@ -227,9 +227,9 @@
*/
class TZlibTransportFactory : public TTransportFactory {
public:
- TZlibTransportFactory() {}
+ TZlibTransportFactory() = default;
- virtual ~TZlibTransportFactory() {}
+ ~TZlibTransportFactory() override = default;
std::shared_ptr<TTransport> getTransport(std::shared_ptr<TTransport> trans) override {
return std::shared_ptr<TTransport>(new TZlibTransport(trans));
diff --git a/lib/cpp/test/Benchmark.cpp b/lib/cpp/test/Benchmark.cpp
index 5ff77aa..56adac0 100644
--- a/lib/cpp/test/Benchmark.cpp
+++ b/lib/cpp/test/Benchmark.cpp
@@ -36,12 +36,12 @@
public:
timeval vStart;
- Timer() { THRIFT_GETTIMEOFDAY(&vStart, 0); }
- void start() { THRIFT_GETTIMEOFDAY(&vStart, 0); }
+ Timer() { THRIFT_GETTIMEOFDAY(&vStart, nullptr); }
+ void start() { THRIFT_GETTIMEOFDAY(&vStart, nullptr); }
double frame() {
timeval vEnd;
- THRIFT_GETTIMEOFDAY(&vEnd, 0);
+ THRIFT_GETTIMEOFDAY(&vEnd, nullptr);
double dstart = vStart.tv_sec + ((double)vStart.tv_usec / 1000000.0);
double dend = vEnd.tv_sec + ((double)vEnd.tv_usec / 1000000.0);
return dend - dstart;
@@ -70,7 +70,7 @@
int num = 100000;
std::shared_ptr<TMemoryBuffer> buf(new TMemoryBuffer(num*1000));
- uint8_t* data = NULL;
+ uint8_t* data = nullptr;
uint32_t datasize = 0;
{
@@ -157,7 +157,7 @@
}
- data = NULL;
+ data = nullptr;
datasize = 0;
num = 10000000;
diff --git a/lib/cpp/test/EnumTest.cpp b/lib/cpp/test/EnumTest.cpp
index c935bc4..6487906 100644
--- a/lib/cpp/test/EnumTest.cpp
+++ b/lib/cpp/test/EnumTest.cpp
@@ -75,7 +75,7 @@
BOOST_CHECK_EQUAL(EnumToString(MyEnumWithCustomOstream::CustoM2), "{2:CUSTOM!}");
// some invalid or unknown value
- MyEnum5::type uut = (MyEnum5::type)44;
+ auto uut = (MyEnum5::type)44;
BOOST_CHECK_EQUAL(EnumToString(uut), "44");
}
diff --git a/lib/cpp/test/OneWayHTTPTest.cpp b/lib/cpp/test/OneWayHTTPTest.cpp
index f369d8c..55d919b 100644
--- a/lib/cpp/test/OneWayHTTPTest.cpp
+++ b/lib/cpp/test/OneWayHTTPTest.cpp
@@ -66,14 +66,14 @@
class OneWayServiceHandler : public onewaytest::OneWayServiceIf {
public:
- OneWayServiceHandler() {}
+ OneWayServiceHandler() = default;
void roundTripRPC() override {
#ifdef ENABLE_STDERR_LOGGING
cerr << "roundTripRPC()" << endl;
#endif
}
- void oneWayRPC() {
+ void oneWayRPC() override {
#ifdef ENABLE_STDERR_LOGGING
cerr << "oneWayRPC()" << std::endl ;
#endif
@@ -82,13 +82,13 @@
class OneWayServiceCloneFactory : virtual public onewaytest::OneWayServiceIfFactory {
public:
- virtual ~OneWayServiceCloneFactory() {}
- virtual onewaytest::OneWayServiceIf* getHandler(const ::apache::thrift::TConnectionInfo& connInfo)
+ ~OneWayServiceCloneFactory() override = default;
+ onewaytest::OneWayServiceIf* getHandler(const ::apache::thrift::TConnectionInfo& connInfo) override
{
(void)connInfo ;
return new OneWayServiceHandler;
}
- virtual void releaseHandler( onewaytest::OneWayServiceIf* handler) {
+ void releaseHandler( onewaytest::OneWayServiceIf* handler) override {
delete handler;
}
};
@@ -96,7 +96,7 @@
class RPC0ThreadClass {
public:
RPC0ThreadClass(TThreadedServer& server) : server_(server) { } // Constructor
-~RPC0ThreadClass() { } // Destructor
+~RPC0ThreadClass() = default; // Destructor
void Run() {
server_.serve() ;
@@ -112,21 +112,21 @@
class TServerReadyEventHandler : public TServerEventHandler, public Monitor {
public:
TServerReadyEventHandler() : isListening_(false), accepted_(0) {}
- virtual ~TServerReadyEventHandler() {}
- virtual void preServe() {
+ ~TServerReadyEventHandler() override = default;
+ void preServe() override {
Synchronized sync(*this);
isListening_ = true;
notify();
}
- virtual void* createContext(shared_ptr<TProtocol> input,
- shared_ptr<TProtocol> output) {
+ void* createContext(shared_ptr<TProtocol> input,
+ shared_ptr<TProtocol> output) override {
Synchronized sync(*this);
++accepted_;
notify();
(void)input;
(void)output;
- return NULL;
+ return nullptr;
}
bool isListening() const { return isListening_; }
uint64_t acceptedCount() const { return accepted_; }
@@ -144,7 +144,7 @@
}
uint32_t write_buffer_length() {
- uint32_t have_bytes = static_cast<uint32_t>(wBase_ - wBuf_.get());
+ auto have_bytes = static_cast<uint32_t>(wBase_ - wBuf_.get());
return have_bytes ;
}
diff --git a/lib/cpp/test/OpenSSLManualInitTest.cpp b/lib/cpp/test/OpenSSLManualInitTest.cpp
index a30b303..a751806 100644
--- a/lib/cpp/test/OpenSSLManualInitTest.cpp
+++ b/lib/cpp/test/OpenSSLManualInitTest.cpp
@@ -62,7 +62,7 @@
// uninitialized. It might also fail on very old versions of
// OpenSSL...
const EVP_MD* md = EVP_get_digestbyname("SHA256");
- BOOST_CHECK(md != NULL);
+ BOOST_CHECK(md != nullptr);
openssl_cleanup();
}
diff --git a/lib/cpp/test/RecursiveTest.cpp b/lib/cpp/test/RecursiveTest.cpp
index 15f234c..ab2e46d 100644
--- a/lib/cpp/test/RecursiveTest.cpp
+++ b/lib/cpp/test/RecursiveTest.cpp
@@ -60,8 +60,8 @@
RecList resultlist;
resultlist.read(prot.get());
- BOOST_CHECK(resultlist.nextitem != NULL);
- BOOST_CHECK(resultlist.nextitem->nextitem == NULL);
+ BOOST_CHECK(resultlist.nextitem != nullptr);
+ BOOST_CHECK(resultlist.nextitem->nextitem == nullptr);
}
BOOST_AUTO_TEST_CASE(test_recursive_3) {
@@ -75,8 +75,8 @@
c.write(prot.get());
c.read(prot.get());
- BOOST_CHECK(c.other != NULL);
- BOOST_CHECK(c.other->other.other == NULL);
+ BOOST_CHECK(c.other != nullptr);
+ BOOST_CHECK(c.other->other.other == nullptr);
}
BOOST_AUTO_TEST_CASE(test_recursive_4) {
diff --git a/lib/cpp/test/TFileTransportTest.cpp b/lib/cpp/test/TFileTransportTest.cpp
index d0c26b3..ad32185 100644
--- a/lib/cpp/test/TFileTransportTest.cpp
+++ b/lib/cpp/test/TFileTransportTest.cpp
@@ -64,12 +64,12 @@
};
typedef std::list<FsyncCall> CallList;
- FsyncLog() {}
+ FsyncLog() = default;
void fsync(int fd) {
(void)fd;
FsyncCall call;
- THRIFT_GETTIMEOFDAY(&call.time, NULL);
+ THRIFT_GETTIMEOFDAY(&call.time, nullptr);
calls_.push_back(call);
}
@@ -123,7 +123,7 @@
if (path_) {
::unlink(path_);
delete[] path_;
- path_ = NULL;
+ path_ = nullptr;
}
}
@@ -195,9 +195,9 @@
struct timeval start;
struct timeval end;
- THRIFT_GETTIMEOFDAY(&start, NULL);
+ THRIFT_GETTIMEOFDAY(&start, nullptr);
delete transport;
- THRIFT_GETTIMEOFDAY(&end, NULL);
+ THRIFT_GETTIMEOFDAY(&end, nullptr);
int delta = time_diff(&start, &end);
@@ -264,7 +264,7 @@
delete transport;
// Stop logging new fsync() calls
- fsync_log = NULL;
+ fsync_log = nullptr;
// Examine the fsync() log
//
@@ -278,8 +278,8 @@
// Make sure TFileTransport called fsync at least once
BOOST_WARN_GE(calls->size(), static_cast<FsyncLog::CallList::size_type>(1));
- const struct timeval* prev_time = NULL;
- for (FsyncLog::CallList::const_iterator it = calls->begin(); it != calls->end(); ++it) {
+ const struct timeval* prev_time = nullptr;
+ for (auto it = calls->begin(); it != calls->end(); ++it) {
if (prev_time) {
int delta = time_diff(prev_time, &it->time);
BOOST_WARN( delta < max_allowed_delta );
@@ -318,13 +318,13 @@
transport.write(buf, 1);
struct timeval start;
- THRIFT_GETTIMEOFDAY(&start, NULL);
+ THRIFT_GETTIMEOFDAY(&start, nullptr);
for (unsigned int n = 0; n < 10; ++n) {
transport.flush();
struct timeval now;
- THRIFT_GETTIMEOFDAY(&now, NULL);
+ THRIFT_GETTIMEOFDAY(&now, nullptr);
// Fail if at any point we've been running for longer than half a second.
// (With the buggy code, TFileTransport used to take 3 seconds per flush())
@@ -349,11 +349,11 @@
void parse_args(int argc, char* argv[]) {
struct option long_opts[]
- = {{"help", false, NULL, 'h'}, {"tmp-dir", true, NULL, 't'}, {NULL, 0, NULL, 0}};
+ = {{"help", false, nullptr, 'h'}, {"tmp-dir", true, nullptr, 't'}, {nullptr, 0, nullptr, 0}};
while (true) {
optopt = 1;
- int optchar = getopt_long(argc, argv, "ht:", long_opts, NULL);
+ int optchar = getopt_long(argc, argv, "ht:", long_opts, nullptr);
if (optchar == -1) {
break;
}
@@ -378,7 +378,7 @@
#ifdef BOOST_TEST_DYN_LINK
static int myArgc = 0;
-static char **myArgv = NULL;
+static char **myArgv = nullptr;
bool init_unit_test_suite() {
boost::unit_test::framework::master_test_suite().p_name.value = "TFileTransportTest";
diff --git a/lib/cpp/test/TNonblockingSSLServerTest.cpp b/lib/cpp/test/TNonblockingSSLServerTest.cpp
index 2111de8..d0d8688 100644
--- a/lib/cpp/test/TNonblockingSSLServerTest.cpp
+++ b/lib/cpp/test/TNonblockingSSLServerTest.cpp
@@ -39,17 +39,17 @@
using apache::thrift::transport::TSSLSocket;
struct Handler : public test::ParentServiceIf {
- void addString(const std::string& s) { strings_.push_back(s); }
- void getStrings(std::vector<std::string>& _return) { _return = strings_; }
+ void addString(const std::string& s) override { strings_.push_back(s); }
+ void getStrings(std::vector<std::string>& _return) override { _return = strings_; }
std::vector<std::string> strings_;
// dummy overrides not used in this test
- int32_t incrementGeneration() { return 0; }
- int32_t getGeneration() { return 0; }
- void getDataWait(std::string&, const int32_t) {}
- void onewayWait() {}
- void exceptionWait(const std::string&) {}
- void unexpectedExceptionWait(const std::string&) {}
+ int32_t incrementGeneration() override { return 0; }
+ int32_t getGeneration() override { return 0; }
+ void getDataWait(std::string&, const int32_t) override {}
+ void onewayWait() override {}
+ void exceptionWait(const std::string&) override {}
+ void unexpectedExceptionWait(const std::string&) override {}
};
boost::filesystem::path keyDir;
@@ -131,7 +131,7 @@
public:
ListenEventHandler(Mutex* mutex) : listenMonitor_(mutex), ready_(false) {}
- void preServe() /* override */ {
+ void preServe() override /* override */ {
Guard g(listenMonitor_.mutex());
ready_ = true;
listenMonitor_.notify();
@@ -155,7 +155,7 @@
listenHandler.reset(new ListenEventHandler(&mutex_));
}
- virtual void run() {
+ void run() override {
// When binding to explicit port, allow retrying to workaround bind failures on ports in use
int retryCount = port ? 10 : 0;
pServerSocketFactory = createServerSocketFactory();
diff --git a/lib/cpp/test/TNonblockingServerTest.cpp b/lib/cpp/test/TNonblockingServerTest.cpp
index f2f5922..434217e 100644
--- a/lib/cpp/test/TNonblockingServerTest.cpp
+++ b/lib/cpp/test/TNonblockingServerTest.cpp
@@ -44,17 +44,17 @@
using namespace apache::thrift;
struct Handler : public test::ParentServiceIf {
- void addString(const std::string& s) { strings_.push_back(s); }
- void getStrings(std::vector<std::string>& _return) { _return = strings_; }
+ void addString(const std::string& s) override { strings_.push_back(s); }
+ void getStrings(std::vector<std::string>& _return) override { _return = strings_; }
std::vector<std::string> strings_;
// dummy overrides not used in this test
- int32_t incrementGeneration() { return 0; }
- int32_t getGeneration() { return 0; }
- void getDataWait(std::string&, const int32_t) {}
- void onewayWait() {}
- void exceptionWait(const std::string&) {}
- void unexpectedExceptionWait(const std::string&) {}
+ int32_t incrementGeneration() override { return 0; }
+ int32_t getGeneration() override { return 0; }
+ void getDataWait(std::string&, const int32_t) override {}
+ void onewayWait() override {}
+ void exceptionWait(const std::string&) override {}
+ void unexpectedExceptionWait(const std::string&) override {}
};
class Fixture {
@@ -63,7 +63,7 @@
public:
ListenEventHandler(Mutex* mutex) : listenMonitor_(mutex), ready_(false) {}
- void preServe() /* override */ {
+ void preServe() override /* override */ {
Guard g(listenMonitor_.mutex());
ready_ = true;
listenMonitor_.notify();
@@ -86,7 +86,7 @@
listenHandler.reset(new ListenEventHandler(&mutex_));
}
- virtual void run() {
+ void run() override {
// When binding to explicit port, allow retrying to workaround bind failures on ports in use
int retryCount = port ? 10 : 0;
startServer(retryCount);
diff --git a/lib/cpp/test/TServerIntegrationTest.cpp b/lib/cpp/test/TServerIntegrationTest.cpp
index a7680d8..b88c35b 100644
--- a/lib/cpp/test/TServerIntegrationTest.cpp
+++ b/lib/cpp/test/TServerIntegrationTest.cpp
@@ -74,21 +74,21 @@
class TServerReadyEventHandler : public TServerEventHandler, public Monitor {
public:
TServerReadyEventHandler() : isListening_(false), accepted_(0) {}
- virtual ~TServerReadyEventHandler() {}
- virtual void preServe() {
+ ~TServerReadyEventHandler() override = default;
+ void preServe() override {
Synchronized sync(*this);
isListening_ = true;
notify();
}
- virtual void* createContext(shared_ptr<TProtocol> input,
- shared_ptr<TProtocol> output) {
+ void* createContext(shared_ptr<TProtocol> input,
+ shared_ptr<TProtocol> output) override {
Synchronized sync(*this);
++accepted_;
notify();
(void)input;
(void)output;
- return NULL;
+ return nullptr;
}
bool isListening() const { return isListening_; }
uint64_t acceptedCount() const { return accepted_; }
@@ -105,36 +105,36 @@
public:
ParentHandler() : generation_(0) {}
- int32_t incrementGeneration() {
+ int32_t incrementGeneration() override {
Guard g(mutex_);
return ++generation_;
}
- int32_t getGeneration() {
+ int32_t getGeneration() override {
Guard g(mutex_);
return generation_;
}
- void addString(const std::string& s) {
+ void addString(const std::string& s) override {
Guard g(mutex_);
strings_.push_back(s);
}
- void getStrings(std::vector<std::string>& _return) {
+ void getStrings(std::vector<std::string>& _return) override {
Guard g(mutex_);
_return = strings_;
}
- void getDataWait(std::string& _return, const int32_t length) {
+ void getDataWait(std::string& _return, const int32_t length) override {
THRIFT_UNUSED_VARIABLE(_return);
THRIFT_UNUSED_VARIABLE(length);
}
- void onewayWait() {}
+ void onewayWait() override {}
- void exceptionWait(const std::string& message) { THRIFT_UNUSED_VARIABLE(message); }
+ void exceptionWait(const std::string& message) override { THRIFT_UNUSED_VARIABLE(message); }
- void unexpectedExceptionWait(const std::string& message) { THRIFT_UNUSED_VARIABLE(message); }
+ void unexpectedExceptionWait(const std::string& message) override { THRIFT_UNUSED_VARIABLE(message); }
protected:
Mutex mutex_;
@@ -264,7 +264,7 @@
* \returns the server port number
*/
int getServerPort() {
- TServerSocket* pSock = dynamic_cast<TServerSocket*>(pServer->getServerTransport().get());
+ auto* pSock = dynamic_cast<TServerSocket*>(pServer->getServerTransport().get());
if (!pSock) { throw std::logic_error("how come?"); }
return pSock->getPort();
}
diff --git a/lib/cpp/test/TServerTransportTest.cpp b/lib/cpp/test/TServerTransportTest.cpp
index 539bd28..15177a8 100644
--- a/lib/cpp/test/TServerTransportTest.cpp
+++ b/lib/cpp/test/TServerTransportTest.cpp
@@ -34,11 +34,11 @@
class TestTServerTransport : public TServerTransport {
public:
TestTServerTransport() : valid_(true) {}
- void close() {}
+ void close() override {}
bool valid_;
protected:
- shared_ptr<TTransport> acceptImpl() {
+ shared_ptr<TTransport> acceptImpl() override {
return valid_ ? shared_ptr<TestTTransport>(new TestTTransport)
: shared_ptr<TestTTransport>();
}
diff --git a/lib/cpp/test/TransportTest.cpp b/lib/cpp/test/TransportTest.cpp
index 0d900d9..b0c84b6 100644
--- a/lib/cpp/test/TransportTest.cpp
+++ b/lib/cpp/test/TransportTest.cpp
@@ -57,7 +57,7 @@
class SizeGenerator {
public:
- virtual ~SizeGenerator() {}
+ virtual ~SizeGenerator() = default;
virtual uint32_t nextSize() = 0;
virtual std::string describe() const = 0;
};
@@ -65,8 +65,8 @@
class ConstantSizeGenerator : public SizeGenerator {
public:
ConstantSizeGenerator(uint32_t value) : value_(value) {}
- uint32_t nextSize() { return value_; }
- std::string describe() const {
+ uint32_t nextSize() override { return value_; }
+ std::string describe() const override {
std::ostringstream desc;
desc << value_;
return desc.str();
@@ -81,9 +81,9 @@
RandomSizeGenerator(uint32_t min, uint32_t max)
: generator_(rng, boost::uniform_int<int>(min, max)) {}
- uint32_t nextSize() { return generator_(); }
+ uint32_t nextSize() override { return generator_(); }
- std::string describe() const {
+ std::string describe() const override {
std::ostringstream desc;
desc << "rand(" << getMin() << ", " << getMax() << ")";
return desc.str();
@@ -109,8 +109,8 @@
GenericSizeGenerator(uint32_t min, uint32_t max)
: generator_(new RandomSizeGenerator(min, max)) {}
- uint32_t nextSize() { return generator_->nextSize(); }
- std::string describe() const { return generator_->describe(); }
+ uint32_t nextSize() override { return generator_->nextSize(); }
+ std::string describe() const override { return generator_->describe(); }
private:
std::shared_ptr<SizeGenerator> generator_;
@@ -131,7 +131,7 @@
template <class Transport_>
class CoupledTransports {
public:
- virtual ~CoupledTransports() {}
+ virtual ~CoupledTransports() = default;
typedef Transport_ TransportType;
CoupledTransports() : in(), out() {}
@@ -282,7 +282,7 @@
out.reset(new TFileTransport(filename));
}
- ~CoupledFileTransports() { remove(filename.c_str()); }
+ ~CoupledFileTransports() override { remove(filename.c_str()); }
std::string filename;
};
@@ -341,7 +341,7 @@
struct TriggerInfo {
TriggerInfo(int seconds, const std::shared_ptr<TTransport>& transport, uint32_t writeLength)
- : timeoutSeconds(seconds), transport(transport), writeLength(writeLength), next(NULL) {}
+ : timeoutSeconds(seconds), transport(transport), writeLength(writeLength), next(nullptr) {}
int timeoutSeconds;
std::shared_ptr<TTransport> transport;
@@ -355,7 +355,7 @@
bool g_teardown = false;
void alarm_handler() {
- TriggerInfo* info = NULL;
+ TriggerInfo* info = nullptr;
{
apache::thrift::concurrency::Synchronized s(g_alarm_monitor);
// The alarm timed out, which almost certainly means we're stuck
@@ -366,7 +366,7 @@
// tools/test/runner only records stdout messages in the failure messages for
// boost tests. (boost prints its test info to stdout.)
printf("Timeout alarm expired; attempting to unblock transport\n");
- if (g_triggerInfo == NULL) {
+ if (g_triggerInfo == nullptr) {
printf(" trigger stack is empty!\n");
}
@@ -377,7 +377,7 @@
}
// Write some data to the transport to hopefully unblock it.
- uint8_t* buf = new uint8_t[info->writeLength];
+ auto* buf = new uint8_t[info->writeLength];
memset(buf, 'b', info->writeLength);
boost::scoped_array<uint8_t> array(buf);
info->transport->write(buf, info->writeLength);
@@ -395,7 +395,7 @@
if (g_teardown)
return;
// calculate timeout
- if (g_triggerInfo == NULL) {
+ if (g_triggerInfo == nullptr) {
timeout = 0;
} else {
timeout = g_triggerInfo->timeoutSeconds * 1000;
@@ -421,10 +421,10 @@
void add_trigger(unsigned int seconds,
const std::shared_ptr<TTransport>& transport,
uint32_t write_len) {
- TriggerInfo* info = new TriggerInfo(seconds, transport, write_len);
+ auto* info = new TriggerInfo(seconds, transport, write_len);
{
apache::thrift::concurrency::Synchronized s(g_alarm_monitor);
- if (g_triggerInfo == NULL) {
+ if (g_triggerInfo == nullptr) {
// This is the first trigger.
// Set g_triggerInfo, and schedule the alarm
g_triggerInfo = info;
@@ -441,17 +441,17 @@
}
void clear_triggers() {
- TriggerInfo* info = NULL;
+ TriggerInfo* info = nullptr;
{
apache::thrift::concurrency::Synchronized s(g_alarm_monitor);
info = g_triggerInfo;
- g_triggerInfo = NULL;
+ g_triggerInfo = nullptr;
g_numTriggersFired = 0;
g_alarm_monitor.notify();
}
- while (info != NULL) {
+ while (info != nullptr) {
TriggerInfo* next = info->next;
delete info;
info = next;
@@ -500,8 +500,8 @@
SizeGenerator& rChunkGenerator,
uint32_t maxOutstanding) {
CoupledTransports transports;
- BOOST_REQUIRE(transports.in != NULL);
- BOOST_REQUIRE(transports.out != NULL);
+ BOOST_REQUIRE(transports.in != nullptr);
+ BOOST_REQUIRE(transports.out != nullptr);
boost::shared_array<uint8_t> wbuf = boost::shared_array<uint8_t>(new uint8_t[totalSize]);
boost::shared_array<uint8_t> rbuf = boost::shared_array<uint8_t>(new uint8_t[totalSize]);
@@ -593,8 +593,8 @@
template <class CoupledTransports>
void test_read_part_available() {
CoupledTransports transports;
- BOOST_REQUIRE(transports.in != NULL);
- BOOST_REQUIRE(transports.out != NULL);
+ BOOST_REQUIRE(transports.in != nullptr);
+ BOOST_REQUIRE(transports.out != nullptr);
uint8_t write_buf[16];
uint8_t read_buf[16];
@@ -615,8 +615,8 @@
template <class CoupledTransports>
void test_read_part_available_in_chunks() {
CoupledTransports transports;
- BOOST_REQUIRE(transports.in != NULL);
- BOOST_REQUIRE(transports.out != NULL);
+ BOOST_REQUIRE(transports.in != nullptr);
+ BOOST_REQUIRE(transports.out != nullptr);
uint8_t write_buf[16];
uint8_t read_buf[16];
@@ -642,8 +642,8 @@
template <class CoupledTransports>
void test_read_partial_midframe() {
CoupledTransports transports;
- BOOST_REQUIRE(transports.in != NULL);
- BOOST_REQUIRE(transports.out != NULL);
+ BOOST_REQUIRE(transports.in != nullptr);
+ BOOST_REQUIRE(transports.out != nullptr);
uint8_t write_buf[16];
uint8_t read_buf[16];
@@ -700,8 +700,8 @@
template <class CoupledTransports>
void test_borrow_part_available() {
CoupledTransports transports;
- BOOST_REQUIRE(transports.in != NULL);
- BOOST_REQUIRE(transports.out != NULL);
+ BOOST_REQUIRE(transports.in != nullptr);
+ BOOST_REQUIRE(transports.out != nullptr);
uint8_t write_buf[16];
uint8_t read_buf[16];
@@ -715,7 +715,7 @@
uint32_t borrow_len = 10;
const uint8_t* borrowed_buf = transports.in->borrow(read_buf, &borrow_len);
BOOST_CHECK_EQUAL(g_numTriggersFired, (unsigned int)0);
- BOOST_CHECK(borrowed_buf == NULL);
+ BOOST_CHECK(borrowed_buf == nullptr);
clear_triggers();
}
@@ -723,8 +723,8 @@
template <class CoupledTransports>
void test_read_none_available() {
CoupledTransports transports;
- BOOST_REQUIRE(transports.in != NULL);
- BOOST_REQUIRE(transports.out != NULL);
+ BOOST_REQUIRE(transports.in != nullptr);
+ BOOST_REQUIRE(transports.out != nullptr);
uint8_t read_buf[16];
@@ -751,8 +751,8 @@
template <class CoupledTransports>
void test_borrow_none_available() {
CoupledTransports transports;
- BOOST_REQUIRE(transports.in != NULL);
- BOOST_REQUIRE(transports.out != NULL);
+ BOOST_REQUIRE(transports.in != nullptr);
+ BOOST_REQUIRE(transports.out != nullptr);
uint8_t write_buf[16];
memset(write_buf, 'a', sizeof(write_buf));
@@ -760,8 +760,8 @@
// Attempting to borrow when no data is available should fail immediately
set_trigger(1, transports.out, 10);
uint32_t borrow_len = 10;
- const uint8_t* borrowed_buf = transports.in->borrow(NULL, &borrow_len);
- BOOST_CHECK(borrowed_buf == NULL);
+ const uint8_t* borrowed_buf = transports.in->borrow(nullptr, &borrow_len);
+ BOOST_CHECK(borrowed_buf == nullptr);
BOOST_CHECK_EQUAL(g_numTriggersFired, (unsigned int)0);
clear_triggers();
@@ -1055,7 +1055,7 @@
#ifdef BOOST_TEST_DYN_LINK
bool init_unit_test_suite() {
struct timeval tv;
- THRIFT_GETTIMEOFDAY(&tv, NULL);
+ THRIFT_GETTIMEOFDAY(&tv, nullptr);
int seed = tv.tv_sec ^ tv.tv_usec;
initrand(seed);
diff --git a/lib/cpp/test/ZlibTest.cpp b/lib/cpp/test/ZlibTest.cpp
index c826814..3e2eb81 100644
--- a/lib/cpp/test/ZlibTest.cpp
+++ b/lib/cpp/test/ZlibTest.cpp
@@ -58,14 +58,14 @@
class SizeGenerator {
public:
- virtual ~SizeGenerator() {}
+ virtual ~SizeGenerator() = default;
virtual unsigned int getSize() = 0;
};
class ConstantSizeGenerator : public SizeGenerator {
public:
ConstantSizeGenerator(unsigned int value) : value_(value) {}
- virtual unsigned int getSize() { return value_; }
+ unsigned int getSize() override { return value_; }
private:
unsigned int value_;
@@ -76,10 +76,10 @@
LogNormalSizeGenerator(double mean, double std_dev)
: gen_(rng, boost::lognormal_distribution<double>(mean, std_dev)) {}
- virtual unsigned int getSize() {
+ unsigned int getSize() override {
// Loop until we get a size of 1 or more
while (true) {
- unsigned int value = static_cast<unsigned int>(gen_());
+ auto value = static_cast<unsigned int>(gen_());
if (value >= 1) {
return value;
}
@@ -91,13 +91,13 @@
};
boost::shared_array<uint8_t> gen_uniform_buffer(uint32_t buf_len, uint8_t c) {
- uint8_t* buf = new uint8_t[buf_len];
+ auto* buf = new uint8_t[buf_len];
memset(buf, c, buf_len);
return boost::shared_array<uint8_t>(buf);
}
boost::shared_array<uint8_t> gen_compressible_buffer(uint32_t buf_len) {
- uint8_t* buf = new uint8_t[buf_len];
+ auto* buf = new uint8_t[buf_len];
// Generate small runs of alternately increasing and decreasing bytes
boost::uniform_smallint<uint32_t> run_length_distribution(1, 64);
@@ -129,7 +129,7 @@
}
boost::shared_array<uint8_t> gen_random_buffer(uint32_t buf_len) {
- uint8_t* buf = new uint8_t[buf_len];
+ auto* buf = new uint8_t[buf_len];
boost::uniform_smallint<uint8_t> distribution(0, UINT8_MAX);
boost::variate_generator<boost::mt19937, boost::uniform_smallint<uint8_t> >
@@ -427,7 +427,7 @@
#ifdef BOOST_TEST_DYN_LINK
bool init_unit_test_suite() {
- uint32_t seed = static_cast<uint32_t>(time(NULL));
+ auto seed = static_cast<uint32_t>(time(nullptr));
#ifdef HAVE_INTTYPES_H
printf("seed: %" PRIu32 "\n", seed);
#endif
diff --git a/lib/cpp/test/concurrency/Tests.cpp b/lib/cpp/test/concurrency/Tests.cpp
index 019ae67..f2b0111 100644
--- a/lib/cpp/test/concurrency/Tests.cpp
+++ b/lib/cpp/test/concurrency/Tests.cpp
@@ -41,7 +41,7 @@
args[ix - 1] = std::string(argv[ix]);
}
- if (getenv("VALGRIND") != 0) {
+ if (getenv("VALGRIND") != nullptr) {
// lower the scale of every test
WEIGHT = 1;
}
diff --git a/lib/cpp/test/concurrency/ThreadFactoryTests.h b/lib/cpp/test/concurrency/ThreadFactoryTests.h
index ad1613b..febe3f8 100644
--- a/lib/cpp/test/concurrency/ThreadFactoryTests.h
+++ b/lib/cpp/test/concurrency/ThreadFactoryTests.h
@@ -51,7 +51,7 @@
public:
ReapNTask(Monitor& monitor, int& activeCount) : _monitor(monitor), _count(activeCount) {}
- void run() {
+ void run() override {
Synchronized s(_monitor);
if (--_count == 0) {
@@ -122,7 +122,7 @@
SynchStartTask(Monitor& monitor, volatile STATE& state) : _monitor(monitor), _state(state) {}
- void run() {
+ void run() override {
{
Synchronized s(_monitor);
if (_state == SynchStartTask::STARTING) {
@@ -247,14 +247,14 @@
class FloodTask : public Runnable {
public:
FloodTask(const size_t id, Monitor& mon) : _id(id), _mon(mon) {}
- ~FloodTask() {
+ ~FloodTask() override {
if (_id % 10000 == 0) {
Synchronized sync(_mon);
std::cout << "\t\tthread " << _id << " done" << std::endl;
}
}
- void run() {
+ void run() override {
if (_id % 10000 == 0) {
Synchronized sync(_mon);
std::cout << "\t\tthread " << _id << " started" << std::endl;
diff --git a/lib/cpp/test/concurrency/ThreadManagerTests.h b/lib/cpp/test/concurrency/ThreadManagerTests.h
index e9ed756..fee7c7c 100644
--- a/lib/cpp/test/concurrency/ThreadManagerTests.h
+++ b/lib/cpp/test/concurrency/ThreadManagerTests.h
@@ -63,7 +63,7 @@
Task(Monitor& monitor, size_t& count, int64_t timeout)
: _monitor(monitor), _count(count), _timeout(timeout), _startTime(0), _endTime(0), _done(false) {}
- void run() {
+ void run() override {
_startTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
@@ -124,7 +124,7 @@
int64_t time00 = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
- for (std::set<shared_ptr<ThreadManagerTests::Task> >::iterator ix = tasks.begin();
+ for (auto ix = tasks.begin();
ix != tasks.end();
ix++) {
@@ -151,7 +151,7 @@
int64_t minTime = 9223372036854775807LL;
int64_t maxTime = 0;
- for (std::set<shared_ptr<ThreadManagerTests::Task> >::iterator ix = tasks.begin();
+ for (auto ix = tasks.begin();
ix != tasks.end();
ix++) {
@@ -201,7 +201,7 @@
BlockTask(Monitor& entryMonitor, Monitor& blockMonitor, bool& blocked, Monitor& doneMonitor, size_t& count)
: _entryMonitor(entryMonitor), _entered(false), _blockMonitor(blockMonitor), _blocked(blocked), _doneMonitor(doneMonitor), _count(count) {}
- void run() {
+ void run() override {
{
Synchronized s(_entryMonitor);
_entered = true;
@@ -275,7 +275,7 @@
new ThreadManagerTests::BlockTask(entryMonitor, blockMonitor, blocked[1], doneMonitor, activeCounts[1])));
}
- for (std::vector<shared_ptr<ThreadManagerTests::BlockTask> >::iterator ix = tasks.begin();
+ for (auto ix = tasks.begin();
ix != tasks.end();
ix++) {
threadManager->add(*ix);
diff --git a/lib/cpp/test/concurrency/TimerManagerTests.h b/lib/cpp/test/concurrency/TimerManagerTests.h
index a922826..313572a 100644
--- a/lib/cpp/test/concurrency/TimerManagerTests.h
+++ b/lib/cpp/test/concurrency/TimerManagerTests.h
@@ -44,9 +44,9 @@
_success(false),
_done(false) {}
- ~Task() { std::cerr << this << std::endl; }
+ ~Task() override { std::cerr << this << std::endl; }
- void run() {
+ void run() override {
_endTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
_success = (_endTime - _startTime) >= _timeout;
@@ -215,7 +215,7 @@
// Verify behavior when removing the removed task
try {
timerManager.remove(timer);
- assert(0 == "ERROR: This remove should send a NoSuchTaskException exception.");
+ assert(nullptr == "ERROR: This remove should send a NoSuchTaskException exception.");
} catch (NoSuchTaskException&) {
}
@@ -244,7 +244,7 @@
// Verify behavior when removing the expired task
try {
timerManager.remove(timer);
- assert(0 == "ERROR: This remove should send a NoSuchTaskException exception.");
+ assert(nullptr == "ERROR: This remove should send a NoSuchTaskException exception.");
} catch (NoSuchTaskException&) {
}
diff --git a/lib/cpp/test/processor/EventLog.cpp b/lib/cpp/test/processor/EventLog.cpp
index e3ddbcc..c8e0d9b 100644
--- a/lib/cpp/test/processor/EventLog.cpp
+++ b/lib/cpp/test/processor/EventLog.cpp
@@ -110,7 +110,7 @@
Event EventLog::waitForConnEvent(uint32_t connId, int64_t timeout) {
Synchronized s(monitor_);
- EventList::iterator it = events_.begin();
+ auto it = events_.begin();
while (true) {
try {
// TODO: it would be nicer to honor timeout for the duration of this
diff --git a/lib/cpp/test/processor/Handlers.h b/lib/cpp/test/processor/Handlers.h
index 29784d8..05d19ed 100644
--- a/lib/cpp/test/processor/Handlers.h
+++ b/lib/cpp/test/processor/Handlers.h
@@ -32,31 +32,31 @@
ParentHandler(const std::shared_ptr<EventLog>& log)
: triggerMonitor(&mutex_), generation_(0), wait_(false), log_(log) {}
- int32_t incrementGeneration() {
+ int32_t incrementGeneration() override {
concurrency::Guard g(mutex_);
log_->append(EventLog::ET_CALL_INCREMENT_GENERATION, 0, 0);
return ++generation_;
}
- int32_t getGeneration() {
+ int32_t getGeneration() override {
concurrency::Guard g(mutex_);
log_->append(EventLog::ET_CALL_GET_GENERATION, 0, 0);
return generation_;
}
- void addString(const std::string& s) {
+ void addString(const std::string& s) override {
concurrency::Guard g(mutex_);
log_->append(EventLog::ET_CALL_ADD_STRING, 0, 0);
strings_.push_back(s);
}
- void getStrings(std::vector<std::string>& _return) {
+ void getStrings(std::vector<std::string>& _return) override {
concurrency::Guard g(mutex_);
log_->append(EventLog::ET_CALL_GET_STRINGS, 0, 0);
_return = strings_;
}
- void getDataWait(std::string& _return, const int32_t length) {
+ void getDataWait(std::string& _return, const int32_t length) override {
concurrency::Guard g(mutex_);
log_->append(EventLog::ET_CALL_GET_DATA_WAIT, 0, 0);
@@ -65,14 +65,14 @@
_return.append(length, 'a');
}
- void onewayWait() {
+ void onewayWait() override {
concurrency::Guard g(mutex_);
log_->append(EventLog::ET_CALL_ONEWAY_WAIT, 0, 0);
blockUntilTriggered();
}
- void exceptionWait(const std::string& message) {
+ void exceptionWait(const std::string& message) override {
concurrency::Guard g(mutex_);
log_->append(EventLog::ET_CALL_EXCEPTION_WAIT, 0, 0);
@@ -83,7 +83,7 @@
throw e;
}
- void unexpectedExceptionWait(const std::string& message) {
+ void unexpectedExceptionWait(const std::string& message) override {
concurrency::Guard g(mutex_);
log_->append(EventLog::ET_CALL_UNEXPECTED_EXCEPTION_WAIT, 0, 0);
@@ -148,7 +148,7 @@
public:
ChildHandler(const std::shared_ptr<EventLog>& log) : ParentHandler(log), value_(0) {}
- int32_t setValue(const int32_t value) {
+ int32_t setValue(const int32_t value) override {
concurrency::Guard g(mutex_);
log_->append(EventLog::ET_CALL_SET_VALUE, 0, 0);
@@ -157,7 +157,7 @@
return oldValue;
}
- int32_t getValue() {
+ int32_t getValue() override {
concurrency::Guard g(mutex_);
log_->append(EventLog::ET_CALL_GET_VALUE, 0, 0);
@@ -198,20 +198,20 @@
public:
ServerEventHandler(const std::shared_ptr<EventLog>& log) : nextId_(1), log_(log) {}
- virtual void preServe() {}
+ void preServe() override {}
- virtual void* createContext(std::shared_ptr<protocol::TProtocol> input,
- std::shared_ptr<protocol::TProtocol> output) {
+ void* createContext(std::shared_ptr<protocol::TProtocol> input,
+ std::shared_ptr<protocol::TProtocol> output) override {
ConnContext* context = new ConnContext(input, output, nextId_);
++nextId_;
log_->append(EventLog::ET_CONN_CREATED, context->id, 0);
return context;
}
- virtual void deleteContext(void* serverContext,
+ void deleteContext(void* serverContext,
std::shared_ptr<protocol::TProtocol> input,
- std::shared_ptr<protocol::TProtocol> output) {
- ConnContext* context = reinterpret_cast<ConnContext*>(serverContext);
+ std::shared_ptr<protocol::TProtocol> output) override {
+ auto* context = reinterpret_cast<ConnContext*>(serverContext);
if (input != context->input) {
abort();
@@ -225,8 +225,8 @@
delete context;
}
- virtual void processContext(void* serverContext,
- std::shared_ptr<transport::TTransport> transport) {
+ void processContext(void* serverContext,
+ std::shared_ptr<transport::TTransport> transport) override {
// TODO: We currently don't test the behavior of the processContext()
// calls. The various server implementations call processContext() at
// slightly different times, and it is too annoying to try and account for
@@ -258,8 +258,8 @@
public:
ProcessorEventHandler(const std::shared_ptr<EventLog>& log) : nextId_(1), log_(log) {}
- void* getContext(const char* fnName, void* serverContext) {
- ConnContext* connContext = reinterpret_cast<ConnContext*>(serverContext);
+ void* getContext(const char* fnName, void* serverContext) override {
+ auto* connContext = reinterpret_cast<ConnContext*>(serverContext);
CallContext* context = new CallContext(connContext, nextId_, fnName);
++nextId_;
@@ -268,47 +268,47 @@
return context;
}
- void freeContext(void* ctx, const char* fnName) {
- CallContext* context = reinterpret_cast<CallContext*>(ctx);
+ void freeContext(void* ctx, const char* fnName) override {
+ auto* context = reinterpret_cast<CallContext*>(ctx);
checkName(context, fnName);
log_->append(EventLog::ET_CALL_FINISHED, context->connContext->id, context->id, fnName);
delete context;
}
- void preRead(void* ctx, const char* fnName) {
- CallContext* context = reinterpret_cast<CallContext*>(ctx);
+ void preRead(void* ctx, const char* fnName) override {
+ auto* context = reinterpret_cast<CallContext*>(ctx);
checkName(context, fnName);
log_->append(EventLog::ET_PRE_READ, context->connContext->id, context->id, fnName);
}
- void postRead(void* ctx, const char* fnName, uint32_t bytes) {
+ void postRead(void* ctx, const char* fnName, uint32_t bytes) override {
THRIFT_UNUSED_VARIABLE(bytes);
- CallContext* context = reinterpret_cast<CallContext*>(ctx);
+ auto* context = reinterpret_cast<CallContext*>(ctx);
checkName(context, fnName);
log_->append(EventLog::ET_POST_READ, context->connContext->id, context->id, fnName);
}
- void preWrite(void* ctx, const char* fnName) {
- CallContext* context = reinterpret_cast<CallContext*>(ctx);
+ void preWrite(void* ctx, const char* fnName) override {
+ auto* context = reinterpret_cast<CallContext*>(ctx);
checkName(context, fnName);
log_->append(EventLog::ET_PRE_WRITE, context->connContext->id, context->id, fnName);
}
- void postWrite(void* ctx, const char* fnName, uint32_t bytes) {
+ void postWrite(void* ctx, const char* fnName, uint32_t bytes) override {
THRIFT_UNUSED_VARIABLE(bytes);
- CallContext* context = reinterpret_cast<CallContext*>(ctx);
+ auto* context = reinterpret_cast<CallContext*>(ctx);
checkName(context, fnName);
log_->append(EventLog::ET_POST_WRITE, context->connContext->id, context->id, fnName);
}
- void asyncComplete(void* ctx, const char* fnName) {
- CallContext* context = reinterpret_cast<CallContext*>(ctx);
+ void asyncComplete(void* ctx, const char* fnName) override {
+ auto* context = reinterpret_cast<CallContext*>(ctx);
checkName(context, fnName);
log_->append(EventLog::ET_ASYNC_COMPLETE, context->connContext->id, context->id, fnName);
}
- void handlerError(void* ctx, const char* fnName) {
- CallContext* context = reinterpret_cast<CallContext*>(ctx);
+ void handlerError(void* ctx, const char* fnName) override {
+ auto* context = reinterpret_cast<CallContext*>(ctx);
checkName(context, fnName);
log_->append(EventLog::ET_HANDLER_ERROR, context->connContext->id, context->id, fnName);
}
diff --git a/lib/cpp/test/processor/ProcessorTest.cpp b/lib/cpp/test/processor/ProcessorTest.cpp
index 9483a0e..a36ef3e 100644
--- a/lib/cpp/test/processor/ProcessorTest.cpp
+++ b/lib/cpp/test/processor/ProcessorTest.cpp
@@ -116,9 +116,9 @@
// TNonblockingServer automatically uses TFramedTransport.
// Raise an exception if the supplied transport factory is not a
// TFramedTransportFactory
- TFramedTransportFactory* framedFactory
+ auto* framedFactory
= dynamic_cast<TFramedTransportFactory*>(transportFactory.get());
- if (framedFactory == NULL) {
+ if (framedFactory == nullptr) {
throw TException("TNonblockingServer must use TFramedTransport");
}
@@ -145,9 +145,9 @@
// TNonblockingServer automatically uses TFramedTransport.
// Raise an exception if the supplied transport factory is not a
// TFramedTransportFactory
- TFramedTransportFactory* framedFactory
+ auto* framedFactory
= dynamic_cast<TFramedTransportFactory*>(transportFactory.get());
- if (framedFactory == NULL) {
+ if (framedFactory == nullptr) {
throw TException("TNonblockingServer must use TFramedTransport");
}
@@ -244,14 +244,14 @@
processor_->setEventHandler(processorEventHandler_);
}
- std::shared_ptr<TServer> createServer(uint16_t port) {
+ std::shared_ptr<TServer> createServer(uint16_t port) override {
ServerTraits_ serverTraits;
return serverTraits.createServer(processor_, port, transportFactory_, protocolFactory_);
}
- std::shared_ptr<TServerEventHandler> getServerEventHandler() { return serverEventHandler_; }
+ std::shared_ptr<TServerEventHandler> getServerEventHandler() override { return serverEventHandler_; }
- void bindSuccessful(uint16_t port) { port_ = port; }
+ void bindSuccessful(uint16_t port) override { port_ = port; }
uint16_t getPort() const { return port_; }
@@ -524,7 +524,7 @@
// can test the timing for the preRead() call.
string requestName = "getDataWait";
string eventName = "ParentService.getDataWait";
- int32_t seqid = int32_t(time(NULL));
+ auto seqid = int32_t(time(nullptr));
TBinaryProtocol protocol(socket);
protocol.writeMessageBegin(requestName, T_CALL, seqid);
socket->flush();
diff --git a/lib/cpp/test/processor/ServerThread.h b/lib/cpp/test/processor/ServerThread.h
index 61e31a3..9cca2d6 100644
--- a/lib/cpp/test/processor/ServerThread.h
+++ b/lib/cpp/test/processor/ServerThread.h
@@ -35,7 +35,7 @@
*/
class ServerState {
public:
- virtual ~ServerState() {}
+ virtual ~ServerState() = default;
/**
* Create a server to listen on the specified port.
@@ -105,9 +105,9 @@
public:
Helper(ServerThread* serverThread) : serverThread_(serverThread) {}
- void run() { serverThread_->run(); }
+ void run() override { serverThread_->run(); }
- void preServe() { serverThread_->preServe(); }
+ void preServe() override { serverThread_->preServe(); }
private:
ServerThread* serverThread_;
diff --git a/lib/cpp/test/qt/TQTcpServerTest.cpp b/lib/cpp/test/qt/TQTcpServerTest.cpp
index 58d0c6d..3371a9a 100644
--- a/lib/cpp/test/qt/TQTcpServerTest.cpp
+++ b/lib/cpp/test/qt/TQTcpServerTest.cpp
@@ -20,25 +20,25 @@
struct AsyncHandler : public test::ParentServiceCobSvIf {
std::vector<std::string> strings;
- virtual void addString(std::function<void()> cob, const std::string& s) {
+ void addString(std::function<void()> cob, const std::string& s) override {
strings.push_back(s);
cob();
}
- virtual void getStrings(std::function<void(std::vector<std::string> const& _return)> cob) {
+ void getStrings(std::function<void(std::vector<std::string> const& _return)> cob) override {
cob(strings);
}
// Overrides not used in this test
- virtual void incrementGeneration(std::function<void(int32_t const& _return)> cob) {}
- virtual void getGeneration(std::function<void(int32_t const& _return)> cob) {}
- virtual void getDataWait(std::function<void(std::string const& _return)> cob,
- const int32_t length) {}
- virtual void onewayWait(std::function<void()> cob) {}
- virtual void exceptionWait(
+ void incrementGeneration(std::function<void(int32_t const& _return)> cob) override {}
+ void getGeneration(std::function<void(int32_t const& _return)> cob) override {}
+ void getDataWait(std::function<void(std::string const& _return)> cob,
+ const int32_t length) override {}
+ void onewayWait(std::function<void()> cob) override {}
+ void exceptionWait(
std::function<void()> cob,
std::function<void(::apache::thrift::TDelayedException* _throw)> /* exn_cob */,
- const std::string& message) {}
- virtual void unexpectedExceptionWait(std::function<void()> cob, const std::string& message) {}
+ const std::string& message) override {}
+ void unexpectedExceptionWait(std::function<void()> cob, const std::string& message) override {}
};
class TQTcpServerTest : public QObject {