26 #ifndef _SANDESH_THRIFT_H_
27 #define _SANDESH_THRIFT_H_ 1
35 #include <sys/types.h>
36 #ifdef HAVE_NETINET_IN_H
37 #include <netinet/in.h>
39 #ifdef HAVE_INTTYPES_H
46 #include <netinet/in.h>
47 #include <sys/socket.h>
57 #include <boost/utility/enable_if.hpp>
58 #include <boost/type_traits/is_convertible.hpp>
75 #define THRIFT_OVERLOAD_IF_DEFN(T, Y) \
76 typename ::boost::enable_if<typename ::boost::is_convertible<T*, Y*>::type, \
79 #define THRIFT_OVERLOAD_IF(T, Y) \
80 THRIFT_OVERLOAD_IF_DEFN(T, Y) = NULL
84 class TEnumIterator :
public std::iterator<std::forward_iterator_tag, std::pair<int, const char*> > {
132 void perror(
const char *message,
int errno_copy);
133 inline void perror(
const std::string &message,
int errno_copy) {
134 perror(message.c_str(), errno_copy);
143 ctime_r(&now, dbgtime);
145 fprintf(stderr,
"Thrift: %s %s\n", dbgtime, msg);
152 void (*
f_)(
const char *);
156 #if defined(__EXCEPTIONS)
157 class TException :
public std::exception {
162 TException(
const std::string& message) :
165 virtual ~TException() throw() {}
167 virtual const char* what()
const throw() {
168 if (message_.empty()) {
169 return "Default TException.";
171 return message_.c_str();
176 std::string message_;
182 namespace reflection {
namespace local {
186 #if defined(__EXCEPTIONS)
187 class TDelayedException {
189 template <
class E>
static TDelayedException* delayException(
const E& e);
190 virtual void throw_it() = 0;
191 virtual ~TDelayedException() {};
194 template <
class E>
class TExceptionWrapper :
public TDelayedException {
196 TExceptionWrapper(
const E& e) : e_(e) {}
197 virtual void throw_it() {
207 TDelayedException* TDelayedException::delayException(
const E& e) {
208 return new TExceptionWrapper<E>(e);
212 #if T_GLOBAL_DEBUG_VIRTUAL > 1
213 void profile_virtual_call(
const std::type_info& info);
214 void profile_generic_protocol(
const std::type_info& template_type,
215 const std::type_info& prot_type);
216 void profile_print_info(FILE *f);
217 void profile_print_info();
218 void profile_write_pprof(FILE* gen_calls_f, FILE* virtual_calls_f);
TEnumIterator(int n, int *enums, const char **names)
bool operator==(const TEnumIterator &end)
bool operator!=(const TEnumIterator &end)
std::pair< int, const char * > operator*() const
void perror(const char *message, int errno_copy)
static void errorTimeWrapper(const char *msg)
static std::string strerror_s(int errno_copy)
void perror(const std::string &message, int errno_copy)
void setOutputFunction(void(*function)(const char *))
void operator()(const char *message)
void printf(const char *message,...)