1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
| #include "stdafx.h"
#include "OField.h"
#include "UtilitairesString.h"
#include "Instrumentation.h"
OField* OField::Cloner() const
{
INSTRUMENTER(this, "OField* OField::Cloner() const");
return new OField(*this);
}
bool OField::EstVide() const
{
INSTRUMENTER(this, "bool OField::EstVide() const");
return true;
}
void OField::Vider()
{
INSTRUMENTER(this, "void OField::Vider()");
}
String OField::ToString() const
{
INSTRUMENTER(this, "String OField::ToString() const");
return "";
}
void OField::FromString( pcTChar )
{
INSTRUMENTER(this, "void OField::FromString( pcTChar )");
}
Octets OField::ToOctets() const
{
INSTRUMENTER(this, "Octets OField::ToOctets() const");
return Octets();
}
void OField::FromOctets( const Octets& /*y*/ )
{
INSTRUMENTER(this, "void OField::FromOctets( const Octets& y )");
}
bool OField::operator==( const OField& fld ) const
{
INSTRUMENTER(this, "bool OField::operator==(const OField& fld)const ");
return true;
}
bool OField::operator!=( const OField& fld ) const
{
INSTRUMENTER(this, "bool OField::operator!=(const OField& fld)const ");
return !operator==(fld);
}
bool OField::operator<( const OField& fld ) const
{
INSTRUMENTER(this, "bool OField::operator<(const OField& fld)const ");
return false;
}
bool OField::operator<=( const OField& fld ) const
{
INSTRUMENTER(this, "bool OField::operator<=(const OField& fld)const ");
return !operator>(fld);
}
bool OField::operator> ( const OField& fld ) const
{
INSTRUMENTER(this, "bool OField::operator>(const OField& fld)const ");
return fld<*this;
}
bool OField::operator>=( const OField& fld ) const
{
INSTRUMENTER(this, "bool OField::operator>=(const OField& fld)const ");
return !operator<(fld);
}
//==============================================================================
// FromOctets
//==============================================================================
_Base_Function void FromOctets( int& i, const Octets& y )
{
INSTRUMENTER(NULL, "void FromOctets(int & i, const Octets& y)");
int size = y.Taille();
Assert( size > 0 && size <= sizeof(int), "FromOctets(int&,const Octets&)" );
if ( size == sizeof(int) ) i = *(const int*) (pcVoid)y;
else if ( size == sizeof(short) ) i = *(const short*)(pcVoid)y;
else if ( size == sizeof(char) ) i = *(const char*) (pcVoid)y;
else Assert( 0, "FromOctets(int&,const Octets&)");
}
_Base_Function void FromOctets( long& i, const Octets& y )
{
INSTRUMENTER(NULL, "void FromOctets(long & i, const Octets& y)");
int size = y.Taille();
Assert( size > 0 && size <= sizeof(long), "FromOctets(long&,const Octets&)" );
if ( size == sizeof(long) ) i = *(const long*) (pcVoid)y;
else if ( size == sizeof(short) ) i = *(const short*)(pcVoid)y;
else if ( size == sizeof(char) ) i = *(const char*) (pcVoid)y;
else Assert( 0, "FromOctets(long&,const Octets&)" );
}
_Base_Function void FromOctets( short& i, const Octets& y )
{
INSTRUMENTER(NULL, "void FromOctets(short & i, const Octets& y)");
int size = y.Taille();
Assert( size > 0 && size <= sizeof(short), "FromOctets(short&,const Octets&)" );
if ( size == sizeof(short) ) i = *(const short*)(pcVoid)y;
else if ( size == sizeof(char) ) i = *(const char*) (pcVoid)y;
else Assert( 0, "FromOctets(short&,const Octets&)" );
}
_Base_Function void FromOctets( double& i, const Octets& y )
{
INSTRUMENTER(NULL, "void FromOctets(double & i, const Octets& y)");
int size = y.Taille();
Assert( size > 0 && size <= sizeof(double), "FromOctets(double&,const Octets&)" );
if ( size == sizeof(double) ) i = *(const double*)(pcVoid)y;
else if ( size == sizeof(float) ) i = *(const float*) (pcVoid)y;
else Assert( 0, "FromOctets(double&,const Octets&)" );
}
_Base_Function void FromOctets( bool& b, const Octets& y )
{
INSTRUMENTER(NULL, "void FromOctets(bool& b, const Octets& y)");
Assert( y.Taille() > 0, "FromOctets(bool&,const Octets&)" );
b = !_strcmpi((const char*)(pcVoid)y, "O");
}
_Base_Function void FromOctets( String& str , const Octets& y )
{
INSTRUMENTER(NULL, "void FromOctets(String& str, const Octets& y)");
str = (pcTChar)(pcVoid)y;
}
_Base_Function void FromOctets( GroupeDateHeure& gdh, const Octets& y )
{
INSTRUMENTER(NULL, "void FromOctets(GroupeDateHeure& gdh, const Octets& y)");
FromString( (pcTChar)(pcVoid)y, gdh );
}
_Base_Function void FromOctets( Octets& y1, const Octets& y )
{
INSTRUMENTER(NULL, "void FromOctets(Octets& y1, const Octets& y)");
y1 = y;
}
//==============================================================================
// ToOctets
//==============================================================================
_Base_Function Octets ToOctets( int i )
{
INSTRUMENTER(NULL, "Octets ToOctets(int i)");
return Octets( (pcVoid)&i, sizeof(int) );
}
_Base_Function Octets ToOctets( long i )
{
INSTRUMENTER(NULL, "Octets ToOctets(long i)");
return Octets( (pcVoid)&i, sizeof(long) );
}
_Base_Function Octets ToOctets( short i )
{
INSTRUMENTER(NULL, "Octets ToOctets(short i)");
return Octets( (pcVoid)&i, sizeof(short) );
}
_Base_Function Octets ToOctets( double f )
{
INSTRUMENTER(NULL, "Octets ToOctets(double f)");
return Octets( (pcVoid)&f, sizeof(double) );
}
_Base_Function Octets ToOctets( bool b )
{
INSTRUMENTER(NULL, "Octets ToOctets(bool b)");
String s = b ? "O" : "N";
return Octets( (pcVoid)(pcTChar)s, (s.length()+1)*sizeof(TChar) );
}
_Base_Function Octets ToOctets( const String& s )
{
INSTRUMENTER(NULL, "Octets ToOctets(const String& s)");
return Octets( (pcVoid)(pcTChar)s, (s.length()+1)*sizeof(TChar) );
}
_Base_Function Octets ToOctets( const GroupeDateHeure& gdh )
{
INSTRUMENTER(NULL, "Octets ToOctets(const GroupeDateHeure& gdh)");
String s = ToString( gdh );
return Octets( (pcVoid)(pcTChar)s, (s.length()+1)*sizeof(TChar) );
}
_Base_Function Octets ToOctets( const Octets& y )
{
INSTRUMENTER(NULL, "Octets ToOctets(const Octets& y)");
return y;
} |
Partager