로딩중...
검색중...
일치하는것 없음
by::platformAPI 네임스페이스 참조

Platform-independent API wrapper for OS-specific operations 더 자세히 ...

함수

const string & foreColor (consoleColor fore)
 Returns platform-specific string for console foreground color
 
const string & backColor (consoleColor back)
 Returns platform-specific string for console background color
 
string createNowTime (const std::string &strftime_format)
 Creates formatted timestamp using strftime format
 
nuint64 getNowMs ()
 
string toAddrId (const void *inst)
 Converts pointer to 4-character hexadecimal identifier
 
void log (const std::string &msg)
 
void log (const std::string *it) BY_SIDE_FUNC(log)
 
string getExecPath ()
 Retrieves absolute path of currently running executable
 
string exec (const std::string &cmd)
 Executes shell command and captures output
 
vector< string > callstack ()
 Captures current call stack for debugging
 
string demangle (const nchar *org)
 Demangles C++ symbol name to human-readable form
 
string filterDemangle (const nchar *org)
 Demangles C++ symbol and extracts only the function name portion
 
std::string format (const nchar *fmt,...)
 Formats string using printf-style specifiers
 
std::string format (const std::string &fmt, va_list args)
 
std::string format (const std::string *fmt, va_list args) BY_SIDE_FUNC(fmt
 
std::string format (const nchar *fmt, va_list args)
 
void crash (const nchar *msg,...)
 Terminates program with error message and call stack dump
 
void crash (const std::string &msg, va_list args)
 
void crash (const std::string *msg, va_list args) BY_SIDE_FUNC(msg
 
void crash void ())
 
void crash (const std::string &msg)
 
void crash (const std::string *it) BY_SIDE_FUNC(crash)
 
nbool unlimitCoreDump ()
 Enables unlimited core dump size for debugging
 

변수

constexpr nint PATH_MAX_LEN = 256
 
constexpr nint MAX_BUF = 512
 
std::string format fmt
 
void crash msg
 

상세한 설명

Platform-independent API wrapper for OS-specific operations

Provides a unified interface for platform-dependent operations, acting as a buffer layer between platform-specific APIs and the rest of the codebase.

For example, colored text output requires different approaches on different platforms: POSIX systems use ANSI escape sequences, while Windows uses WINAPI. Using platformAPI::foreColor() allows writing platform-independent code.

Usage

Example of platform-independent colored console output:

cout << foreColor(LIGHTGRAY) << "("
<< foreColor(YELLOW) << _encodeNewLine(rightName)
<< foreColor(LIGHTGRAY) << ")";
const string & foreColor(consoleColor fore)
Returns platform-specific string for console foreground color
Definition platformAPI.cpp:51
Rich logging support with polymorphic type conversion
Definition richLog.hpp:34

Other common operations include:

함수 문서화

◆ backColor()

const _nout std::string & by::platformAPI::backColor ( consoleColor back)

Returns platform-specific string for console background color

반환값
On POSIX returns ANSI escape sequence, on Windows modifies console and returns empty string. Returns empty if terminal doesn't support colors.

◆ callstack()

_nout std::vector< std::string > by::platformAPI::callstack ( )

Captures current call stack for debugging

반환값
Vector of demangled function names, excluding invalid entries. Returns empty if execinfo unavailable.
주의
Requires execinfo.h support (BY_HAS_EXECINFO == 1)

◆ crash()

_nout void by::platformAPI::crash ( const nchar * msg,
... )

Terminates program with error message and call stack dump

주의
Outputs crash banner, reason, callstack, then calls abort()

◆ createNowTime()

_nout std::string by::platformAPI::createNowTime ( const std::string & strftime_format)

Creates formatted timestamp using strftime format

반환값
Formatted time string representing current local time

◆ demangle()

_nout std::string by::platformAPI::demangle ( const nchar * org)

Demangles C++ symbol name to human-readable form

반환값
Demangled name on POSIX, original string on Windows/WASM or if demangling fails

◆ exec()

_nout std::string by::platformAPI::exec ( const std::string & cmd)

Executes shell command and captures output

반환값
Complete stdout output. Returns empty on Windows or execution failure.
주의
POSIX only. Uses popen/pclose internally.

◆ filterDemangle()

_nout std::string by::platformAPI::filterDemangle ( const nchar * org)

Demangles C++ symbol and extracts only the function name portion

반환값
Function name after "::" on POSIX, after last space on Windows

◆ foreColor()

const _nout std::string & by::platformAPI::foreColor ( consoleColor fore)

Returns platform-specific string for console foreground color

반환값
On POSIX returns ANSI escape sequence, on Windows modifies console and returns empty string. Returns empty if terminal doesn't support colors.

◆ format()

_nout std::string by::platformAPI::format ( const nchar * fmt,
... )

Formats string using printf-style specifiers

반환값
Formatted string (max 512 characters)

◆ getExecPath()

_nout std::string by::platformAPI::getExecPath ( )

Retrieves absolute path of currently running executable

반환값
Absolute path on Linux/macOS, empty string on Windows or error
주의
Uses /proc/self/exe on Linux, _NSGetExecutablePath on macOS

◆ toAddrId()

_nout std::string by::platformAPI::toAddrId ( const void * inst)

Converts pointer to 4-character hexadecimal identifier

반환값
Last 4 hex digits of address
주의
Commonly used in logging with "@" prefix (e.g., "obj@a4f2")

◆ unlimitCoreDump()

_nout nbool by::platformAPI::unlimitCoreDump ( )

Enables unlimited core dump size for debugging

반환값
true if successfully set, false otherwise
주의
On POSIX sets RLIMIT_CORE to infinity, on Windows registers minidump filter. Should be called early in debug builds.