19 #ifndef INCLUDE_RCF_TOOLS_HPP 20 #define INCLUDE_RCF_TOOLS_HPP 27 #include <RCF/Config.hpp> 28 #include <RCF/Export.hpp> 32 #pragma comment(lib, "ws2_32.lib") 33 #pragma comment(lib, "mswsock.lib") 34 #pragma comment(lib, "advapi32.lib") 35 #pragma comment(lib, "user32.lib") 36 #pragma comment(lib, "crypt32.lib") 37 #pragma comment(lib, "rpcrt4.lib") 43 static const int LogNameRcf = 1;
44 static const int LogLevel_1 = 1;
45 static const int LogLevel_2 = 2;
46 static const int LogLevel_3 = 3;
47 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) 57 RCF_EXPORT
void doAssert(
const char * szFile,
int line,
const char * szFunc,
const char * szAssertion);
59 #define RCF_ASSERT(x) if (x) ; else RCF::doAssert(__FILE__, __LINE__, __FUNCTION__, #x); 60 #define RCF_ASSERT_ALWAYS(x) RCF::doAssert(__FILE__, __LINE__, __FUNCTION__, x); 65 #define RCF_ASSERT_ALWAYS(x) 71 RCF_EXPORT
void rcfThrow(
const char * szFile,
int line,
const char * szFunc,
const Exception & e);
73 #define RCF_THROW(e) RCF::rcfThrow(__FILE__, __LINE__, __FUNCTION__, e) 74 #define RCF_VERIFY(cond, e) if (cond); else RCF_THROW(e) 86 RCF_EXPORT
void rcfDtorCatchHandler(
const std::exception & e);
89 #define RCF_DTOR_BEGIN \ 92 #define RCF_DTOR_END \ 94 catch (const std::exception &e) \ 96 RCF::rcfDtorCatchHandler(e); \ 101 template<
typename Container,
typename Element>
102 void eraseRemove(Container & container,
const Element & element)
112 RCF_EXPORT std::uint64_t fileSize(
const std::string & path);
116 inline bool operator<(
117 const std::weak_ptr<T> & lhs,
118 const std::weak_ptr<T> & rhs)
120 std::owner_less< std::weak_ptr<T> > cmp;
121 return cmp(lhs, rhs);
125 inline bool operator==(
126 const std::weak_ptr<T> & lhs,
127 const std::weak_ptr<T> & rhs)
129 return ! (lhs < rhs) && ! (rhs < lhs);
133 inline bool operator!=(
134 const std::weak_ptr<T> & lhs,
135 const std::weak_ptr<T> & rhs)
137 return ! (lhs == rhs);
145 Noncopyable(
const Noncopyable&) =
delete;
146 Noncopyable& operator=(
const Noncopyable&) =
delete;
152 ScopeGuard(std::function<
void()> func);
159 std::function<void()> m_func;
162 RCF_EXPORT
void trim(std::string& s);
163 RCF_EXPORT
void trimLeft(std::string& s);
164 RCF_EXPORT
void trimRight(std::string& s);
165 RCF_EXPORT
bool iequals(
const std::string& lhs,
const std::string& rhs);
166 RCF_EXPORT
bool istartsWith(
const std::string& s,
const std::string& startsWith);
168 template<
typename TPtr>
169 std::string getTypeName(
const TPtr & tPtr)
174 return typeid(t).name();
183 typedef RCF::Noncopyable Noncopyable;
187 #define RCF_UNUSED_VARIABLE(x) ((void) x) 190 #define RCF_MIN (std::min) 191 #define RCF_MAX (std::max) 196 #define SF_FOR_EACH_FUNDAMENTAL_TYPE_(arg) \ 204 arg(unsigned short) \ 214 #define SF_FOR_EACH_FUNDAMENTAL_TYPE(arg) \ 215 SF_FOR_EACH_FUNDAMENTAL_TYPE_(arg) \ 217 arg(unsigned __int64) 221 #define SF_FOR_EACH_FUNDAMENTAL_TYPE(arg) \ 222 SF_FOR_EACH_FUNDAMENTAL_TYPE_(arg) \ 224 arg(unsigned long long) 228 #endif // ! INCLUDE_RCF_TOOLS_HPP Definition: ByteBuffer.hpp:189
Definition: AmiIoHandler.hpp:24