00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "nbaseoutput.h"
00023
00024 NBaseOutput::NBaseOutput(void)
00025 : m_base(DECIMAL)
00026 {
00027
00028 }
00029
00030 NBaseOutput::~NBaseOutput(void) {
00031 fflush(NULL);
00032 }
00033
00034 NBaseOutput &NBaseOutput::setBase(Base base) {
00035 m_base = base;
00036
00037 return *this;
00038 }
00039
00040 void NBaseOutput::print(nint32 val) {
00041 switch (m_base) {
00042 case HEXADECIMAL: {
00043 printf("%x", val);
00044 break;
00045 }
00046 case OCTAL: {
00047 printf("%o", val);
00048 break;
00049 }
00050 case DECIMAL:
00051 default: {
00052 printf("%d", val);
00053 break;
00054 }
00055 }
00056 }
00057
00058 void NBaseOutput::print(nuint32 val) {
00059 switch (m_base) {
00060 case HEXADECIMAL: {
00061 printf("%x",val);
00062 break;
00063 }
00064 case OCTAL: {
00065 printf("%o", val);
00066 break;
00067 }
00068 case DECIMAL:
00069 default: {
00070 printf("%u", val);
00071 break;
00072 }
00073 }
00074 }
00075
00076
00077 void NBaseOutput::print(nint64 val) {
00078
00079 printf("%lld", val);
00080 }
00081
00082 void NBaseOutput::print(nuint64 val) {
00083 printf("%llu", val);
00084 }
00085
00086
00087 void NBaseOutput::print(double d) {
00088 printf("%f", d);
00089 }
00090
00091
00092 void NBaseOutput::print(char c) {
00093 printf("%c", c);
00094 }
00095
00096
00097 void NBaseOutput::print(const NString &str) {
00098 printf("%s", str.toChar());
00099 }
00100
00101
00102 void NBaseOutput::print(const void *ptr) {
00103 printf("%p", ptr);
00104 }
00105
00106
00107 void NBaseOutput::print(const char *str) {
00108 printf("%s", str);
00109 }
00110
00111
00112
00113 void NBaseOutput::println(const NString &str) {
00114 printf("%s\n", str.toChar());
00115 }