45 lines
1.0 KiB
C++
45 lines
1.0 KiB
C++
#pragma once
|
|
#ifndef _NB_CORE_TYPES
|
|
#define _NB_CORE_TYPES
|
|
|
|
#include <array>
|
|
#include <utility>
|
|
#include <string>
|
|
|
|
namespace nb {
|
|
|
|
#ifdef _NB_TARGET_WINDOWS
|
|
const std::string NEWLINE("\r\n");
|
|
#endif // _NB_TARGET_WINDOWS
|
|
#ifdef _NB_TARGET_LINUX
|
|
const std::string NEWLINE("\n");
|
|
#endif // _NB_TARGET_LINUX
|
|
|
|
template<typename K, typename V, size_t N>
|
|
struct ConstexprMap {
|
|
template<typename Input>
|
|
constexpr ConstexprMap(Input inp) : _data{inp} {}
|
|
|
|
protected:
|
|
const std::array<std::pair<K, V>, N> _data;
|
|
};
|
|
|
|
/* template<typename T>
|
|
T swap_endian(const T& val) {
|
|
T ret;
|
|
const int size = sizeof(T);
|
|
auto retLoc = static_cast<void*>(&ret);
|
|
auto valLoc = static_cast<const void*>(&val);
|
|
|
|
for (int i = 0; i < size; ++i) {
|
|
memcpy(retLoc+i, valLoc+(size-i-1), 1);
|
|
}
|
|
return ret;
|
|
} */
|
|
|
|
std::string find_and_replace(const std::string& original, const std::string& find, const std::string& replace);
|
|
|
|
// using ByteVector = std::vector<uint8_t>;
|
|
|
|
} // namespace nb
|
|
#endif // _NB_CORE_TYPES
|