31 #if !defined(THEOLIZER_INTERNAL_BASE_H) 32 #define THEOLIZER_INTERNAL_BASE_H 46 #include <type_traits> 61 #if defined(_MSC_VER) && defined(_DEBUG) 73 #define THEOLIZER_INTERNAL_LICENSE "" //"licensed under GPLv3 or lator." 75 #define THEOLIZER_INTERNAL_PRODUCT_NAME "Theolizer" 77 #define THEOLIZER_INTERNAL_COPYRIGHT "Copyright (C) 2016 Yohinori Tahara (Theoride Technology)" 79 #define THEOLIZER_INTERNAL_BUG "Theolizer bug. Please report to http://theoride.com" 94 #ifndef THEOLIZER_INTERNAL_DOXYGEN 101 #if defined(__GNUC__) 102 #define THEOLIZER_INTERNAL_UNUSED __attribute__ ((unused)) 104 #define THEOLIZER_INTERNAL_UNUSED 111 #define THEOLIZER_INTERNAL_STRINGIZE(...) THEOLIZER_INTERNAL_STRINGIZE_I(__VA_ARGS__) 112 #define THEOLIZER_INTERNAL_STRINGIZE_I(...) #__VA_ARGS__ "" 118 #define THEOLIZER_INTERNAL_CAT(a, b) THEOLIZER_INTERNAL_CAT_I(a, b) 119 #define THEOLIZER_INTERNAL_CAT_I(a, b) a ## b 125 #define THEOLIZER_INTERNAL_FIRST(dFirst, ...) dFirst 131 #define THEOLIZER_INTERNAL_EXPAND(P) P 141 #define THEOLIZER_INTERNAL_FOR(S,...) \ 143 (!theolizer::internal::isEmpty(THEOLIZER_INTERNAL_STRINGIZE(__VA_ARGS__)))\ 144 && (theolizer::internal::countComma(THEOLIZER_INTERNAL_STRINGIZE(__VA_ARGS__))<8),\ 145 "Bad number of elements(1..8) in THEOLIZER_INTERNAL_FOR."); \ 146 THEOLIZER_INTERNAL_FOR_I(THEOLIZER_INTERNAL_FORR(__VA_ARGS__),S,__VA_ARGS__) 150 #define THEOLIZER_INTERNAL_FORX1(S,P,...) S(P) 151 #define THEOLIZER_INTERNAL_FORX2(S,P,...) S(P);\ 152 THEOLIZER_INTERNAL_EXPAND(THEOLIZER_INTERNAL_FORX1(S,__VA_ARGS__)) 153 #define THEOLIZER_INTERNAL_FORX3(S,P,...) S(P);\ 154 THEOLIZER_INTERNAL_EXPAND(THEOLIZER_INTERNAL_FORX2(S,__VA_ARGS__)) 155 #define THEOLIZER_INTERNAL_FORX4(S,P,...) S(P);\ 156 THEOLIZER_INTERNAL_EXPAND(THEOLIZER_INTERNAL_FORX3(S,__VA_ARGS__)) 157 #define THEOLIZER_INTERNAL_FORX5(S,P,...) S(P);\ 158 THEOLIZER_INTERNAL_EXPAND(THEOLIZER_INTERNAL_FORX4(S,__VA_ARGS__)) 159 #define THEOLIZER_INTERNAL_FORX6(S,P,...) S(P);\ 160 THEOLIZER_INTERNAL_EXPAND(THEOLIZER_INTERNAL_FORX5(S,__VA_ARGS__)) 161 #define THEOLIZER_INTERNAL_FORX7(S,P,...) S(P);\ 162 THEOLIZER_INTERNAL_EXPAND(THEOLIZER_INTERNAL_FORX6(S,__VA_ARGS__)) 163 #define THEOLIZER_INTERNAL_FORX8(S,P,...) S(P);\ 164 THEOLIZER_INTERNAL_EXPAND(THEOLIZER_INTERNAL_FORX7(S,__VA_ARGS__)) 166 #define THEOLIZER_INTERNAL_FORN(_1, _2, _3, _4, _5, _6, _7, _8, N, ...) N 167 #define THEOLIZER_INTERNAL_FORR_I(...)\ 168 THEOLIZER_INTERNAL_EXPAND(THEOLIZER_INTERNAL_FORN(__VA_ARGS__)) 169 #define THEOLIZER_INTERNAL_FORR(...)\ 170 THEOLIZER_INTERNAL_FORR_I(__VA_ARGS__, 8, 7, 6, 5, 4, 3, 2, 1, 0) 171 #define THEOLIZER_INTERNAL_FOR_I(N,S,...) \ 172 THEOLIZER_INTERNAL_EXPAND \ 174 THEOLIZER_INTERNAL_CAT(THEOLIZER_INTERNAL_FORX,N)(S,__VA_ARGS__) \ 183 constexpr
bool isEmpty(
char const* p)
190 constexpr
unsigned countComma(
char const* p)
204 constexpr
char const* stripPathImpl(
char const* iPath,
char const* iLast)
208 : ((*iPath ==
'/') || (*iPath ==
'\\'))?
209 stripPathImpl(iPath+1, iPath+1)
211 stripPathImpl(iPath+1, iLast);
214 constexpr
char const* stripPath(
char const* iPath)
216 return stripPathImpl(iPath, iPath);
219 #define THEOLIZER_INTERNAL_FILE theolizer::internal::stripPath(__FILE__) 230 std::chrono::system_clock::time_point mStartTime;
233 FineTimer() { mStartTime=std::chrono::system_clock::now(); }
235 int64_t GetmSec(
bool iUpdate=
true)
237 std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
238 auto duration = now - mStartTime;
239 if (iUpdate) mStartTime=now;
240 return std::chrono::duration_cast<
241 std::chrono::milliseconds>(duration).count();
244 int64_t GetuSec(
bool iUpdate=
true)
246 std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
247 auto duration = now - mStartTime;
248 if (iUpdate) mStartTime=now;
249 return std::chrono::duration_cast<
250 std::chrono::microseconds>(duration).count();
261 #ifndef THEOLIZER_INTERNAL_DRIVER 267 #if defined(__GNUC__) 269 template<
typename tType>
273 static void use(GccTypeName
const&) {}
276 GccTypeName() : mName(0)
279 mName = abi::__cxa_demangle(
typeid(tType).name(), 0, 0, &status);
281 ~GccTypeName() {std::free(mName);}
284 static GccTypeName& getInstance()
286 static GccTypeName instance;
292 return (mName)?mName:
"\"demagle error\"";
295 GccTypeName(GccTypeName
const&) =
delete;
296 GccTypeName(GccTypeName&&) =
delete;
297 GccTypeName& operator=(GccTypeName
const&) =
delete;
298 GccTypeName& operator=(GccTypeName&&) =
delete;
302 template<
typename tType>
303 char const* getTypeNameImpl()
305 return GccTypeName<tType>::getInstance().get();
310 std::string getCppTypeName(std::type_index iStdTypeIndex)
313 char* aName = abi::__cxa_demangle(iStdTypeIndex.name(), 0, 0, &status);
314 std::string ret(aName);
326 template<
typename tType>
327 char const* getTypeNameImpl()
329 return typeid(tType).name();
334 std::string getCppTypeName(std::type_index iStdTypeIndex)
336 return std::string(iStdTypeIndex.name());
346 template<
typename tType>
349 static char const*
get(
bool iIsRough=
false)
353 return getTypeNameImpl<tType>();
357 char const* aName=getTypeNameImpl<TypeNameImpl>();
359 for (p=aName; (*p !=
'<') && (*p != 0); ++p)
373 #define THEOLIZER_INTERNAL_TYPE_NAME(dType) \ 374 theolizer::internal::TypeNameImpl<dType>::get() 376 #define THEOLIZER_INTERNAL_TYPE_NAME_VAR(dVar) \ 377 theolizer::internal::TypeNameImpl<decltype(dVar)>::get() 379 #define THEOLIZER_INTERNAL_TYPE_NAME_ROUGH(dType) \ 380 theolizer::internal::TypeNameImpl<dType>::get(true) 382 #define THEOLIZER_INTERNAL_TYPE_NAME_VAR_ROUGH(dVar) \ 383 theolizer::internal::TypeNameImpl<decltype(dVar)>::get(true) 389 THEOLIZER_INTERNAL_DLL std::string getNameByTypeInfo(std::type_index aTypeIndex);
397 #define THEOLIZER_INTERNAL_TYPE_NAME(dType) "" 398 #define THEOLIZER_INTERNAL_TYPE_NAME_VAR(dVar) "" 399 #define THEOLIZER_INTERNAL_TYPE_NAME_ROUGH(dType) "" 400 #define THEOLIZER_INTERNAL_TYPE_NAME_VAR_ROUGH(dVar) "" 401 inline std::string getNameByTypeInfo(std::type_index aTypeIndex) {
return "";}
403 #endif // THEOLIZER_INTERNAL_DRIVER 413 template<
bool tBool,
class tThen =
void>
414 using EnableIf=
typename std::enable_if<tBool, tThen>::type;
424 static const bool kTrue =
true;
425 static const bool kFalse =
false;
433 template<
typename tType,
class tEnable=
void>
439 template<
typename tType>
440 class RemoveCV<tType, EnableIf<std::is_pointer<tType>::value>>
442 typedef typename std::remove_pointer<tType>::type Type0;
443 typedef typename std::remove_cv<Type0>::type Type1;
444 typedef typename RemoveCV<Type1>::type Type2;
446 typedef typename std::add_pointer<Type2>::type type;
448 template<
typename tType>
449 class RemoveCV<tType,
450 EnableIf<std::is_lvalue_reference<tType>::value>>
452 typedef typename std::remove_reference<tType>::type Type0;
453 typedef typename std::remove_cv<Type0>::type Type1;
454 typedef typename RemoveCV<Type1>::type Type2;
456 typedef typename std::add_lvalue_reference<Type2>::type type;
458 template<
typename tType>
459 class RemoveCV<tType, EnableIf<std::is_array<tType>::value>>
461 static size_t const kExtent=std::extent<tType>::value;
463 typedef typename std::remove_extent<tType>::type Type0;
464 typedef typename std::remove_cv<Type0>::type Type1;
465 typedef typename RemoveCV<Type1>::type Type2;
467 typedef typename RemoveCV::Type2 type[kExtent];
474 #define THEOLIZER_INTERNAL_UNPAREN(...) __VA_ARGS__ 481 #define THEOLIZER_GE >= 482 #define THEOLIZER_GT > 483 #define THEOLIZER_LE <= 484 #define THEOLIZER_LT < 494 #define THEOLIZER_INTERNAL_OVERLOAD(dJudge) \ 495 typename std::enable_if<THEOLIZER_INTERNAL_UNPAREN dJudge, std::nullptr_t>::type=nullptr 501 template<
typename tClass>
502 void copyData(tClass& oDestination, tClass
const& iSource);
508 template<
typename tType>
515 explicit AutoRestore(tType& iTarget, tType iInitialValue) :
519 mTarget=iInitialValue;
525 AutoRestore(AutoRestore
const&) =
delete;
526 AutoRestore& operator=(AutoRestore
const&) =
delete;
529 #endif // THEOLIZER_INTERNAL_DOXYGEN 537 #if !defined(THEOLIZER_INTERNAL_DLL) 538 #define THEOLIZER_INTERNAL_DLL 541 #ifndef THEOLIZER_INTERNAL_EXCLUDE_VERSION_H 568 #endif //THEOLIZER_INTERNAL_EXCLUDE_VERSION_H 576 #endif // THEOLIZER_INTERNAL_BASE_H
THEOLIZER_INTERNAL_DLL std::string getSourcesHash()
ソース・コードのMD5ハッシュ値獲得(バージョン文字列獲得の一部)
THEOLIZER_INTERNAL_DLL bool checkLibraryHash(char const *iLibraryHash=kTheolizerLibraryHash)
ライブラリ・バイナリとライブラリ・ヘッダのバージョンが一致している時、true返却
THEOLIZER_INTERNAL_DLL std::string getVersionString()
バージョン文字列獲得
char const kTheolizerLibraryHash[]
Theolizerライブラリ・ヘッダ・ファイルのハッシュ値
THEOLIZER_INTERNAL_DLL std::string getVersionNo()
バージョン番号獲得(バージョン文字列獲得の一部)
THEOLIZER_INTERNAL_DLL std::string getLibraryHash()
ライブラリ・ヘッダのMD5ハッシュ値獲得(バージョン文字列獲得の一部)