2016-05-30 16:37:03 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
//_USE_MATH_DEFINES + cmath needs to be first or M_PI won't be defined in VS2015
|
|
|
|
#define _USE_MATH_DEFINES
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
#include "targetver.h"
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <list>
|
|
|
|
#include <map>
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <memory>
|
|
|
|
#include <cstdint>
|
|
|
|
#include <streambuf>
|
|
|
|
#include "ace_version.hpp"
|
2017-10-28 19:39:46 +00:00
|
|
|
#include <algorithm>
|
|
|
|
#include <cctype> //std::isspace
|
2019-09-28 21:03:55 +00:00
|
|
|
#include <cstring>
|
|
|
|
#include <istream>
|
2016-05-30 16:37:03 +00:00
|
|
|
|
|
|
|
#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<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems);
|
|
|
|
std::vector<std::string> split(const std::string &s, char delim);
|
|
|
|
|
|
|
|
template<typename T, typename... Args>
|
|
|
|
std::unique_ptr<T> make_unique(Args&&... args) {
|
|
|
|
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
|
|
|
}
|
|
|
|
|
|
|
|
// trim from start
|
|
|
|
static inline std::string <rim(std::string &s) {
|
2017-10-28 19:39:46 +00:00
|
|
|
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](const char _char) noexcept {return !std::isspace(_char); }));
|
2016-05-30 16:37:03 +00:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
// trim from end
|
|
|
|
static inline std::string &rtrim(std::string &s) {
|
2017-10-28 19:39:46 +00:00
|
|
|
s.erase(std::find_if(s.rbegin(), s.rend(), [](const char _char) noexcept {return !std::isspace(_char); }).base(), s.end());
|
2016-05-30 16:37:03 +00:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
// trim from both ends
|
|
|
|
static inline std::string &trim(std::string &s) {
|
|
|
|
return ltrim(rtrim(s));
|
|
|
|
}
|
|
|
|
|
|
|
|
struct exception {
|
|
|
|
exception(const uint32_t code_, const std::string & text_) : code(code_), text(text_) {}
|
2019-09-28 21:03:55 +00:00
|
|
|
|
2016-05-30 16:37:03 +00:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
2019-09-28 21:03:55 +00:00
|
|
|
#define __stdcall
|
2016-05-30 16:37:03 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(_MSC_VER)
|
2019-09-28 21:03:55 +00:00
|
|
|
// Microsoft
|
2016-05-30 16:37:03 +00:00
|
|
|
#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
|