19 #ifndef INCLUDE_RCF_TOOLS_HPP
20 #define INCLUDE_RCF_TOOLS_HPP
29 #include <boost/config.hpp>
30 #include <boost/shared_ptr.hpp>
32 #include <RCF/Export.hpp>
33 #include <RCF/util/UnusedVariable.hpp>
34 #include <RCF/util/VariableArgMacro.hpp>
37 #include <RCF/util/Log.hpp>
40 static const int LogNameRcf = 1;
41 static const int LogLevel_1 = 1;
42 static const int LogLevel_2 = 2;
43 static const int LogLevel_3 = 3;
44 static const int LogLevel_4 = 4;
48 #define RCF_LOG_1() UTIL_LOG(RCF::LogNameRcf, RCF::LogLevel_1)
49 #define RCF_LOG_2() UTIL_LOG(RCF::LogNameRcf, RCF::LogLevel_2)
50 #define RCF_LOG_3() UTIL_LOG(RCF::LogNameRcf, RCF::LogLevel_3)
51 #define RCF_LOG_4() UTIL_LOG(RCF::LogNameRcf, RCF::LogLevel_4)
57 #include <RCF/util/Assert.hpp>
58 #define RCF_ASSERT(x) UTIL_ASSERT(x, RCF::AssertionFailureException(), RCF::LogNameRcf, RCF::LogLevel_1)
60 #define RCF_ASSERT_EQ(a,b) RCF_ASSERT(a == b)(a)(b)
61 #define RCF_ASSERT_NEQ(a,b) RCF_ASSERT(a != b)(a)(b)
63 #define RCF_ASSERT_LT(a,b) RCF_ASSERT(a < b)(a)(b)
64 #define RCF_ASSERT_LTEQ(a,b) RCF_ASSERT(a <= b)(a)(b)
66 #define RCF_ASSERT_GT(a,b) RCF_ASSERT(a > b)(a)(b)
67 #define RCF_ASSERT_GTEQ(a,b) RCF_ASSERT(a >= b)(a)(b)
72 #define RCF_ASSERT(x) DUMMY_VARIABLE_ARG_MACRO()
74 #define RCF_ASSERT_EQ(a,b) DUMMY_VARIABLE_ARG_MACRO()
75 #define RCF_ASSERT_NEQ(a,b) DUMMY_VARIABLE_ARG_MACRO()
77 #define RCF_ASSERT_LT(a,b) DUMMY_VARIABLE_ARG_MACRO()
78 #define RCF_ASSERT_LTEQ(a,b) DUMMY_VARIABLE_ARG_MACRO()
80 #define RCF_ASSERT_GT(a,b) DUMMY_VARIABLE_ARG_MACRO()
81 #define RCF_ASSERT_GTEQ(a,b) DUMMY_VARIABLE_ARG_MACRO()
89 RCF_EXPORT DummyVariableArgMacroObject rcfThrow(
const char * szFile,
int line,
const char * szFunc,
const Exception & e);
95 #define RCF_THROW(e) RCF::rcfThrow(__FILE__, __LINE__, __FUNCTION__, e)
100 #define RCF_THROW(e) RCF::rcfThrow(__FILE__, __LINE__, __FUNCTION__, e)
108 #define RCF_VERIFY(cond, e) if (cond); else RCF_THROW(e)
111 #include <boost/multi_index/detail/scope_guard.hpp>
124 class SharedPtrIsNull
128 bool operator()(boost::shared_ptr<T> spt)
const
130 return spt.get() == NULL;
138 RCF_EXPORT
void rcfDtorCatchHandler(
const std::exception & e);
143 #define RCF_DTOR_BEGIN \
146 #define RCF_DTOR_END \
148 catch (const std::exception &e) \
150 RCF::rcfDtorCatchHandler(e); \
158 #define RCF_PFTO_HACK
162 #pragma comment(lib, "ws2_32.lib")
163 #pragma comment(lib, "mswsock.lib")
164 #pragma comment(lib, "advapi32.lib")
165 #pragma comment(lib, "user32.lib")
166 #pragma comment(lib, "crypt32.lib")
173 template<
typename Container,
typename Element>
174 void eraseRemove(Container & container,
const Element & element)
184 RCF_EXPORT boost::uint64_t fileSize(
const std::string & path);
191 inline bool operator==(
192 const boost::weak_ptr<T> & lhs,
193 const boost::weak_ptr<T> & rhs)
195 return ! (lhs < rhs) && ! (rhs < lhs);
199 inline bool operator!=(
200 const boost::weak_ptr<T> & lhs,
201 const boost::weak_ptr<T> & rhs)
203 return ! (lhs == rhs);
208 #endif // ! INCLUDE_RCF_TOOLS_HPP