#ifndef TEXTOUTPUT_HPP
#define TEXTOUTPUT_HPP

class TextOutput
{
public:
    virtual void write(char c) noexcept = 0;

    void write(const char *s) noexcept {
        if (s) {
            while (*s)
                write(*s++);
        }
    }

    void write(int n) noexcept {
        char buf[32];
        auto ptr = buf + sizeof(buf);

        *--ptr = '\0';
        do {
            *--ptr = "0123456789"[n % 10];
            n /= 10;
        } while (n);

        write(ptr);
    }

    void write(unsigned n) noexcept {
        char buf[32];
        auto ptr = buf + sizeof(buf);

        *--ptr = '\0';
        do {
            *--ptr = "0123456789"[n % 10];
            n /= 10;
        } while (n);

        write(ptr);
    }
};

#endif // TEXTOUTPUT_HPP