About Store Forum Documentation Contact



Post Reply 
"File" and "File.get<...>"
Author Message
Houge Offline
Member

Post: #1
"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
Visit this user's website Find all posts by this user Quote this message in a reply
TBJokers Offline
Member

Post: #2
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
Visit this user's website Find all posts by this user Quote this message in a reply
Houge Offline
Member

Post: #3
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
Visit this user's website Find all posts by this user Quote this message in a reply
PsychoBoy Offline
Member

Post: #4
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
Visit this user's website Find all posts by this user Quote this message in a reply
Houge Offline
Member

Post: #5
RE: "File" and "File.get<...>"

Thanks a lot! Now i get it smile
05-16-2012 04:17 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Houge Offline
Member

Post: #6
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 smile
05-16-2012 07:41 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #7
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
Find all posts by this user Quote this message in a reply
Post Reply