23 #ifndef _SANDESH_THRIFT_H_
24 #define _SANDESH_THRIFT_H_ 1
32 #include <sys/types.h>
33 #ifdef HAVE_NETINET_IN_H
34 #include <netinet/in.h>
36 #ifdef HAVE_INTTYPES_H
43 #include <netinet/in.h>
44 #include <sys/socket.h>
54 #include <boost/utility/enable_if.hpp>
55 #include <boost/type_traits/is_convertible.hpp>
72 #define THRIFT_OVERLOAD_IF_DEFN(T, Y) \
73 typename ::boost::enable_if<typename ::boost::is_convertible<T*, Y*>::type, \
76 #define THRIFT_OVERLOAD_IF(T, Y) \
77 THRIFT_OVERLOAD_IF_DEFN(T, Y) = NULL
79 namespace contrail {
namespace sandesh {
81 class TEnumIterator :
public std::iterator<std::forward_iterator_tag, std::pair<int, const char*> > {
129 void perror(
const char *message,
int errno_copy);
130 inline void perror(
const std::string &message,
int errno_copy) {
131 perror(message.c_str(), errno_copy);
134 void printf(
const char *message, ...);
140 ctime_r(&now, dbgtime);
142 fprintf(stderr,
"Thrift: %s %s\n", dbgtime, msg);
146 static std::string
strerror_s(
int errno_copy);
149 void (*
f_)(
const char *);
153 #if defined(__EXCEPTIONS)
154 class TException :
public std::exception {
159 TException(
const std::string& message) :
162 virtual ~TException() throw() {}
164 virtual const char* what()
const throw() {
165 if (message_.empty()) {
166 return "Default TException.";
168 return message_.c_str();
173 std::string message_;
179 namespace reflection {
namespace local {
183 #if defined(__EXCEPTIONS)
184 class TDelayedException {
186 template <
class E>
static TDelayedException* delayException(
const E& e);
187 virtual void throw_it() = 0;
188 virtual ~TDelayedException() {};
191 template <
class E>
class TExceptionWrapper :
public TDelayedException {
193 TExceptionWrapper(
const E& e) : e_(e) {}
194 virtual void throw_it() {
204 TDelayedException* TDelayedException::delayException(
const E& e) {
205 return new TExceptionWrapper<E>(e);
209 #if T_GLOBAL_DEBUG_VIRTUAL > 1
210 void profile_virtual_call(
const std::type_info& info);
211 void profile_generic_protocol(
const std::type_info& template_type,
212 const std::type_info& prot_type);
213 void profile_print_info(FILE *f);
214 void profile_print_info();
215 void profile_write_pprof(FILE* gen_calls_f, FILE* virtual_calls_f);
220 #endif // #ifndef _SANDESH_THRIFT_H_
static void errorTimeWrapper(const char *msg)
bool operator!=(const TEnumIterator &end)
bool operator==(const TEnumIterator &end)
TEnumIterator(int n, int *enums, const char **names)
void setOutputFunction(void(*function)(const char *))
void perror(const char *message, int errno_copy)
std::pair< int, const char * > operator*() const
void perror(const std::string &message, int errno_copy)
static std::string strerror_s(int errno_copy)
void printf(const char *message,...)
void operator()(const char *message)