Compare commits
No commits in common. "85241b4aa53e77a7400225457d1c43ec2b8f1cc0" and "1b4a891a58d933eb88b97ce5cd03f73f8e51c75e" have entirely different histories.
85241b4aa5
...
1b4a891a58
@ -61,7 +61,6 @@ endif()
|
||||
if (NB_LOGGING)
|
||||
message(STATUS "Building with automatic logging")
|
||||
add_compile_definitions(_NB_AUTOLOG)
|
||||
add_compile_definitions(_NB_CODE_ERROR_LOCATIONS)
|
||||
endif()
|
||||
|
||||
if (NB_TARGET_WINDOWS)
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
toAbsolutePath(NB_CORE_SOURCE
|
||||
./src/Errors.cpp
|
||||
./src/Logger.cpp
|
||||
# ./src/Logger.cpp
|
||||
./src/Processes.cpp
|
||||
./src/StringUtils.cpp
|
||||
./src/Utils.cpp
|
||||
)
|
||||
|
||||
@ -12,7 +11,6 @@ toAbsolutePath(NB_CORE_INCLUDE
|
||||
./Errors.hpp
|
||||
./Logger.hpp
|
||||
./Processes.hpp
|
||||
./StringUtils.hpp
|
||||
./ThreadsafeQueue.hpp
|
||||
./Types.hpp
|
||||
./TypeTraits.hpp
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
#ifndef _NB_DATASINK
|
||||
#define _NB_DATASINK
|
||||
|
||||
#include <atomic>
|
||||
#include <thread>
|
||||
|
||||
#include "ThreadSafeQueue.hpp"
|
||||
@ -35,9 +34,9 @@ class BufferedDataProcessor : public DataSink<DataType> {
|
||||
public:
|
||||
using Base::Base;
|
||||
|
||||
virtual bool stop() noexcept override { return type_ptr->stop(); }
|
||||
virtual bool run() override { return type_ptr->run(); }
|
||||
virtual bool in(const DataType& val) override { return type_ptr->in(val); }
|
||||
bool stop() noexcept { return type_ptr->stop(); }
|
||||
bool run() { return type_ptr->run(); }
|
||||
bool in(const DataType& val) { return type_ptr->in(val); }
|
||||
|
||||
protected:
|
||||
unsigned int count() const {
|
||||
@ -78,7 +77,7 @@ public:
|
||||
bool isRunning() const noexcept override {
|
||||
return this->_running && (_runningThread!=nullptr);
|
||||
}
|
||||
bool run() override {
|
||||
bool run() {
|
||||
if (!type_ptr->isRunning()) {
|
||||
this->_running = true;
|
||||
_runningThread = std::make_shared<std::thread>([&]{
|
||||
|
||||
@ -9,7 +9,23 @@
|
||||
#include <type_traits>
|
||||
#include "TypeTraits.hpp"
|
||||
#include <unordered_map>
|
||||
#include "StringUtils.hpp"
|
||||
#include "Utils.hpp"
|
||||
|
||||
/* #ifndef THROW_WITH_INFO
|
||||
#ifdef CODE_ERROR_LOCATIONS
|
||||
#define THROW_WITH_INFO(type, ...) throw type(__VA_ARGS__, __LINE__, __FILE__)
|
||||
#else
|
||||
#define THROW_WITH_INFO(type, ...) throw type(__VA_ARGS__)
|
||||
#endif // CODE_ERROR_LOCATIONS
|
||||
#endif // THROW_WITH_INFO
|
||||
|
||||
#ifndef THROW
|
||||
#ifdef LOGGING
|
||||
#define THROW_WTIH_INFO(type, ...) throw type(__VA_ARGS__, __LINE__, __FILE__)
|
||||
#else
|
||||
#define THROW(...) THROW_WITH_INFO(__VA_ARGS__)
|
||||
#endif // LOGGING
|
||||
#endif // THROW */
|
||||
|
||||
namespace nb {
|
||||
|
||||
@ -67,9 +83,9 @@ public:
|
||||
ErrorBase& operator=(const ErrorBase&) = delete;
|
||||
|
||||
virtual inline std::string str() const noexcept override {
|
||||
std::string ret = msg + nb::NEWLINE;
|
||||
std::string ret = msg;
|
||||
if (trace) {
|
||||
const std::string tabover = " ";
|
||||
const std::string replace = nb::NEWLINE+" ";
|
||||
std::string trace_msg;
|
||||
if (traceIsNBError) {
|
||||
trace_msg = std::static_pointer_cast<const ErrorBase>(trace)->str();
|
||||
@ -79,9 +95,13 @@ public:
|
||||
} else {
|
||||
trace_msg = std::string(trace->what());
|
||||
}
|
||||
ret += indent_strblock(trace_msg, tabover, tabover+"Trace: ")+nb::NEWLINE;
|
||||
ret += replace + "Trace: " + find_and_replace<std::string>(
|
||||
trace_msg,
|
||||
nb::NEWLINE,
|
||||
replace
|
||||
);
|
||||
}
|
||||
return ret;
|
||||
return ret + nb::NEWLINE;
|
||||
}
|
||||
|
||||
static const std::string type;
|
||||
@ -178,7 +198,7 @@ protected:
|
||||
) noexcept : ErrorBase(
|
||||
0,
|
||||
msg_,
|
||||
static_cast<std::exception*>(nullptr),
|
||||
nullptr,
|
||||
line_,
|
||||
filename_
|
||||
) {}
|
||||
@ -199,14 +219,13 @@ class Error : public ErrorBase<ErrorType> {
|
||||
using Base = ErrorBase<ErrorType>;
|
||||
public:
|
||||
template <typename... Args>
|
||||
Error(Args... args) : Base(args...) {}
|
||||
Error(Args... T) : Base(T...) {}
|
||||
|
||||
using Base::str;
|
||||
using Base::what;
|
||||
using Base::code;
|
||||
using Base::msg;
|
||||
using Base::trace;
|
||||
using Base::traceIsNBError;
|
||||
using Base::type;
|
||||
using Base::ErrorMessages;
|
||||
|
||||
@ -220,20 +239,16 @@ public:
|
||||
using Base::Base;
|
||||
Error() : Base(0) {}
|
||||
|
||||
template <typename... Args>
|
||||
Error(Args... args) : Base(args...) {}
|
||||
|
||||
enum Codes : unsigned int {
|
||||
GENERAL, UNDEFINED, BADERRORCODE
|
||||
};
|
||||
|
||||
using Base::str;
|
||||
using Base::what;
|
||||
|
||||
using Base::code;
|
||||
using Base::msg;
|
||||
using Base::trace;
|
||||
using Base::traceIsNBError;
|
||||
|
||||
static const std::string type;
|
||||
static const ErrorCodeMap ErrorMessages;
|
||||
};
|
||||
|
||||
@ -2,9 +2,12 @@
|
||||
#ifndef _NB_LOGGER
|
||||
#define _NB_LOGGER
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <iomanip>
|
||||
#include <ostream>
|
||||
#include <thread>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
@ -20,6 +23,14 @@ typedef std::chrono::time_point<
|
||||
std::chrono::nanoseconds
|
||||
> LoggerTimePoint;
|
||||
|
||||
struct LogEvent{
|
||||
const LoggerTimePoint time;
|
||||
const unsigned char lvl;
|
||||
const std::string msg;
|
||||
const std::thread::id tid;
|
||||
const uint64_t pid;
|
||||
};
|
||||
|
||||
typedef std::string (*LogProcessFunction)(const LoggerTimePoint&, const std::string&);
|
||||
typedef std::unordered_map<uint8_t, LogProcessFunction> LogProcessFunctionMap;
|
||||
|
||||
@ -30,7 +41,7 @@ class LoggerBase
|
||||
using LoggerType = Logger;
|
||||
using Base = MultithreadedDataProcessor<LogType, LoggerType>;
|
||||
public:
|
||||
bool run() override {
|
||||
bool run() {
|
||||
if (!type_ptr->isRunning()) {
|
||||
this->_running = true;
|
||||
this->_runningThread = std::make_shared<std::thread>([&]{
|
||||
@ -51,14 +62,6 @@ private:
|
||||
LoggerType* type_ptr = static_cast<LoggerType*>(this);
|
||||
};
|
||||
|
||||
struct LogEvent{
|
||||
const LoggerTimePoint time;
|
||||
const unsigned char lvl;
|
||||
const std::string msg;
|
||||
const std::thread::id tid;
|
||||
const uint64_t pid;
|
||||
};
|
||||
|
||||
template <typename LT>
|
||||
class DebugLogger : public LoggerBase<LogEvent, LT, std::vector<std::ostream*>>{
|
||||
using StreamType = std::vector<std::ostream*>;
|
||||
@ -71,7 +74,7 @@ public:
|
||||
|
||||
~DebugLogger() { type_ptr->stop(); }
|
||||
|
||||
void log(const std::string& msg, const uint8_t& lvl=0x00) {
|
||||
void log(const std::string& msg, const uint8_t& lvl=0xFF) {
|
||||
type_ptr->push(LogEvent{
|
||||
std::chrono::system_clock::now(),
|
||||
lvl,
|
||||
@ -82,7 +85,7 @@ public:
|
||||
}
|
||||
|
||||
template <size_t N>
|
||||
void log(char const(&msg) [N], const uint8_t& lvl=0x00) {
|
||||
void log(char const(&msg) [N], const uint8_t& lvl=0xFF) {
|
||||
type_ptr->log(std::string(msg), lvl);
|
||||
}
|
||||
|
||||
@ -101,6 +104,7 @@ protected:
|
||||
|
||||
private:
|
||||
LoggerType* type_ptr = static_cast<LoggerType*>(this);
|
||||
|
||||
};
|
||||
|
||||
class DefaultDebugLogger : public DebugLogger<DefaultDebugLogger> {
|
||||
@ -123,31 +127,17 @@ public:
|
||||
protected:
|
||||
using Base::_ostream;
|
||||
|
||||
bool process(const LogEvent& msg);
|
||||
bool process(const LogEvent& msg) {
|
||||
for (const auto os : this->_ostream) {
|
||||
*os << msg.lvl << "\t|\t" << msg.msg << "\n";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef _NB_NO_LOGGER
|
||||
extern DefaultDebugLogger logger;
|
||||
#endif // _NB_NO_LOGGER
|
||||
|
||||
// Taking Charge of Adult ADHD by Russell Barkley
|
||||
|
||||
} // namespace nb
|
||||
|
||||
#ifndef CONSTRUCT_ERROR
|
||||
#ifdef _NB_CODE_ERROR_LOCATIONS
|
||||
#define CONSTRUCT_ERROR(type, ...) type(# __VA_ARGS__, __LINE__, __FILE__)
|
||||
#else
|
||||
#define CONSTRUCT_ERROR(type, ...) type(__VA_ARGS__)
|
||||
#endif // _NB_CODE_ERROR_LOCATIONS
|
||||
#endif // CONSTRUCT_ERROR
|
||||
|
||||
#ifndef THROW
|
||||
#ifdef _NB_AUTOLOG
|
||||
#define THROW(type, ...) {auto x = CONSTRUCT_ERROR(type, ## __VA_ARGS__); nb::logger.error(x); throw x;}
|
||||
#else
|
||||
#define THROW(type, ...) throw CONSTRUCT_ERROR(type, __VA_ARGS__)
|
||||
#endif // _NB_AUTOLOG
|
||||
#endif // THROW
|
||||
|
||||
#endif // _NB_LOGGER
|
||||
@ -1,142 +0,0 @@
|
||||
#pragma once
|
||||
#ifndef _NB_CORE_TYPES
|
||||
#define _NB_CORE_TYPES
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
#include "TypeTraits.hpp"
|
||||
|
||||
namespace nb {
|
||||
|
||||
#ifdef _NB_TARGET_WINDOWS
|
||||
const std::string NEWLINE = "\n";
|
||||
const std::wstring WNEWLINE = L"\n";
|
||||
#endif // _NB_TARGET_WINDOWS
|
||||
#ifdef _NB_TARGET_LINUX
|
||||
const std::string NEWLINE = "\n";
|
||||
const std::wstring WNEWLINE = L"\n";
|
||||
#endif // _NB_TARGET_LINUX
|
||||
|
||||
template <typename... T>
|
||||
using StringConvertible = ValidConversion<std::string, T...>;
|
||||
|
||||
template <typename... T>
|
||||
using WStringConvertible = ValidConversion<std::wstring, T...>;
|
||||
|
||||
template <typename... T>
|
||||
constexpr bool StringConvertible_v = StringConvertible<T...>::value;
|
||||
|
||||
template <typename... T>
|
||||
constexpr bool WStringConvertible_v = WStringConvertible<T...>::value;
|
||||
|
||||
template <typename... T>
|
||||
using StringConvertible_to = typename StringConvertible<T...>::to;
|
||||
|
||||
template <typename... T>
|
||||
using WStringConvertible_to = typename WStringConvertible<T...>::to;
|
||||
|
||||
template <typename... T>
|
||||
using StringConvertible_from = typename StringConvertible<T...>::from;
|
||||
|
||||
template <typename... T>
|
||||
using WStringConvertible_from = typename WStringConvertible<T...>::from;
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<StringConvertible_v<T>, std::wstring> str_to_wstr(T in) {
|
||||
std::string str(in);
|
||||
std::wstring ret(str.begin(), str.end());
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<WStringConvertible_v<T>, std::string> wstr_to_str(T in) {
|
||||
std::wstring wstr(in);
|
||||
std::size_t wstrlen = wstr.length();
|
||||
char* c_str= new char[wstrlen];
|
||||
std::wcstombs(c_str, wstr.c_str(), wstrlen);
|
||||
std::string ret(c_str, wstrlen);
|
||||
delete[] c_str;
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename Stream, typename... Args>
|
||||
void stream(Stream& s, Args&&... args);
|
||||
|
||||
template <typename Stream, typename... Args>
|
||||
void stream(Stream& s, Args&&... args) {
|
||||
(s << ... << args);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void term(Args&&... args) { stream(std::cout, args..., nb::NEWLINE); }
|
||||
|
||||
template<typename... Args>
|
||||
void wterm(Args&&... args) { stream(std::wcout, args..., nb::WNEWLINE); }
|
||||
|
||||
template <typename T = std::string, typename A, typename B, typename C>
|
||||
ValidConversion_to<T, A, B, C> find_and_replace(
|
||||
A original,
|
||||
B find,
|
||||
C replace
|
||||
) {
|
||||
const T& find_t = T(find);
|
||||
const T& replace_t = T(replace);
|
||||
|
||||
T ret(original);
|
||||
|
||||
std::size_t find_len = find_t.length();
|
||||
std::size_t replace_len = replace_t.length();
|
||||
std::size_t currpos = 0;
|
||||
while(true) {
|
||||
currpos = ret.find(find_t, currpos);
|
||||
if (currpos == T::npos) {
|
||||
break;
|
||||
}
|
||||
ret = ret.erase(currpos, find_len);
|
||||
ret = ret.insert(currpos, replace_t);
|
||||
currpos += replace_len;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename A, typename B, typename C>
|
||||
StringConvertible_to<A, B, C> indent_strblock(
|
||||
A block,
|
||||
B prepend,
|
||||
C topIndent
|
||||
) {
|
||||
return std::string(topIndent) + find_and_replace<std::string>(
|
||||
std::string(block),
|
||||
nb::NEWLINE,
|
||||
nb::NEWLINE + std::string(prepend)
|
||||
);
|
||||
}
|
||||
|
||||
template <typename A, typename B>
|
||||
StringConvertible_to<A, B> indent_strblock(
|
||||
A block,
|
||||
B prepend
|
||||
) {
|
||||
return indent_strblock<A, B, B>(block, prepend, prepend);
|
||||
}
|
||||
|
||||
/* 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;
|
||||
} */
|
||||
|
||||
|
||||
// using ByteVector = std::vector<uint8_t>;
|
||||
|
||||
} // namespace nb
|
||||
#endif // _NB_CORE_TYPES
|
||||
@ -2,9 +2,7 @@
|
||||
#ifndef _NB_TYPE_TRAITS
|
||||
#define _NB_TYPE_TRAITS
|
||||
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
namespace nb {
|
||||
|
||||
@ -39,41 +37,11 @@ template <
|
||||
>
|
||||
using is_detected = typename detail::detector<NoneType, void, Op, Args...>::value;
|
||||
|
||||
template <typename... Types>
|
||||
struct ValidConversion;
|
||||
|
||||
template <typename To, typename A, typename B, typename... Rest>
|
||||
struct ValidConversion<To, A, B, Rest...> {
|
||||
typedef std::conjunction<
|
||||
std::is_constructible<To, A>, std::is_constructible<To, A>, std::conjunction<std::is_constructible<To, Rest>...>
|
||||
> value_type;
|
||||
static constexpr bool value = value_type::value;
|
||||
typedef std::enable_if_t<value, To> to;
|
||||
|
||||
};
|
||||
|
||||
template <typename To, typename From>
|
||||
struct ValidConversion<To, From> {
|
||||
typedef std::is_constructible<To, From> value_type;
|
||||
static constexpr bool value = value_type::value;
|
||||
typedef std::enable_if_t<value, To> to;
|
||||
typedef std::enable_if_t<value, From> from;
|
||||
};
|
||||
|
||||
template<typename... Types>
|
||||
using ValidConversion_v = typename ValidConversion<Types...>::value;
|
||||
|
||||
template<typename... Types>
|
||||
using ValidConversion_to = typename ValidConversion<Types...>::to;
|
||||
|
||||
template<typename To, typename From>
|
||||
using ValidConversion_from = typename ValidConversion<To, From>::from;
|
||||
|
||||
template<typename Func, std::size_t N=0, typename... Pack>
|
||||
/*template<std::size_t N=0, typename Func, typename... Pack>
|
||||
inline typename std::enable_if<N==sizeof...(Pack), void>::type
|
||||
ForEach(std::tuple<Pack...>&, Func) {}
|
||||
|
||||
template<typename Func, std::size_t N=0, typename... Pack>
|
||||
template<std::size_t N=0, typename Func, typename... Pack>
|
||||
inline typename std::enable_if<N < sizeof...(Pack), void>::type
|
||||
ForEach(std::tuple<Pack...>& tup, Func f) {
|
||||
f(N, std::get<N>(tup));
|
||||
@ -131,7 +99,7 @@ struct PackIsSameType<T, PackType> {
|
||||
template <typename T, typename FirstPack, typename... Pack>
|
||||
struct PackIsSameType<T, FirstPack, Pack...> {
|
||||
const bool value = std::is_base_of<T, FirstPack>::value && PackIsSameType<T, Pack...>::value;
|
||||
};
|
||||
};*/
|
||||
|
||||
} // namespace nb
|
||||
|
||||
|
||||
@ -2,8 +2,80 @@
|
||||
#ifndef _NB_CORE_TYPES
|
||||
#define _NB_CORE_TYPES
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
namespace nb {
|
||||
|
||||
#ifdef _NB_TARGET_WINDOWS
|
||||
const std::string NEWLINE = "\n";
|
||||
const std::wstring WNEWLINE = L"\n";
|
||||
#endif // _NB_TARGET_WINDOWS
|
||||
#ifdef _NB_TARGET_LINUX
|
||||
const std::string NEWLINE = "\n";
|
||||
const std::wstring WNEWLINE = L"\n";
|
||||
#endif // _NB_TARGET_LINUX
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_convertible_v<T, std::string>, std::wstring> str_to_wstr(T in) {
|
||||
std::string str(in);
|
||||
std::wstring ret(str.begin(), str.end());
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_convertible_v<T, std::wstring>, std::string> wstr_to_str(T in) {
|
||||
std::wstring wstr(in);
|
||||
std::size_t wstrlen = wstr.length();
|
||||
char* c_str= new char[wstrlen];
|
||||
std::wcstombs(c_str, wstr.c_str(), wstrlen);
|
||||
std::string ret(c_str, wstrlen);
|
||||
delete[] c_str;
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename Stream, typename... Args>
|
||||
void stream(Stream& s, Args&&... args);
|
||||
|
||||
template <typename Stream, typename... Args>
|
||||
void stream(Stream& s, Args&&... args) {
|
||||
(s << ... << args);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void term(Args&&... args) { stream(std::cout, args..., nb::NEWLINE); }
|
||||
|
||||
template<typename... Args>
|
||||
void wterm(Args&&... args) { stream(std::wcout, args..., nb::WNEWLINE); }
|
||||
|
||||
template <typename T = std::string, typename A, typename B, typename C>
|
||||
T find_and_replace(
|
||||
A original,
|
||||
B find,
|
||||
C replace
|
||||
) {
|
||||
const T& original_t = T(original);
|
||||
const T& find_t = T(find);
|
||||
const T& replace_t = T(replace);
|
||||
|
||||
T ret = original_t;
|
||||
|
||||
std::size_t find_len = find_t.length();
|
||||
std::size_t replace_len = replace_t.length();
|
||||
std::size_t currpos = 0;
|
||||
while(true) {
|
||||
currpos = ret.find(find_t, currpos);
|
||||
if (currpos == T::npos) {
|
||||
break;
|
||||
}
|
||||
ret = ret.erase(currpos, find_len);
|
||||
ret = ret.insert(currpos, replace_t);
|
||||
currpos += replace_len;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* template<typename T>
|
||||
T swap_endian(const T& val) {
|
||||
T ret;
|
||||
|
||||
@ -1,31 +1,15 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "Logger.hpp"
|
||||
#include "StringUtils.hpp"
|
||||
|
||||
namespace nb {
|
||||
|
||||
#ifndef _NB_NO_LOGGER
|
||||
nb::DefaultDebugLogger logger(std::cout);
|
||||
#endif // _NB_NO_LOGGER
|
||||
|
||||
bool nb::DefaultDebugLogger::process(const LogEvent& msg) {
|
||||
for (const auto os : this->_ostream) {
|
||||
*os << indent_strblock(
|
||||
msg.msg,
|
||||
std::string(10, ' '),
|
||||
"[ "+std::to_string(msg.lvl)+" ] : "
|
||||
) << nb::NEWLINE;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool RUN_LOGGER(nb::DefaultDebugLogger& log) {
|
||||
return log.run();
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const bool LOGGER_RUNNING = RUN_LOGGER(logger);
|
||||
|
||||
} // namespace nb
|
||||
@ -1 +0,0 @@
|
||||
#include "StringUtils.hpp"
|
||||
@ -1 +1,8 @@
|
||||
#include <string>
|
||||
#include "Utils.hpp"
|
||||
|
||||
template<>
|
||||
std::wstring nb::str_to_wstr(const std::string& in) {
|
||||
std::wstring ret(in.begin(), in.end());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -12,13 +12,5 @@ if (NB_BUILD_TESTS)
|
||||
NBCore
|
||||
GTest::gtest_main
|
||||
)
|
||||
|
||||
add_executable(LoggerTest
|
||||
./testLogger.cpp
|
||||
)
|
||||
target_link_libraries(LoggerTest
|
||||
NBCore
|
||||
)
|
||||
|
||||
gtest_discover_tests(TestCore)
|
||||
endif()
|
||||
@ -4,6 +4,7 @@
|
||||
|
||||
#include "Errors.hpp"
|
||||
#include <string>
|
||||
#include "Utils.hpp"
|
||||
|
||||
using namespace nb;
|
||||
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
#include <exception>
|
||||
|
||||
#include "Errors.hpp"
|
||||
#include "Logger.hpp"
|
||||
|
||||
|
||||
|
||||
int main() {
|
||||
nb::logger.log("Whoop!");
|
||||
try {
|
||||
THROW(nb::Error, "Hiii!");
|
||||
} catch (nb::Error<nb::NoneType> e){
|
||||
nb::logger.log("Winner winner chicken dinner!");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
#include <string>
|
||||
#include "TypeTraits.hpp"
|
||||
#include "StringUtils.hpp"
|
||||
#include "Utils.hpp"
|
||||
|
||||
namespace nb {
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user