Houge
Member
|
"File" and "File.get<...>"
Hi to all!
Please can you help me with the following:
If i create File (to send it for example from server to client) and want to write into it Int, i use f.writeMem().putInt() or f.writeMem().putUInt(), but if i need something more than 2^32 as unsigned long long int how can i put 8-Byte integer and read it from file correctly?
|
|
05-15-2012 05:35 PM |
|
TBJokers
Member
|
RE: "File" and "File.get<...>"
Enum ClientServerCommands
{
IWantInt,
};
f.writeMem().putbyte(IWantInt).putInt(Int);
and recieving code,
Int Myint;
Myint=f.getInt();
Man, it's always that semicolon...
|
|
05-15-2012 05:53 PM |
|
Houge
Member
|
RE: "File" and "File.get<...>"
(05-15-2012 05:53 PM)TBJokers Wrote: Enum ClientServerCommands
{
IWantInt,
};
f.writeMem().putbyte(IWantInt).putInt(Int);
and recieving code,
Int Myint;
Myint=f.getInt();
That's great, but Int is 4-Byte integer and i need to put and to get 8-Byte integer
|
|
05-15-2012 05:59 PM |
|
PsychoBoy
Member
|
RE: "File" and "File.get<...>"
Code:
//Put
File f; f.writeMem();
U64 put = 1234;
f.put((CPtr)&put, sizeof(put));
//Get
U64 get = 0;
f.pos(0);
f.get((Ptr)&get, sizeof(get));
|
|
05-16-2012 03:27 AM |
|
Houge
Member
|
RE: "File" and "File.get<...>"
As i understand, to simplify the process we can add to File.h the following
File& putU64 (U64 u64) {T<<u64; return T;} U64 getU64 () {U64 u64; T>>u64; return u64;} // write/read Unsigned LONG LONG
and you'll be able to access it by writing f.putU64() and f.getU64() (i checked, it works)
BUT there is HUGE "BUT" and it is ... if we are able to edit Esenthel's header files
|
|
05-16-2012 07:41 AM |
|
Esenthel
Administrator
|
RE: "File" and "File.get<...>"
this particular editing of a header will not cause any issue,
but generally you should never do it, as it may cause many issues sometimes impossible to debug.
as aceio pointed out, easy way is to use for File f; U64 u; code: f<<u;
|
|
05-16-2012 11:27 AM |
|