mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 08:24:32 -08:00
Move to RAII-style status_line objects for console status
This commit is contained in:
@@ -11,11 +11,6 @@ class console
|
||||
public:
|
||||
console(uefi::boot_services *bs, uefi::protos::simple_text_output *out);
|
||||
|
||||
void status_begin(const wchar_t *message);
|
||||
void status_warn(const wchar_t *message, const wchar_t *error=nullptr);
|
||||
void status_fail(const wchar_t *message, const wchar_t *error=nullptr);
|
||||
void status_end();
|
||||
|
||||
size_t print_hex(uint32_t n) const;
|
||||
size_t print_dec(uint32_t n) const;
|
||||
size_t print_long_hex(uint64_t n) const;
|
||||
@@ -26,19 +21,45 @@ public:
|
||||
static size_t print(const wchar_t *fmt, ...);
|
||||
|
||||
private:
|
||||
friend class status_line;
|
||||
|
||||
void pick_mode(uefi::boot_services *bs);
|
||||
size_t vprintf(const wchar_t *fmt, va_list args) const;
|
||||
|
||||
size_t m_rows, m_cols;
|
||||
|
||||
int m_status_level;
|
||||
int m_status_line;
|
||||
|
||||
uefi::protos::simple_text_output *m_out;
|
||||
|
||||
static console *s_console;
|
||||
};
|
||||
|
||||
class status_line
|
||||
{
|
||||
public:
|
||||
status_line(const wchar_t *message);
|
||||
~status_line();
|
||||
|
||||
inline static void warn(const wchar_t *message, const wchar_t *error=nullptr) {
|
||||
if (s_current) s_current->do_warn(message, error);
|
||||
}
|
||||
|
||||
inline static void fail(const wchar_t *message, const wchar_t *error=nullptr) {
|
||||
if (s_current) s_current->do_fail(message, error);
|
||||
}
|
||||
|
||||
private:
|
||||
void print_status_tag();
|
||||
void do_warn(const wchar_t *message, const wchar_t *error);
|
||||
void do_fail(const wchar_t *message, const wchar_t *error);
|
||||
void finish();
|
||||
|
||||
size_t m_line;
|
||||
int m_level;
|
||||
int m_depth;
|
||||
|
||||
status_line *m_next;
|
||||
static status_line *s_current;
|
||||
};
|
||||
|
||||
uefi::status
|
||||
con_get_framebuffer(
|
||||
uefi::boot_services *bs,
|
||||
|
||||
Reference in New Issue
Block a user