#pragma once #include "targetver.h" #include #include #include #include #include #include #include #include #include #include #include #include #include "ace_version.hpp" #include "logging.hpp" #ifdef _DEBUG #define ZERO_OUTPUT() { memset(output, 0x00, outputSize); } #define EXTENSION_RETURN() {output[outputSize-1] = 0x00; } return; #else #define ZERO_OUTPUT() #define EXTENSION_RETURN() return; #endif #ifdef _WIN32 #define sleep(x) Sleep(x) #else #define _strdup strdup #define strtok_s strtok_r #endif namespace ace { template< typename T > struct array_deleter { void operator ()(T const * p) { delete[] p; } }; std::vector &split(const std::string &s, char delim, std::vector &elems); std::vector split(const std::string &s, char delim); template std::unique_ptr make_unique(Args&&... args) { return std::unique_ptr(new T(std::forward(args)...)); } // trim from start static inline std::string <rim(std::string &s) { s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun(std::isspace)))); return s; } // trim from end static inline std::string &rtrim(std::string &s) { s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun(std::isspace))).base(), s.end()); return s; } // trim from both ends static inline std::string &trim(std::string &s) { return ltrim(rtrim(s)); } inline void runtime_assert(bool result); struct exception { exception(const uint32_t code_, const std::string & text_) : code(code_), text(text_) {} exception & operator= (const exception& other) { code = other.code; text = other.text; return *this; } bool operator == (const exception &r) const { return ( code == r.code ); } uint32_t code; std::string text; }; } #ifdef _DEBUG #define ACE_ASSERT assert() #else #define ACE_ASSERT ace::runtime_assert() #endif #ifndef _WIN32 #define __stdcall #endif #if defined(_MSC_VER) // Microsoft #define EXPORT __declspec(dllexport) #define IMPORT __declspec(dllimport) #elif defined(_GCC) // GCC #define EXPORT __attribute__((visibility("default"))) #define IMPORT #else // do nothing and hope for the best? #define EXPORT #define IMPORT #pragma warning Unknown dynamic link import/export semantics. #endif