convert.cc (2883B)
1 /* -*- Mode: c++; -*- */ 2 /* -------------------------------------------------------------------- 3 * Filename: 4 * convert.cc 5 * 6 * Description: 7 * Implementation of miscellaneous convertion functions. 8 * 9 * Authors: 10 * Andreas Aardal Hanssen <andreas-binc curly bincimap spot org> 11 * 12 * Bugs: 13 * 14 * ChangeLog: 15 * 16 * -------------------------------------------------------------------- 17 * Copyright 2002-2005 Andreas Aardal Hanssen 18 * 19 * This program is free software; you can redistribute it and/or modify 20 * it under the terms of the GNU General Public License as published by 21 * the Free Software Foundation; either version 2 of the License, or 22 * (at your option) any later version. 23 * 24 * This program is distributed in the hope that it will be useful, 25 * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 * GNU General Public License for more details. 28 * 29 * You should have received a copy of the GNU General Public License 30 * along with this program; if not, write to the Free Software 31 * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. 32 * -------------------------------------------------------------------- 33 */ 34 #ifdef HAVE_CONFIG_H 35 #include <config.h> 36 #endif 37 38 #include "convert.h" 39 #include "io.h" 40 #include <string> 41 42 #include <cstring> 43 44 using namespace ::std; 45 using namespace Binc; 46 47 //------------------------------------------------------------------------ 48 BincStream::BincStream(void) 49 { 50 } 51 52 //------------------------------------------------------------------------ 53 BincStream::~BincStream(void) 54 { 55 clear(); 56 } 57 58 //------------------------------------------------------------------------ 59 const string &BincStream::str(void) const 60 { 61 return nstr; 62 } 63 64 //------------------------------------------------------------------------ 65 void BincStream::clear(void) 66 { 67 nstr = ""; 68 } 69 70 //------------------------------------------------------------------------ 71 int BincStream::getSize(void) const 72 { 73 return nstr.length(); 74 } 75 76 //------------------------------------------------------------------------ 77 BincStream &BincStream::operator << (std::ostream&(*)(std::ostream&)) 78 { 79 nstr += "\r\n"; 80 return *this; 81 } 82 83 //------------------------------------------------------------------------ 84 BincStream &BincStream::operator << (const string &t) 85 { 86 nstr += t; 87 return *this; 88 } 89 90 //------------------------------------------------------------------------ 91 BincStream &BincStream::operator << (int t) 92 { 93 nstr += toString(t); 94 return *this; 95 } 96 97 //------------------------------------------------------------------------ 98 BincStream &BincStream::operator << (unsigned int t) 99 { 100 nstr += toString(t); 101 return *this; 102 } 103 104 //------------------------------------------------------------------------ 105 BincStream &BincStream::operator << (char t) 106 { 107 nstr += t; 108 return *this; 109 }