Add missing check to ItemPtr and instantiate FileStore32 in FS library
This commit is contained in:
28
deps/ox/src/ox/trace/trace.cpp
vendored
28
deps/ox/src/ox/trace/trace.cpp
vendored
@@ -6,11 +6,15 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#if defined(OX_USE_STDLIB)
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
#include <ox/mc/write.hpp>
|
||||
|
||||
#include "trace.hpp"
|
||||
|
||||
namespace ox {
|
||||
namespace ox::trace {
|
||||
|
||||
OutStream::OutStream(const char *file, int line, const char *ch, const char *msg) {
|
||||
m_msg.file = file;
|
||||
@@ -26,4 +30,26 @@ OutStream::~OutStream() {
|
||||
writeMC(buff, buffLen, &m_msg, &size);
|
||||
}
|
||||
|
||||
|
||||
StdOutStream::StdOutStream(const char *file, int line, const char *ch, const char *msg) {
|
||||
m_msg.file = file;
|
||||
m_msg.line = line;
|
||||
m_msg.ch = ch;
|
||||
m_msg.msg = msg;
|
||||
}
|
||||
|
||||
StdOutStream::~StdOutStream() {
|
||||
#if defined(OX_USE_STDLIB)
|
||||
std::cout << m_msg.ch.c_str() << ':' << m_msg.msg.c_str();
|
||||
std::cout << " (" << m_msg.file.c_str() << ':' << m_msg.line << ")\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
NullStream::NullStream(const char*, int, const char*, const char*) {
|
||||
}
|
||||
|
||||
NullStream::~NullStream() {
|
||||
}
|
||||
|
||||
}
|
||||
|
47
deps/ox/src/ox/trace/trace.hpp
vendored
47
deps/ox/src/ox/trace/trace.hpp
vendored
@@ -10,7 +10,7 @@
|
||||
|
||||
#include <ox/std/std.hpp>
|
||||
|
||||
namespace ox {
|
||||
namespace ox::trace {
|
||||
|
||||
struct TraceMsg {
|
||||
ox::BString<150> file = "";
|
||||
@@ -21,7 +21,7 @@ struct TraceMsg {
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
int ioOp(T *io, ox::TraceMsg *obj) {
|
||||
int ioOp(T *io, ox::trace::TraceMsg *obj) {
|
||||
int32_t err = 0;
|
||||
io->setFields(5);
|
||||
err |= io->op("file", &obj->file);
|
||||
@@ -44,7 +44,7 @@ class OutStream {
|
||||
~OutStream();
|
||||
|
||||
template<typename T>
|
||||
OutStream &operator<<(T v) {
|
||||
inline OutStream &operator<<(const T &v) {
|
||||
m_msg.msg += " ";
|
||||
m_msg.msg += v;
|
||||
return *this;
|
||||
@@ -52,6 +52,45 @@ class OutStream {
|
||||
|
||||
};
|
||||
|
||||
|
||||
class StdOutStream {
|
||||
|
||||
private:
|
||||
TraceMsg m_msg;
|
||||
|
||||
public:
|
||||
StdOutStream() = default;
|
||||
|
||||
StdOutStream(const char *file, int line, const char *ch, const char *msg = "");
|
||||
|
||||
~StdOutStream();
|
||||
|
||||
template<typename T>
|
||||
inline StdOutStream &operator<<(T v) {
|
||||
m_msg.msg += " ";
|
||||
m_msg.msg += v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class NullStream {
|
||||
|
||||
public:
|
||||
NullStream() = default;
|
||||
|
||||
NullStream(const char *file, int line, const char *ch, const char *msg = "");
|
||||
|
||||
~NullStream();
|
||||
|
||||
template<typename T>
|
||||
inline NullStream &operator<<(const T&) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#define oxTrace(ch) ox::OutStream(__FILE__, __LINE__, ch)
|
||||
#define oxTrace(ch) ox::trace::StdOutStream(__FILE__, __LINE__, ch)
|
||||
|
Reference in New Issue
Block a user