L
Larry
Hi,
I would need to convert the following class. It basically converts a
numebr into a binary char 4 bytes long.
#include <sstream>
class hexPack
{
public:
hexPack(int value) : m_value(value) { }
friend std:
stream& operator<<(std:
stream& os, const hexPack& pack)
{
return os.put((pack.m_value >> 24) & 0xFF).put((pack.m_value >> 16) &
0xFF).put((pack.m_value >> 8) & 0xFF).put(pack.m_value & 0xFF);
}
private:
unsigned m_value;
};
I am using it to save a number into a preference file:
// Write Packed Data //
//
{
std::stringstream k;
std:
fstream hfile;
hfile.open(szPrefFile, std::ios:
ut|std::ios::binary);
if(hfile.bad())
return -1;
k << hexPack(20); // Top
k << hexPack(25); // Left
k << hexPack(650); // Width
k << hexPack(450); // Height
hfile.write(k.str().c_str(), 4*4);
hfile.close();
}
///////////////////////
Now, since I didn't write that class I would need to figure out a way to
code the viceversa class
thanks
I would need to convert the following class. It basically converts a
numebr into a binary char 4 bytes long.
#include <sstream>
class hexPack
{
public:
hexPack(int value) : m_value(value) { }
friend std:
{
return os.put((pack.m_value >> 24) & 0xFF).put((pack.m_value >> 16) &
0xFF).put((pack.m_value >> 8) & 0xFF).put(pack.m_value & 0xFF);
}
private:
unsigned m_value;
};
I am using it to save a number into a preference file:
// Write Packed Data //
//
{
std::stringstream k;
std:
hfile.open(szPrefFile, std::ios:
if(hfile.bad())
return -1;
k << hexPack(20); // Top
k << hexPack(25); // Left
k << hexPack(650); // Width
k << hexPack(450); // Height
hfile.write(k.str().c_str(), 4*4);
hfile.close();
}
///////////////////////
Now, since I didn't write that class I would need to figure out a way to
code the viceversa class
thanks