Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals

utility.h

Go to the documentation of this file.
00001 // utility.h
00002 //////////////////////////////////////////////////////////////////////
00003 //          (c) Copyright 2001-2002 Brown Deer Technology, LLC.
00004 //                        All rights reserved.
00005 //////////////////////////////////////////////////////////////////////
00006 
00007 #ifndef UTILITY_H
00008 #define UTILITY_H
00009 
00010 #ifdef USE_STD
00011 #include <iostream>
00012 using namespace std;
00013 #else
00014 #include <iostream.h>
00015 #endif
00016 
00017 #define BYTEPACK_DEFAULT_SIZEMAX 16
00018 
00019 void inttohex( int, char*, int = sizeof(int) );
00020 
00021 class bytepack {
00022    public:
00023 
00024       bytepack( const int sizemax = BYTEPACK_DEFAULT_SIZEMAX );
00025       bytepack( const bytepack& rhs );
00026       ~bytepack();
00027 
00028       bytepack& operator()( const char data=0, const int size=sizeof(char) );
00029       bytepack& operator()( const int data=0, const int size=sizeof(int) );
00030       bytepack& operator()( const float data=0, const int size=sizeof(float) );
00031       bytepack& operator()(const double data=0,const int size=sizeof(double));
00032 
00033       bytepack& operator = ( const bytepack );
00034 
00035       char& operator[]( const int i ) { return _data[i]; }
00036       char* c_str() { return _data; }
00037 
00038       operator char();
00039       operator int();
00040       operator float();
00041       operator double();
00042 
00043       int size() { return _size; }
00044 
00045       void write( ostream& );
00046       void read( istream& );
00047 
00048    private:
00049       char* _data;
00050       int _sizemax;
00051       int _size;
00052 
00053    friend ostream& operator << ( ostream&, bytepack& );
00054    friend istream& operator >> ( istream&, bytepack& );
00055 
00056 };
00057 
00058 #endif
00059 

Generated on Mon May 31 21:38:53 2004 for SR2k4 Assembler by doxygen 1.3.6