0

i have a windows app based on mfc that saves its doc using the CArchive (MFC) serialization class

i would like to load these files into my new andriod app but need some java code to understand the serialized data file format. once i pull it apart i can handle the data ok but don't really want to dissect CArchive created files myself. can anyone help, maybe a library out there somewhere?

Arun P Johny
  • 384,651
  • 66
  • 527
  • 531
steveh
  • 1,352
  • 2
  • 27
  • 41
  • Deserializing a `CArchive` heavily relies on MFC infrastructure. It uses the factory methods for creating objects defined in the `IMPLEMENT_SERIAL` macro. The `CArchive` stream itself consists of class and length information followed by the actual content. The type names are serialized in plain text for the first object of that type. MFC constructs a map of previously serialized objects and writes an index rather than the type name to the stream for subsequent objects. You can look up the details as you have the MFC source available. It is doable, but certainly messy to replicate this. – IInspectable Jan 10 '13 at 21:28
  • Correction on the comment above: The MFC class factory is implemented through `IMPLEMENT_DYNCREATE` - `IMPLEMENT_SERIAL` provides serialization support. The latter relies on the former to dynamically construct objects read from a `CArchive` stream. – IInspectable Jan 10 '13 at 21:57

1 Answers1

0

See previous answers to this question (with respect to Ruby instead of Java) - Parsing CArchive (MFC classes) files in Ruby

Unfortunately, I think that you're going to have dissect it yourself.

Community
  • 1
  • 1
GreyBeardedGeek
  • 29,460
  • 2
  • 47
  • 67
  • thanks, i did see that post and thought it sounded like a problem. maybe better i change my mfc app to export something more java friendly. but who knows, maybe someone has some code i could borrow? – steveh Jan 10 '13 at 04:00
  • If you can change the MFC app, I'd suggest using JSON as the export format. That will be particularly easy to use in your Android app. – GreyBeardedGeek Jan 10 '13 at 04:38
  • actually, it isn't that bad to read the CArchive format if you know the way it was created (which i do) and if the saved data structures are very regular (which they are) – steveh Jan 14 '13 at 08:44