Click here to Skip to main content
15,885,216 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Hooking a running process 's Innermost dll's function Pin
Santhosh G_3-Aug-13 23:30
Santhosh G_3-Aug-13 23:30 
QuestionSaving console output to .txt/.html file using C++/VC++ Pin
pk jain31-Jul-13 3:30
pk jain31-Jul-13 3:30 
AnswerRe: Saving console output to .txt/.html file using C++/VC++ Pin
Richard MacCutchan31-Jul-13 3:58
mveRichard MacCutchan31-Jul-13 3:58 
AnswerRe: Saving console output to .txt/.html file using C++/VC++ Pin
pasztorpisti31-Jul-13 4:25
pasztorpisti31-Jul-13 4:25 
QuestionCString to float conversion Pin
tagopi31-Jul-13 0:32
tagopi31-Jul-13 0:32 
AnswerRe: CString to float conversion Pin
pasztorpisti31-Jul-13 0:49
pasztorpisti31-Jul-13 0:49 
QuestionCan we Directly write a Class Object with vectors as member into FILE ? Pin
002comp31-Jul-13 0:26
002comp31-Jul-13 0:26 
AnswerRe: Can we Directly write a Class Object with vectors as member into FILE ? Pin
pasztorpisti31-Jul-13 0:38
pasztorpisti31-Jul-13 0:38 
The vector contains just pointers to the actual data stored by the vector. If you write out your struct then you write out just some pointers that will probably be invalid the next time you want to load your data. The serialization method you use is the 0th solution everyone starts with and it works just with primitive types - as soon as you start using complex types like a vector you have to consider using a more sophisticated serialization method. Unfortunately serializing correctly needs more work and a serialization framework. I'm using my own reflection-like framework that is similar to AutoSerial[^] but is more lightweight. If you have reflection info / typeinfo then you can easily write different kind of serializers (binary, xml, ...) that will automatically work with all of your structs and types that have typeinfo attached. In my system I register every serializable member of a struct manually but from that point the struct is serializable as xml, binary, and so on depending on the kind of serialzers I have written. Runtime typeinfo has a bit of perofrmance penalty that matters quite rarely. Some other serializer frameworks do the dirty job with templates and bind to serializable data at compile time with better performance and the third type of serializers generate serializer classes/code for you by parsing your source code. In general I don't like code generators. Another popular serialization framework to check out is boost::serialzation[^].

A serialization framework can have additional benefits compared to a single-shot file-write: It can handle endianness problems and struct member alignment too if you compile the same serializer code on two different machines (in case of a server-client program that serializes data to send over network, or if you transfer the serialized data file to a completely different machine that has different endiannes/compiler struct member alignment).

modified 31-Jul-13 6:54am.

GeneralRe: Can we Directly write a Class Object with vectors as member into FILE ? Pin
002comp31-Jul-13 1:34
002comp31-Jul-13 1:34 
GeneralRe: Can we Directly write a Class Object with vectors as member into FILE ? Pin
pasztorpisti31-Jul-13 1:50
pasztorpisti31-Jul-13 1:50 
GeneralRe: Can we Directly write a Class Object with vectors as member into FILE ? Pin
002comp31-Jul-13 2:23
002comp31-Jul-13 2:23 
GeneralRe: Can we Directly write a Class Object with vectors as member into FILE ? Pin
pasztorpisti31-Jul-13 4:03
pasztorpisti31-Jul-13 4:03 
GeneralRe: Can we Directly write a Class Object with vectors as member into FILE ? Pin
002comp31-Jul-13 18:11
002comp31-Jul-13 18:11 
GeneralRe: Can we Directly write a Class Object with vectors as member into FILE ? Pin
pasztorpisti31-Jul-13 22:37
pasztorpisti31-Jul-13 22:37 
QuestionOrder of Overlapped Operations Pin
Richard Andrew x6430-Jul-13 21:58
professionalRichard Andrew x6430-Jul-13 21:58 
AnswerRe: Order of Overlapped Operations Pin
Randor 30-Jul-13 22:52
professional Randor 30-Jul-13 22:52 
GeneralRe: Order of Overlapped Operations Pin
Richard Andrew x6430-Jul-13 23:01
professionalRichard Andrew x6430-Jul-13 23:01 
AnswerRe: Order of Overlapped Operations Pin
pasztorpisti30-Jul-13 23:35
pasztorpisti30-Jul-13 23:35 
GeneralRe: Order of Overlapped Operations Pin
Richard Andrew x6431-Jul-13 7:14
professionalRichard Andrew x6431-Jul-13 7:14 
Questioncreating empty file Pin
sarfaraznawaz29-Jul-13 22:32
sarfaraznawaz29-Jul-13 22:32 
AnswerRe: creating empty file Pin
pasztorpisti29-Jul-13 22:37
pasztorpisti29-Jul-13 22:37 
GeneralRe: creating empty file Pin
sarfaraznawaz29-Jul-13 23:21
sarfaraznawaz29-Jul-13 23:21 
GeneralRe: creating empty file Pin
pasztorpisti29-Jul-13 23:27
pasztorpisti29-Jul-13 23:27 
GeneralRe: creating empty file Pin
sarfaraznawaz29-Jul-13 23:40
sarfaraznawaz29-Jul-13 23:40 
GeneralRe: creating empty file Pin
pasztorpisti30-Jul-13 0:12
pasztorpisti30-Jul-13 0:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.