Platform-independent API wrapper for OS-specific operations. More...
Functions | |
| 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. | |
Variables | |
| 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.
Example of platform-independent colored console output:
Other common operations include:
| const _nout std::string & by::platformAPI::backColor | ( | consoleColor | back | ) |
Returns platform-specific string for console background color.
| _nout std::vector< std::string > by::platformAPI::callstack | ( | ) |
Captures current call stack for debugging.
| _nout void by::platformAPI::crash | ( | const nchar * | msg, |
| ... ) |
Terminates program with error message and call stack dump.
| _nout std::string by::platformAPI::createNowTime | ( | const std::string & | strftime_format | ) |
Creates formatted timestamp using strftime format.
| _nout std::string by::platformAPI::demangle | ( | const nchar * | org | ) |
Demangles C++ symbol name to human-readable form.
| _nout std::string by::platformAPI::exec | ( | const std::string & | cmd | ) |
Executes shell command and captures output.
| _nout std::string by::platformAPI::filterDemangle | ( | const nchar * | org | ) |
Demangles C++ symbol and extracts only the function name portion.
| const _nout std::string & by::platformAPI::foreColor | ( | consoleColor | fore | ) |
Returns platform-specific string for console foreground color.
| _nout std::string by::platformAPI::format | ( | const nchar * | fmt, |
| ... ) |
Formats string using printf-style specifiers.
| _nout std::string by::platformAPI::getExecPath | ( | ) |
Retrieves absolute path of currently running executable.
| _nout std::string by::platformAPI::toAddrId | ( | const void * | inst | ) |
Converts pointer to 4-character hexadecimal identifier.
| _nout nbool by::platformAPI::unlimitCoreDump | ( | ) |
Enables unlimited core dump size for debugging.