nbaseoutput.cpp

00001 // LICENSE: (Please see the file COPYING for details)
00002 //
00003 // NUS - Nemesis Utilities System: A C++ application development framework 
00004 // Copyright (C) 2006, 2007 Otavio Rodolfo Piske
00005 //
00006 //  This file is part of NUS
00007 //
00008 //  This library is free software; you can redistribute it and/or
00009 //  modify it under the terms of the GNU Lesser General Public
00010 //  License as published by the Free Software Foundation version 2.1
00011 //  of the License.
00012 //
00013 //  This library is distributed in the hope that it will be useful,
00014 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 //  Lesser General Public License for more details.
00017 //
00018 //  You should have received a copy of the GNU Lesser General Public
00019 //  License along with this library; if not, write to the Free Software
00020 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
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       //switch (m_base
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 }

Generated on Wed Mar 5 23:10:35 2008 for NemesisUtilitiesSystem by  doxygen 1.5.4