00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef DEBUG_OSTREAM_OPERATORS_H
00017 #define DEBUG_OSTREAM_OPERATORS_H
00018
00019 #ifdef CWDEBUG
00020
00021 #ifndef USE_PCH
00022 #include <sys/time.h>
00023 #include <regex.h>
00024 #include <iosfwd>
00025 #include <utility>
00026 #include <boost/shared_ptr.hpp>
00027 #include <boost/weak_ptr.hpp>
00028 #endif
00029
00030 struct timeval;
00031 class Application;
00032 class Server;
00033 class Network;
00034 class MessageIn;
00035 class ClientMessageIn;
00036 class ServerMessageIn;
00037 class UserAnswerRequestData;
00038 class UserAnswer;
00039 class UserAnswerEventRequestBase;
00040 class Identity;
00041 class IdentityReference;
00042 class Authentication;
00043 class Channel;
00044 class Nick;
00045 class ClientSession;
00046 class QuestionTarget;
00047 class NoticeTarget;
00048 class ServerSession;
00049 class Target;
00050 class DestructEventRequestData;
00051 class ServerConnection;
00052 class MessageOutData;
00053 class MessageOut;
00054 class Priority;
00055 class Matcher;
00056 class MatchRequestList;
00057 class MatchRequest;
00058 class MatcherEventType;
00059 class Prefix;
00060 class PseudoMessageEventRequestData;
00061 class Member;
00062 class WhoOptions;
00063 class WhoRequest;
00064 class SignalType;
00065 class ServerVersion;
00066 class AuthState;
00067
00068 extern std::ostream& operator<<(std::ostream& os, Application const& application);
00069 extern std::ostream& operator<<(std::ostream& os, Server const& server);
00070 extern std::ostream& operator<<(std::ostream& os, Network const& network);
00071 extern std::ostream& operator<<(std::ostream& os, MessageIn const& msg);
00072 extern std::ostream& operator<<(std::ostream& os, ClientMessageIn const& msg);
00073 extern std::ostream& operator<<(std::ostream& os, ServerMessageIn const& msg);
00074 extern std::ostream& operator<<(std::ostream& os, UserAnswerRequestData const& request_data);
00075 extern std::ostream& operator<<(std::ostream& os, UserAnswer const& answer);
00076 extern std::ostream& operator<<(std::ostream& os, UserAnswerEventRequestBase const& request);
00077 extern std::ostream& operator<<(std::ostream& os, Identity const& identity);
00078 extern std::ostream& operator<<(std::ostream& os, IdentityReference const& identity_reference);
00079 extern std::ostream& operator<<(std::ostream& os, Authentication const& authentication);
00080 extern std::ostream& operator<<(std::ostream& os, Channel const& channel);
00081 extern std::ostream& operator<<(std::ostream& os, Nick const& nick);
00082 extern std::ostream& operator<<(std::ostream& os, ClientSession const& client_session);
00083 extern std::ostream& operator<<(std::ostream& os, QuestionTarget const& question_target);
00084 extern std::ostream& operator<<(std::ostream& os, NoticeTarget const& notice_target);
00085 extern std::ostream& operator<<(std::ostream& os, ServerSession const& server_session);
00086 extern std::ostream& operator<<(std::ostream& os, Target const& target);
00087 extern std::ostream& operator<<(std::ostream& os, DestructEventRequestData const& request_data);
00088 extern std::ostream& operator<<(std::ostream& os, ServerConnection const& server_connection);
00089 extern std::ostream& operator<<(std::ostream& os, MessageOutData const& data);
00090 extern std::ostream& operator<<(std::ostream& os, MessageOut const& message);
00091 extern std::ostream& operator<<(std::ostream& os, Priority const& priority);
00092 extern std::ostream& operator<<(std::ostream& os, timeval const& time);
00093 extern std::ostream& operator<<(std::ostream& os, regex_t const& regex);
00094 extern std::ostream& operator<<(std::ostream& os, Matcher const& matcher);
00095 extern std::ostream& operator<<(std::ostream& os, MatchRequestList const& match_request_list);
00096 extern std::ostream& operator<<(std::ostream& os, MatchRequest const& match_request);
00097 extern std::ostream& operator<<(std::ostream& os, MatcherEventType const& event_type);
00098 extern std::ostream& operator<<(std::ostream& os, Prefix const& prefix);
00099 extern std::ostream& operator<<(std::ostream& os, PseudoMessageEventRequestData const& request_data);
00100 extern std::ostream& operator<<(std::ostream& os, Member const& member);
00101 extern std::ostream& operator<<(std::ostream& os, WhoOptions const& who_options);
00102 extern std::ostream& operator<<(std::ostream& os, WhoRequest const& who_request);
00103 extern std::ostream& operator<<(std::ostream& os, SignalType const& signal);
00104 extern std::ostream& operator<<(std::ostream& os, ServerVersion const& server_version);
00105 extern std::ostream& operator<<(std::ostream& os, AuthState const& auth_state);
00106
00107
00108 template<typename T>
00109 std::ostream& operator<<(std::ostream& os, boost::shared_ptr<T> const& data)
00110 {
00111 os << "(boost::shared_ptr<" << libcwd::type_info_of<T>().demangled_name() << ">)({";
00112 if (data.get())
00113 os << *data;
00114 else
00115 os << "<NULL>";
00116 return os << "})";
00117 }
00118
00119
00120 template<typename T>
00121 std::ostream& operator<<(std::ostream& os, boost::weak_ptr<T> const& data)
00122 {
00123 return os << "(boost::weak_ptr<" << libcwd::type_info_of<T>().demangled_name() << ">)({ " << *boost::shared_ptr<T>(data) << "})";
00124 }
00125
00126
00127 template<typename T1, typename T2>
00128 std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> const& data)
00129 {
00130 return os << "{first:" << data.first << ", second:" << data.second << '}';
00131 }
00132
00133
00134 template<typename T1, typename T2, typename T3>
00135 std::ostream& operator<<(std::ostream& os, std::map<T1, T2, T3> const& data)
00136 {
00137 os << "{map<" << libcwd::type_info_of<T1>().demangled_name() <<
00138 ", " << libcwd::type_info_of<T2>().demangled_name() <<
00139 ", " << libcwd::type_info_of<T3>().demangled_name() <<">:";
00140 typedef std::map<T1, T2, T3> map_type;
00141 for (typename map_type::const_iterator iter = data.begin(); iter != data.end(); ++iter)
00142 os << '{' << *iter << '}';
00143 return os << '}';
00144 }
00145
00146 #endif // CWDEBUG
00147 #endif // DEBUG_OSTREAM_OPERATORS_H
00148