Files
dusklight/src/JSystem/JGadget/define.cpp
T
kipcode66 1d2a0d9568 Add guards around std library headers (#3013)
* Last fix for standard compiler error

* adding define guards around headers

* rename cmath.h and climits.h to cmath and climits respectively

* renaming cstdarg.h to cstdarg

* renaming cstdlib.h to cstdlib

* renaming cstring.h to cstring

* renaming cstdio.h to cstdio

* renaming cmath locale ctype

* renaming stdarg string and va_list

* renaming cstddef

* renaming stdio stddef stdlib

* renaming algorithm, functional, iterator, memory, and utility

* renaming bitset, cstdint, limits, and stdint

* renaming new and type_traits

* update quote includes for standard library headers to angle bracket includes
2026-01-05 03:50:45 -08:00

73 lines
1.5 KiB
C++

#include "JSystem/JSystem.h" // IWYU pragma: keep
#include "JSystem/JGadget/define.h"
#define MSL_USE_INLINES 1
#include <ctype>
JGadget_outMessage::JGadget_outMessage(MessageFunc fn, const char* file, int line) {
mMsgFunc = fn;
mFile = file;
mLine = line;
mWrite_p = mBuffer;
*mWrite_p = 0;
}
JGadget_outMessage::~JGadget_outMessage() {
for (u8* p = (u8*)mBuffer; p != (u8*)mWrite_p; p++) {
char c = *p;
if (!isprint(c) && !isspace(c)) {
*p = '_';
}
}
mMsgFunc(mFile, mLine, mBuffer);
}
JGadget_outMessage& JGadget_outMessage::operator<<(const char* sz) {
JUT_ASSERT(99, sz!=NULL);
while (*sz != 0 && mWrite_p < mBuffer + (BUFFER_SIZE - 1)) {
*mWrite_p = *sz;
mWrite_p++;
sz++;
}
*mWrite_p = 0;
return *this;
}
JGadget_outMessage& JGadget_outMessage::operator<<(char c) {
char sz[2];
sz[0] = c;
sz[1] = 0;
return *this << sz;
}
JGadget_outMessage& JGadget_outMessage::operator<<(s32 value) {
char sz[64];
snprintf(sz, 64, "%d", value);
return *this << sz;
}
JGadget_outMessage& JGadget_outMessage::operator<<(u32 value) {
char sz[64];
snprintf(sz, 64, "%u", value);
return *this << sz;
}
JGadget_outMessage& JGadget_outMessage::operator<<(const void* data) {
char sz[64];
snprintf(sz, 64, "%p", data);
return *this << sz;
}
void JGadget_outMessage::warning(const char* file, int line, const char* message) {
JUTAssertion::setWarningMessage(3, (char*)file, line, message);
}