Dirk wrote:
I expect, that these are a few places where you have to change the
encoding. I simply copy the bytes from the file into a buffer and later
"cast" this to the specific record. You can not simply reverse the order
of the buffer. You have to do it for each POD and each non trivial type.
One way is to have the structure members be a class for a back-to-front
byte order rather than a simple int.
Here are a couple of classes that I used for a similar case - these just
sit in the bigger data structure in place of a "normal" unsigned member
and on access appear to be a regular unsigned int/short.
32 bit case, and adjusting the 24 bit case to swap byte order the other
way left as an exercise to the reader...
class unsigned24rev
{
public:
inline const unsigned24rev &operator=(unsigned long Data)
{
lo=(unsigned char)Data;
mid=(unsigned char)(Data>>8);
hi=(unsigned char)(Data>>16);
return *this;
}
inline operator unsigned long(void) const { return lo | (((unsigned
long)mid)<<8) | (((unsigned long)hi)<<16); }
private:
unsigned char hi;
unsigned char mid;
unsigned char lo;
};
class unsigned16rev
{
public:
inline const unsigned16rev &operator=(unsigned short Data)
{
revData=(unsigned short)((Data<<8) | (Data >>8));
return *this;
}
inline operator unsigned short(void) const { return (unsigned
short)((revData<<8) | (revData>>8)); }
private:
unsigned short revData;
};
--
Stephen Lee <[EMAIL PROTECTED]>
Software Engineer, Vision Group - Pro-Measure Leader
Wilcox Associates Inc. (U.K.)
_______________________________________________
vss2svn-users mailing list
Project homepage:
http://www.pumacode.org/projects/vss2svn/
Subscribe/Unsubscribe/Admin:
http://lists.pumacode.org/mailman/listinfo/vss2svn-users-lists.pumacode.org
Mailing list web interface (with searchable archives):
http://dir.gmane.org/gmane.comp.version-control.subversion.vss2svn.user