THRIFT-925. cpp: Add _VALUES_TO_NAMES enum map
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005143 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/Thrift.h b/lib/cpp/src/Thrift.h
index a8bf2a8..cf766f2 100644
--- a/lib/cpp/src/Thrift.h
+++ b/lib/cpp/src/Thrift.h
@@ -24,6 +24,7 @@
#include "config.h"
#endif
#include <stdio.h>
+#include <assert.h>
#include <sys/types.h>
#include <netinet/in.h>
@@ -42,6 +43,34 @@
namespace apache { namespace thrift {
+class TEnumIterator {
+ public:
+ TEnumIterator(int n,
+ int* enums,
+ const char** names) :
+ ii_(0), n_(n), enums_(enums), names_(names) {
+ }
+
+ int operator ++() {
+ return ++ii_;
+ }
+
+ bool operator !=(const TEnumIterator& end) {
+ assert(end.n_ == -1);
+ return (ii_ != n_);
+ }
+
+ std::pair<int, const char*> operator*() const {
+ return std::make_pair(enums_[ii_], names_[ii_]);
+ }
+
+ private:
+ int ii_;
+ const int n_;
+ int* enums_;
+ const char** names_;
+};
+
class TOutput {
public:
TOutput() : f_(&errorTimeWrapper) {}