diff options
author | Bryan Duxbury <bryanduxbury@apache.org> | 2010-09-27 17:26:02 +0000 |
---|---|---|
committer | Bryan Duxbury <bryanduxbury@apache.org> | 2010-09-27 17:26:02 +0000 |
commit | 833ae492902c08ab13ebc4efa73adef0a4936dff (patch) | |
tree | fc300d98f1b97a0847b7e1bf962c78bc14640e8e | |
parent | a5df7c7b0ef66819f56039f95f6d8b40a3197d8d (diff) | |
download | thrift-833ae492902c08ab13ebc4efa73adef0a4936dff.tar.gz |
THRIFT-920. cpp: C++ Test and Tutorial does not compile anymore due to the change within Enum handling
Patch: Roger Meier and Christian Lavoie
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1001826 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | test/cpp/Thrift-test.mk | 8 | ||||
-rw-r--r-- | test/cpp/src/TestClient.cpp | 22 | ||||
-rw-r--r-- | test/cpp/src/TestServer.cpp | 30 | ||||
-rw-r--r-- | tutorial/cpp/CppClient.cpp | 4 | ||||
-rw-r--r-- | tutorial/cpp/CppServer.cpp | 8 |
5 files changed, 36 insertions, 36 deletions
diff --git a/test/cpp/Thrift-test.mk b/test/cpp/Thrift-test.mk index fb3e38bc6..97f0decf0 100644 --- a/test/cpp/Thrift-test.mk +++ b/test/cpp/Thrift-test.mk @@ -59,16 +59,16 @@ stubs: ../ThriftTest.thrift $(THRIFT) --gen cpp ../ThriftTest.thrift server-debug: stubs - g++ -o TestServer $(DCFL) src/TestServer.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp ../ThriftTest_extras.cpp + g++ -o TestServer $(DCFL) src/TestServer.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp $(thrift_home)/lib/cpp/test/ThriftTest_extras.cpp client-debug: stubs - g++ -o TestClient $(DCFL) src/TestClient.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp ../ThriftTest_extras.cpp + g++ -o TestClient $(DCFL) src/TestClient.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp $(thrift_home)/lib/cpp/test/ThriftTest_extras.cpp server: stubs - g++ -o TestServer $(CFL) src/TestServer.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp ../ThriftTest_extras.cpp + g++ -o TestServer $(CFL) src/TestServer.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp $(thrift_home)/lib/cpp/test/ThriftTest_extras.cpp client: stubs - g++ -o TestClient $(CFL) src/TestClient.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp ../ThriftTest_extras.cpp + g++ -o TestClient $(CFL) src/TestClient.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp $(thrift_home)/lib/cpp/test/ThriftTest_extras.cpp small: $(THRIFT) --gen cpp ../SmallTest.thrift diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp index 5ddfa0601..4764a4c3c 100644 --- a/test/cpp/src/TestClient.cpp +++ b/test/cpp/src/TestClient.cpp @@ -297,23 +297,23 @@ int main(int argc, char** argv) { * ENUM TEST */ printf("testEnum(ONE)"); - Numberz ret = testClient.testEnum(ONE); + Numberz::type ret = testClient.testEnum(Numberz::ONE); printf(" = %d\n", ret); printf("testEnum(TWO)"); - ret = testClient.testEnum(TWO); + ret = testClient.testEnum(Numberz::TWO); printf(" = %d\n", ret); printf("testEnum(THREE)"); - ret = testClient.testEnum(THREE); + ret = testClient.testEnum(Numberz::THREE); printf(" = %d\n", ret); printf("testEnum(FIVE)"); - ret = testClient.testEnum(FIVE); + ret = testClient.testEnum(Numberz::FIVE); printf(" = %d\n", ret); printf("testEnum(EIGHT)"); - ret = testClient.testEnum(EIGHT); + ret = testClient.testEnum(Numberz::EIGHT); printf(" = %d\n", ret); /** @@ -345,7 +345,7 @@ int main(int argc, char** argv) { * INSANITY TEST */ Insanity insane; - insane.userMap.insert(make_pair(FIVE, 5000)); + insane.userMap.insert(make_pair(Numberz::FIVE, 5000)); Xtruct truck; truck.string_thing = "Truck"; truck.byte_thing = 8; @@ -353,19 +353,19 @@ int main(int argc, char** argv) { truck.i64_thing = 8; insane.xtructs.push_back(truck); printf("testInsanity()"); - map<UserId, map<Numberz,Insanity> > whoa; + map<UserId, map<Numberz::type,Insanity> > whoa; testClient.testInsanity(whoa, insane); printf(" = {"); - map<UserId, map<Numberz,Insanity> >::const_iterator i_iter; + map<UserId, map<Numberz::type,Insanity> >::const_iterator i_iter; for (i_iter = whoa.begin(); i_iter != whoa.end(); ++i_iter) { printf("%"PRId64" => {", i_iter->first); - map<Numberz,Insanity>::const_iterator i2_iter; + map<Numberz::type,Insanity>::const_iterator i2_iter; for (i2_iter = i_iter->second.begin(); i2_iter != i_iter->second.end(); ++i2_iter) { printf("%d => {", i2_iter->first); - map<Numberz, UserId> userMap = i2_iter->second.userMap; - map<Numberz, UserId>::const_iterator um; + map<Numberz::type, UserId> userMap = i2_iter->second.userMap; + map<Numberz::type, UserId>::const_iterator um; printf("{"); for (um = userMap.begin(); um != userMap.end(); ++um) { printf("%d => %"PRId64", ", um->first, um->second); diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp index 83454dcaf..d6063ac32 100644 --- a/test/cpp/src/TestServer.cpp +++ b/test/cpp/src/TestServer.cpp @@ -138,7 +138,7 @@ class TestHandler : public ThriftTestIf { out = thing; } - Numberz testEnum(const Numberz thing) { + Numberz::type testEnum(const Numberz::type thing) { printf("testEnum(%d)\n", thing); return thing; } @@ -163,7 +163,7 @@ class TestHandler : public ThriftTestIf { } - void testInsanity(map<UserId, map<Numberz,Insanity> > &insane, const Insanity &argument) { + void testInsanity(map<UserId, map<Numberz::type,Insanity> > &insane, const Insanity &argument) { printf("testInsanity()\n"); Xtruct hello; @@ -179,36 +179,36 @@ class TestHandler : public ThriftTestIf { goodbye.i64_thing = 4; Insanity crazy; - crazy.userMap.insert(make_pair(EIGHT, 8)); + crazy.userMap.insert(make_pair(Numberz::EIGHT, 8)); crazy.xtructs.push_back(goodbye); Insanity looney; - crazy.userMap.insert(make_pair(FIVE, 5)); + crazy.userMap.insert(make_pair(Numberz::FIVE, 5)); crazy.xtructs.push_back(hello); - map<Numberz, Insanity> first_map; - map<Numberz, Insanity> second_map; + map<Numberz::type, Insanity> first_map; + map<Numberz::type, Insanity> second_map; - first_map.insert(make_pair(TWO, crazy)); - first_map.insert(make_pair(THREE, crazy)); + first_map.insert(make_pair(Numberz::TWO, crazy)); + first_map.insert(make_pair(Numberz::THREE, crazy)); - second_map.insert(make_pair(SIX, looney)); + second_map.insert(make_pair(Numberz::SIX, looney)); insane.insert(make_pair(1, first_map)); insane.insert(make_pair(2, second_map)); printf("return"); printf(" = {"); - map<UserId, map<Numberz,Insanity> >::const_iterator i_iter; + map<UserId, map<Numberz::type,Insanity> >::const_iterator i_iter; for (i_iter = insane.begin(); i_iter != insane.end(); ++i_iter) { printf("%"PRId64" => {", i_iter->first); - map<Numberz,Insanity>::const_iterator i2_iter; + map<Numberz::type,Insanity>::const_iterator i2_iter; for (i2_iter = i_iter->second.begin(); i2_iter != i_iter->second.end(); ++i2_iter) { printf("%d => {", i2_iter->first); - map<Numberz, UserId> userMap = i2_iter->second.userMap; - map<Numberz, UserId>::const_iterator um; + map<Numberz::type, UserId> userMap = i2_iter->second.userMap; + map<Numberz::type, UserId>::const_iterator um; printf("{"); for (um = userMap.begin(); um != userMap.end(); ++um) { printf("%d => %"PRId64", ", um->first, um->second); @@ -232,7 +232,7 @@ class TestHandler : public ThriftTestIf { } - 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 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) { printf("testMulti()\n"); hello.string_thing = "Hello2"; @@ -353,7 +353,7 @@ int main(int argc, char **argv) { if (!args["workers"].empty()) { workerCount = atoi(args["workers"].c_str()); } - } catch (exception& e) { + } catch (std::exception& e) { cerr << e.what() << endl; cerr << usage; } diff --git a/tutorial/cpp/CppClient.cpp b/tutorial/cpp/CppClient.cpp index a3f17feec..4dac90c4f 100644 --- a/tutorial/cpp/CppClient.cpp +++ b/tutorial/cpp/CppClient.cpp @@ -53,7 +53,7 @@ int main(int argc, char** argv) { printf("1+1=%d\n", sum); Work work; - work.op = DIVIDE; + work.op = Operation::DIVIDE; work.num1 = 1; work.num2 = 0; @@ -64,7 +64,7 @@ int main(int argc, char** argv) { printf("InvalidOperation: %s\n", io.why.c_str()); } - work.op = SUBTRACT; + work.op = Operation::SUBTRACT; work.num1 = 15; work.num2 = 10; int32_t diff = client.calculate(1, work); diff --git a/tutorial/cpp/CppServer.cpp b/tutorial/cpp/CppServer.cpp index 23c2b8339..860381eea 100644 --- a/tutorial/cpp/CppServer.cpp +++ b/tutorial/cpp/CppServer.cpp @@ -61,16 +61,16 @@ class CalculatorHandler : public CalculatorIf { int32_t val; switch (work.op) { - case ADD: + case Operation::ADD: val = work.num1 + work.num2; break; - case SUBTRACT: + case Operation::SUBTRACT: val = work.num1 - work.num2; break; - case MULTIPLY: + case Operation::MULTIPLY: val = work.num1 * work.num2; break; - case DIVIDE: + case Operation::DIVIDE: if (work.num2 == 0) { InvalidOperation io; io.what = work.op; |