2015-10-10 12:59:23 +00:00
|
|
|
#ifndef _OUTPUT_HPP
|
|
|
|
#define _OUTPUT_HPP
|
2015-10-10 16:03:53 +00:00
|
|
|
#include <base.hpp>
|
|
|
|
#include <stdint.h>
|
2015-10-10 12:59:23 +00:00
|
|
|
namespace MTGosHAL {
|
2015-10-10 16:03:53 +00:00
|
|
|
|
2015-10-10 12:59:23 +00:00
|
|
|
enum class Base : int {
|
|
|
|
BINARY=2,
|
|
|
|
TERNARY,
|
|
|
|
BASE4,
|
|
|
|
BASE5,
|
|
|
|
BASE6,
|
|
|
|
BASE7,
|
|
|
|
OCTAL,
|
|
|
|
BASE9,
|
|
|
|
DECIMAL,
|
|
|
|
BASE11,
|
|
|
|
BASE12,
|
|
|
|
BASE13,
|
|
|
|
BASE14,
|
|
|
|
BASE15,
|
|
|
|
HEXADECIMAL
|
|
|
|
};
|
|
|
|
/* abstract */ class Output {
|
|
|
|
private:
|
2015-10-10 16:03:53 +00:00
|
|
|
virtual auto putChar(char c) -> void = 0;
|
|
|
|
auto puts(const char* s) -> void;
|
2015-10-10 12:59:23 +00:00
|
|
|
int base=10;
|
|
|
|
public:
|
|
|
|
template <typename T>
|
|
|
|
auto operator<<(T output) -> Output & {
|
|
|
|
puts(output); //kernel won't compile if class cannot be converted into string
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
template <>
|
2015-10-10 16:03:53 +00:00
|
|
|
auto Output::operator<<<Base>(Base output) -> Output &;
|
2015-10-10 12:59:23 +00:00
|
|
|
template <>
|
2015-10-10 16:03:53 +00:00
|
|
|
auto Output::operator<<<int>(int output) -> Output &;
|
2015-10-10 12:59:23 +00:00
|
|
|
template <>
|
2015-10-10 16:03:53 +00:00
|
|
|
auto Output::operator<<<char>(char output) -> Output &;
|
2015-10-10 12:59:23 +00:00
|
|
|
template <>
|
2015-10-10 16:03:53 +00:00
|
|
|
auto Output::operator<<<char*>(char* output) -> Output &;
|
2015-10-10 12:59:23 +00:00
|
|
|
}
|
|
|
|
#endif
|