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

bytepack Class Reference

#include <DCFbytepack.h>

Collaboration diagram for bytepack:

Collaboration graph
[legend]

Public Member Functions

 bytepack (const bytepack &rhs)
 bytepack (const int sizemax=BYTEPACK_DEFAULT_SIZEMAX)
 bytepack (const int sizemax=16)
char * c_str ()
char * c_str ()
 operator char ()
 operator char ()
 operator double ()
 operator double ()
 operator float ()
 operator float ()
 operator int ()
 operator int ()
bytepackoperator() (const double data=0, const int size=sizeof(double))
bytepackoperator() (const float data=0, const int size=sizeof(float))
bytepackoperator() (const int data=0, const int size=sizeof(int))
bytepackoperator() (const char data=0, const int size=sizeof(char))
bytepackoperator() (const double data=0, const int size=0)
bytepackoperator() (const float data=0, const int size=0)
bytepackoperator() (const int data=0, const int size=0)
bytepackoperator() (const char data=0, const int size=0)
bytepackoperator= (const bytepack)
char & operator[] (const int i)
char & operator[] (const int i)
void read (istream &)
int size ()
int size ()
void write (ostream &)
 ~bytepack ()
 ~bytepack ()

Private Attributes

char * _data
char * _pt
int _size
int _sizemax

Friends

ostream & operator<< (ostream &, bytepack &)
ostream & operator<< (ostream &, bytepack &)
istream & operator>> (istream &, bytepack &)
istream & operator>> (istream &, bytepack &)

Constructor & Destructor Documentation

bytepack::bytepack const int  sizemax = 16  ) 
 

Definition at line 42 of file DCFbytepack.h.

References _pt, and _sizemax.

00043   : _sizemax(sizemax), _size(0) 
00044 {
00045    _pt = new char[ _sizemax + 1 ]; 
00046    _pt[0] = 0;
00047 }

bytepack::~bytepack  ) 
 

Definition at line 50 of file DCFbytepack.h.

References _pt.

00050 { delete [] _pt; _pt = 0; }

bytepack.bytepack const int  sizemax = BYTEPACK_DEFAULT_SIZEMAX  ) 
 

bytepack::bytepack const bytepack rhs  ) 
 

Definition at line 52 of file utility.cpp.

References _data, and _sizemax.

00053   : _sizemax(rhs._sizemax), _size(rhs._size) 
00054 {
00055    _data = new char[ _sizemax + 1 ]; 
00056    for( int i = 0; i < rhs._sizemax; ++i ) _data[i] = rhs._data[i];
00057 }

bytepack.~bytepack  ) 
 


Member Function Documentation

char* bytepack.c_str  ) 
 

Definition at line 36 of file utility.h.

00036 { return _data; }

char* bytepack.c_str  ) 
 

Definition at line 30 of file DCFbytepack.h.

References _pt.

00030 { return _pt; }

bytepack.operator char  ) 
 

bytepack::operator char  ) 
 

Definition at line 118 of file DCFbytepack.cpp.

References _pt.

00118 { return char(_pt[0]); }

bytepack.operator double  ) 
 

bytepack::operator double  ) 
 

Definition at line 168 of file DCFbytepack.cpp.

References _pt, and _size.

00168                           {
00169    double data=0;
00170    char* ptdata = (char*)(&data);
00171 #ifdef STORM_RS6000_AIX
00172    for( int i = 0; i < min( _size, int(sizeof(double)) ); i++ ) { 
00173       ptdata[i] = _pt[i]; 
00174    }
00175 #endif
00176 #ifdef STORM_x86_LINUX
00177    for( int i = 0; i < min( _size, int(sizeof(double)) ); i++ ) { 
00178       ptdata[ sizeof(double) - 1 - i ] = _pt[i];
00179    }
00180 #endif
00181 #ifdef STORM_SGI_IRIX
00182    for( int i = 0; i < min( _size, int(sizeof(double)) ); i++ ) { 
00183       ptdata[i] = _pt[i]; 
00184    }
00185 #endif
00186    return data;
00187 };

bytepack.operator float  ) 
 

bytepack::operator float  ) 
 

Definition at line 147 of file DCFbytepack.cpp.

References _pt, and _size.

00147                          {
00148    float data = 0;
00149    char* ptdata = (char*)(&data);
00150 #ifdef STORM_RS6000_AIX
00151    for( int i = 0; i < min( _size, int(sizeof(float)) ); i++ ) { 
00152       ptdata[i] = _pt[i]; 
00153    }
00154 #endif
00155 #ifdef STORM_x86_LINUX
00156    for( int i = 0; i < min( _size, int(sizeof(float)) ); i++ ) { 
00157       ptdata[ sizeof(float) - 1 - i ] = _pt[i];
00158    }
00159 #endif
00160 #ifdef STORM_SGI_IRIX
00161    for( int i = 0; i < min( _size, int(sizeof(float)) ); i++ ) { 
00162       ptdata[i] = _pt[i]; 
00163    }
00164 #endif
00165    return data;
00166 };

bytepack.operator int  ) 
 

bytepack::operator int  ) 
 

Definition at line 120 of file DCFbytepack.cpp.

References _pt, and _size.

00120                        {
00121    int data;
00122    char* ptdata = (char*)(&data);
00123    if ((_pt[_size-1]&0x80)) {
00124       for( int i = 0; i < sizeof(int); i++ ) ptdata[i] = 0xFF; 
00125    }
00126    else {
00127       for( int i = 0; i < sizeof(int); i++ ) ptdata[i] = 0x00; 
00128    }
00129 #ifdef STORM_RS6000_AIX
00130    for( int i = 0; i < min( _size, int(sizeof(int)) ); i++ ) { 
00131       ptdata[ sizeof(int) - 1 - i ] = _pt[i]; 
00132    }
00133 #endif
00134 #ifdef STORM_x86_LINUX
00135    for( int i = 0; i < min( _size, int(sizeof(int)) ); i++ ) { 
00136       ptdata[i] = _pt[i]; 
00137    }
00138 #endif
00139 #ifdef STORM_SGI_IRIX
00140    for( int i = 0; i < min( _size, int(sizeof(int)) ); i++ ) { 
00141       ptdata[ sizeof(int) - 1 - i ] = _pt[i]; 
00142    }
00143 #endif
00144    return data;
00145 };

bytepack& bytepack.operator() const double  data = 0,
const int  size = sizeof(double)
 

bytepack& bytepack.operator() const float  data = 0,
const int  size = sizeof(float)
 

bytepack& bytepack.operator() const int  data = 0,
const int  size = sizeof(int)
 

bytepack& bytepack.operator() const char  data = 0,
const int  size = sizeof(char)
 

bytepack & bytepack::operator() const double  data = 0,
const int  size = 0
 

Definition at line 93 of file DCFbytepack.cpp.

References _pt, and _size.

00093                                                                    {
00094    double data = data0;
00095    char* ptdata = (char*)(&data);
00096    for( int i = 0; i <= size; i++ ) _pt[i] = 0;
00097 #ifdef STORM_RS6000_AIX
00098    for( int i = 0; i < min( size, int(sizeof(double)) ); i++ ) {
00099       _pt[i] = ptdata[i]; 
00100    }
00101    _size = size;
00102 #endif
00103 #ifdef STORM_x86_LINUX
00104    for( int i = 0; i < min( size, int(sizeof(double)) ); i++ ) {
00105       _pt[i] = ptdata[ sizeof(double) - 1 - i ]; 
00106    }
00107    _size = size;
00108 #endif
00109 #ifdef STORM_SGI_IRIX
00110    for( int i = 0; i < min( size, int(sizeof(double)) ); i++ ) {
00111       _pt[i] = ptdata[i]; 
00112    }
00113    _size = size;
00114 #endif
00115    return *this;
00116 };

bytepack & bytepack::operator() const float  data = 0,
const int  size = 0
 

Definition at line 62 of file DCFbytepack.cpp.

References _pt, and _size.

00062                                                                   {
00063    float data = data0;
00064    char* ptdata = (char*)(&data);
00065    for( int i = 0; i <= size; i++ ) _pt[i] = 0;
00066 #ifdef STORM_RS6000_AIX
00067    for( int i = 0; i < min( size, int(sizeof(float)) ); i++ ) {
00068       _pt[i] = ptdata[i]; 
00069    }
00070    _size = size;
00071 #endif
00072 #ifdef STORM_x86_LINUX
00073    for( int i = 0 ; i < min( size, int(sizeof(float)) ); i++ ) {
00074       _pt[i] = ptdata[ sizeof(float) - 1 - i ]; 
00075    }
00076    _size = size;
00077 #endif
00078 #ifdef STORM_SGI_IRIX
00079    for( i = 0; i < min( size, int(sizeof(float)) ); i++ ) {
00080       _pt[i] = ptdata[i]; 
00081    }
00082    _size = size;
00083 #endif
00084 //#ifdef STORM_DEBUG
00085 //   cout << "bytepack::operator(): float : data0 _size _pt[] "
00086 //      << data0 << ' ' << _size << ' ';
00087 //   for(i=0;i<_size;i++) { cout << int( (unsigned char)(_pt[i]) ) << ' '; }
00088 //   cout << '\n';
00089 //#endif
00090    return *this;
00091 };

bytepack & bytepack::operator() const int  data = 0,
const int  size = 0
 

Definition at line 37 of file DCFbytepack.cpp.

References _pt, and _size.

00037                                                                 {
00038    int data = data0;
00039    char* ptdata = (char*)(&data);
00040    for(int i=0;i<=size;i++) _pt[i] = 0;
00041 #ifdef STORM_RS6000_AIX
00042    for(int i = 0; i < min( size, int(sizeof(int)) ); i++ ) {
00043       _pt[i] = ptdata[ sizeof(int) - 1 - i ]; 
00044    }
00045    _size = size;
00046 #endif
00047 #ifdef STORM_x86_LINUX
00048    for( int i = 0; i < min( size, int(sizeof(int)) ); i++ ) {
00049       _pt[i] = ptdata[i]; 
00050    }
00051    _size = size;
00052 #endif
00053 #ifdef STORM_SGI_IRIX
00054    for( int i = 0; i < min( size, int(sizeof(int)) ); i++ ) {
00055       _pt[i] = ptdata[ sizeof(int) - 1 - i ]; 
00056    }
00057    _size = size;
00058 #endif
00059    return *this;
00060 };

bytepack & bytepack::operator() const char  data = 0,
const int  size = 0
 

Definition at line 29 of file DCFbytepack.cpp.

References _pt, and _size.

00030 {
00031    for( int i = 0; i <= size; i++ ) _pt[i] = 0;
00032    _pt[0] = data;
00033    _size = 1;
00034    return *this;
00035 };

bytepack & bytepack::operator= const  bytepack  ) 
 

Definition at line 144 of file utility.cpp.

References _data, _size, and _sizemax.

00145 {
00146    _sizemax = bp._sizemax;
00147    if ( _data != 0 ) delete [] _data;
00148    _data = new char[ _sizemax + 1 ]; 
00149    _size = bp._size;
00150    for( int i = 0; i < ( _sizemax + 1); ++i ) _data[i] = bp._data[i];
00151    return *this;
00152 }

char& bytepack.operator[] const int  i  ) 
 

Definition at line 35 of file utility.h.

00035 { return _data[i]; }

char& bytepack.operator[] const int  i  ) 
 

Definition at line 29 of file DCFbytepack.h.

References _pt.

00029 { return _pt[i]; }

void bytepack::read istream &   ) 
 

Definition at line 230 of file utility.cpp.

References _size.

Referenced by operator>>().

00231 {
00232    for( int i = 0; i < _size; i++ ) is.get( _data[i] );
00233    _data[ _size ] = 0;
00234 }

int bytepack.size  ) 
 

Definition at line 43 of file utility.h.

References _size.

00043 { return _size; }

int bytepack.size  ) 
 

Definition at line 24 of file DCFbytepack.h.

References _size.

Referenced by MCFmpBase.push_back(), DCFmpBase.push_back(), DCFmpacketBase.put(), BufferBase.read(), DCFmpacket< Rtrsmra< float, scalar > >.replace(), DCFmpacket< Rtrsmra< float, array > >.replace(), DCFmpacket< Rtrsmra< double, scalar > >.replace(), DCFmpacket< Rtrsmra< double, array > >.replace(), DCFmpacket< Rtmra< float, scalar > >.replace(), DCFmpacket< Rtmra< float, array > >.replace(), DCFmpacket< Rtmra< double, scalar > >.replace(), DCFmpacket< Rtmra< double, array > >.replace(), and BufferBase.write().

00024 { return _size; }

void bytepack::write ostream &   ) 
 

Definition at line 225 of file utility.cpp.

References _size.

Referenced by operator<<().

00226 {
00227    for( int i = 0; i < _size; i++ ) os.put( _data[i] );
00228 }


Friends And Related Function Documentation

ostream& operator<< ostream &  os,
bytepack bp
[friend]
 

Definition at line 189 of file DCFbytepack.cpp.

00189                                                    {
00190    for( int i = 0; i < bp._size; i++ ) { os.put( bp._pt[i] ); }
00191 //#ifdef STORM_DEBUG
00192 //   cout << "bytepack:operator<<: ";
00193 //   for(i=0;i<bp._size;i++) { cout << int( (unsigned char)(bp._pt[i]) ); }
00194 //   cout << '\n';
00195 //#endif
00196    return os;
00197 };

ostream& operator<< ostream &  os,
bytepack bp
[friend]
 

Definition at line 189 of file DCFbytepack.cpp.

00189                                                    {
00190    for( int i = 0; i < bp._size; i++ ) { os.put( bp._pt[i] ); }
00191 //#ifdef STORM_DEBUG
00192 //   cout << "bytepack:operator<<: ";
00193 //   for(i=0;i<bp._size;i++) { cout << int( (unsigned char)(bp._pt[i]) ); }
00194 //   cout << '\n';
00195 //#endif
00196    return os;
00197 };

istream& operator>> istream &  is,
bytepack bp
[friend]
 

Definition at line 199 of file DCFbytepack.cpp.

00199                                                    {
00200    for( int i = 0; i < bp._size; i++ ) { is.get( bp._pt[i] ); }
00201    bp._pt[ bp._size ] = 0;
00202    return is;
00203 };

istream& operator>> istream &  is,
bytepack bp
[friend]
 

Definition at line 199 of file DCFbytepack.cpp.

00199                                                    {
00200    for( int i = 0; i < bp._size; i++ ) { is.get( bp._pt[i] ); }
00201    bp._pt[ bp._size ] = 0;
00202    return is;
00203 };


Field Documentation

char* bytepack._data [private]
 

Definition at line 49 of file utility.h.

Referenced by bytepack(), and operator=().

char* bytepack._pt [private]
 

Definition at line 36 of file DCFbytepack.h.

Referenced by bytepack(), c_str(), operator char(), operator double(), operator float(), operator int(), operator()(), operator<<(), operator>>(), operator[](), and ~bytepack().

int bytepack::_size [private]
 

Definition at line 51 of file utility.h.

Referenced by operator double(), operator float(), operator int(), operator()(), operator<<(), operator=(), operator>>(), read(), size(), and write().

int bytepack::_sizemax [private]
 

Definition at line 50 of file utility.h.

Referenced by bytepack(), and operator=().


The documentation for this class was generated from the following files:
Generated on Mon May 31 21:40:43 2004 for SR2k4 Assembler by doxygen 1.3.6