19 #ifndef INCLUDE_RCF_TOOLS_HPP
20 #define INCLUDE_RCF_TOOLS_HPP
31 #include <boost/config.hpp>
32 #include <boost/shared_ptr.hpp>
34 #include <RCF/Export.hpp>
35 #include <RCF/util/UnusedVariable.hpp>
38 #include <RCF/util/Log.hpp>
41 static const int LogNameRcf = 1;
42 static const int LogLevel_1 = 1;
43 static const int LogLevel_2 = 2;
44 static const int LogLevel_3 = 3;
45 static const int LogLevel_4 = 4;
49 #define RCF_LOG_1() UTIL_LOG(RCF::LogNameRcf, RCF::LogLevel_1)
50 #define RCF_LOG_2() UTIL_LOG(RCF::LogNameRcf, RCF::LogLevel_2)
51 #define RCF_LOG_3() UTIL_LOG(RCF::LogNameRcf, RCF::LogLevel_3)
52 #define RCF_LOG_4() UTIL_LOG(RCF::LogNameRcf, RCF::LogLevel_4)
55 #include <RCF/util/Assert.hpp>
56 #define RCF_ASSERT(x) UTIL_ASSERT(x, RCF::AssertionFailureException(), RCF::LogNameRcf, RCF::LogLevel_1)
58 #define RCF_ASSERT_EQ(a,b) RCF_ASSERT(a == b)(a)(b)
59 #define RCF_ASSERT_NEQ(a,b) RCF_ASSERT(a != b)(a)(b)
61 #define RCF_ASSERT_LT(a,b) RCF_ASSERT(a < b)(a)(b)
62 #define RCF_ASSERT_LTEQ(a,b) RCF_ASSERT(a <= b)(a)(b)
64 #define RCF_ASSERT_GT(a,b) RCF_ASSERT(a > b)(a)(b)
65 #define RCF_ASSERT_GTEQ(a,b) RCF_ASSERT(a >= b)(a)(b)
68 #include <RCF/util/Throw.hpp>
71 RCF_EXPORT ::util::DummyVariableArgMacroObject rcfThrow(
const char * szFile,
int line,
const char * szFunc,
const Exception & e);
73 #define RCF_THROW(e) RCF::rcfThrow(__FILE__, __LINE__, __FUNCTION__, e)
76 #define RCF_VERIFY(cond, e) if (cond); else RCF_THROW(e)
80 #include <boost/multi_index/detail/scope_guard.hpp>
92 std::ostream &operator<<(std::ostream &os, const std::vector<T> &v)
95 std::copy(v.begin(), v.end(), std::ostream_iterator<T>(os,
", "));
102 std::ostream &operator<<(std::ostream &os, const std::deque<T> &d)
105 std::copy(d.begin(), d.end(), std::ostream_iterator<T>(os,
", "));
111 RCF_EXPORT std::ostream &operator<<(std::ostream &os,
const std::type_info &ti);
114 RCF_EXPORT std::ostream &operator<<(std::ostream &os,
const std::exception &e);
117 RCF_EXPORT std::ostream &operator<<(std::ostream &os,
const RCF::Exception &e);
132 class SharedPtrIsNull
136 bool operator()(boost::shared_ptr<T> spt)
const
138 return spt.get() == NULL;
151 #define RCF_DTOR_BEGIN \
154 #define RCF_DTOR_END \
156 catch (const std::exception &e) \
158 if (!util::detail::uncaught_exception()) \
173 #define RCF_PFTO_HACK
177 #pragma comment(lib, "ws2_32.lib")
178 #pragma comment(lib, "mswsock.lib")
179 #pragma comment(lib, "advapi32.lib")
180 #pragma comment(lib, "user32.lib")
181 #pragma comment(lib, "crypt32.lib")
188 template<
typename Container,
typename Element>
189 void eraseRemove(Container & container,
const Element & element)
199 RCF_EXPORT boost::uint64_t fileSize(
const std::string & path);
206 inline bool operator==(
207 const boost::weak_ptr<T> & lhs,
208 const boost::weak_ptr<T> & rhs)
210 return ! (lhs < rhs) && ! (rhs < lhs);
214 inline bool operator!=(
215 const boost::weak_ptr<T> & lhs,
216 const boost::weak_ptr<T> & rhs)
218 return ! (lhs == rhs);
223 #endif // ! INCLUDE_RCF_TOOLS_HPP