wxArchive v1.0 Released!
wxArchive v1.0 Released!
Hi all,
I released wxArchive v1.0 officially to the public. What is wxArchive? Well I found the serialization support in wxWidgets too limiting, so I wrote my own class. Basically this class goes back 4+ years so it is tested thoroughly and proved well in many occasions, but it was STL only. I also improved it a lot and created lots of API documentation for it. I know there is boost::serialize, but often your class does not need to write it's complete state and in-depth data to a file, but only a few data members, and relations that are more complex and need to be resolved at run-time. This is where wxArchive kicks in. Handy for undo/redo mechanisms, cache files, settings files, or complete project data files on disk.
Here are some highlights:
- This class provides serialization for wxWidgets with the following features:
- wxInputStream / wxOutputStream serializing (so practically to all wxWidgets streams)
- With versioning to check what version the stream has
- With header check to make sure it's your stream
- Fully unicode compliant
- Streams are binary compatible on linux and windows (interchangable)
- EnterObject() / LeaveObject() can be used to mark boundaries and auto skipping
- Older streams with less info can still be read by newer applications without any significant changes
- Newer streams can be read by older applications without problems
- All basic types are supported: wxString, wxArrayString, int, char, boolean, int8, int16, int32, double, etc
- Strings are written in UNICODE always, even serializing between unicode / non-unicode builds will work
CHANGELOG:
----------
v1.0:
- UNICODE support added (fixed bug: 0071)
- Fixed some compile errors on wx2.7
- Added better structure in the source
INFO:
-----
Check the site for dowload and more info: http://wastebucket.solidsteel.nl
Online documentation: http://www.xs4all.nl/~jorgb/components/archive/help/
- Jorgen
I released wxArchive v1.0 officially to the public. What is wxArchive? Well I found the serialization support in wxWidgets too limiting, so I wrote my own class. Basically this class goes back 4+ years so it is tested thoroughly and proved well in many occasions, but it was STL only. I also improved it a lot and created lots of API documentation for it. I know there is boost::serialize, but often your class does not need to write it's complete state and in-depth data to a file, but only a few data members, and relations that are more complex and need to be resolved at run-time. This is where wxArchive kicks in. Handy for undo/redo mechanisms, cache files, settings files, or complete project data files on disk.
Here are some highlights:
- This class provides serialization for wxWidgets with the following features:
- wxInputStream / wxOutputStream serializing (so practically to all wxWidgets streams)
- With versioning to check what version the stream has
- With header check to make sure it's your stream
- Fully unicode compliant
- Streams are binary compatible on linux and windows (interchangable)
- EnterObject() / LeaveObject() can be used to mark boundaries and auto skipping
- Older streams with less info can still be read by newer applications without any significant changes
- Newer streams can be read by older applications without problems
- All basic types are supported: wxString, wxArrayString, int, char, boolean, int8, int16, int32, double, etc
- Strings are written in UNICODE always, even serializing between unicode / non-unicode builds will work
CHANGELOG:
----------
v1.0:
- UNICODE support added (fixed bug: 0071)
- Fixed some compile errors on wx2.7
- Added better structure in the source
INFO:
-----
Check the site for dowload and more info: http://wastebucket.solidsteel.nl
Online documentation: http://www.xs4all.nl/~jorgb/components/archive/help/
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
-
- I live to help wx-kind
- Posts: 187
- Joined: Sun Jan 30, 2005 2:50 pm
- Location: Heidelberg, Germany
so how whould i, for example, realize this with wxArchive?handy for undo/redo mechanisms
Last edited by Vexator on Mon Jan 23, 2006 1:53 pm, edited 1 time in total.
Windows 7 Pro
Visual Studio 2010
wxWidgets 2.9.3
Visual Studio 2010
wxWidgets 2.9.3
Hi Vexator.
For example when you have a complex object framework, you serialize the contents to a wxArchive e.g. through a wxStringInputStream / wxStringOutputStream. You delete the object that the user "deleted". When wanting to undo, you serialize back the state of the model of that class into the object model and notify the GUI.
Other techniques include that the "delete" is not actually used but all references are removed from the object and replaced when the delete action is undone. This method is cleaner.
With regards,
- Jorgen
For example when you have a complex object framework, you serialize the contents to a wxArchive e.g. through a wxStringInputStream / wxStringOutputStream. You delete the object that the user "deleted". When wanting to undo, you serialize back the state of the model of that class into the object model and notify the GUI.
Other techniques include that the "delete" is not actually used but all references are removed from the object and replaced when the delete action is undone. This method is cleaner.
With regards,
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
-
- wxWorld Domination!
- Posts: 1339
- Joined: Wed Aug 03, 2005 8:10 am
- Location: BANGALORE, INDIA
- Contact:
-
- wxWorld Domination!
- Posts: 1339
- Joined: Wed Aug 03, 2005 8:10 am
- Location: BANGALORE, INDIA
- Contact:
Thanks priyank!
Any suggestions are always welcome ofcourse.
What do you mean with this?
Any suggestions are always welcome ofcourse.
What do you mean with this?
- JorgenGreat Work! Does it is compatible with other wxArchive* classes
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
-
- wxWorld Domination!
- Posts: 1339
- Joined: Wed Aug 03, 2005 8:10 am
- Location: BANGALORE, INDIA
- Contact:
Jorg wrote:Thanks priyank!
Any suggestions are always welcome ofcourse.
What do you mean with this?
- JorgenGreat Work! Does it is compatible with other wxArchive* classes
I know what your wxArchive class is, as Its what we have in MFC. But in the wxWidgets documentation is see there are some archive stream classes also, starting with "wxArchive*". I don't have much idea what that does. But I just want to ask that, is your class some extension to them, or is independent of them.
Also it would be great you can have some compression and encryption in that archive.
Maybe this name is unluckily chosen, but I think the other names are related to archive manipulation for e.g. zip files or rar files. I deliberately chose wxArchive to make the bridge between CArchive and wxArchive easier.
You can however send the serialization to a wxZLibOutputStream. The data will be both compressed and serialized. So when serializing back, simply open the file, and redirect the file -> zlib -> wxArchive and you get the data back.
- Jorgen
You can however send the serialization to a wxZLibOutputStream. The data will be both compressed and serialized. So when serializing back, simply open the file, and redirect the file -> zlib -> wxArchive and you get the data back.
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
-
- Super wx Problem Solver
- Posts: 424
- Joined: Tue Jul 12, 2005 8:44 pm
- Location: Alabama, USA
Are there any functions in the wxArchive class for reading and writing arbitrary amounts data? I noticed the following function in the header file, but the implementation appears to be missing.
I'm mainly interested because I am trying to serialize a class that contains a wxImage object. I have been using wxImage::GetData() to retrieve the data buffer when storing the class in a database. However, I can't find an easy way to read and write this to the archive without the function mentioned above. I could attempt to implement it, but I thought I would ask first to see if you had already done it.
-Scott
Code: Select all
/** Saves an arbitrary amount of bytes to the stream. It writes a header type first, and after that the count
to be saved and the bytes from the void ptr. This means when the record is read back when it is not expected,
an error occurs and the program can terminate gracefully because no bogus values are read back. True is returned
when the value is saved properly, and false when it's not.
No conversion takes place when writing the buffer. It is written as a sequence of bytes to the stream.
*/
bool Write(void *ptr, size_t count);
-Scott
wxMSW 2.6.2, VS 2002, 2003 and 2005, Code::Blocks and mingw, Windows XP Pro
I noticed you filed a bug for this.. Thanks! It should be there, but it must have sneaked off my todo list. I will implement this for you hoppefully tonight, if I do not succeed, at least this weekend.
The arbitrary data Write is simple, but I am wondering how to inmplement the read side. One way is to return a pointer the user must delete themselves, but a more solid method is creating a wxArchiveData class that you can pass. Something like;
wxArchiveData my_data;
my_data.SetData(void *ptr, size_t size);
This will copy the pointer for size bytes. Ofcourse it will own the memory. Then;
stream << my_data;
And to read back;
stream >> my_data;
And to use it;
my_data.Len(); // will produce the size of bytes read back
my_data.GetData(); // will produce a void * to the data
When my_data runs out of scope (or when new data is assigned to it) the old data is automatically cleaned up.
Is this an acceptable solution? I will not provide any conversion on the data, so it's not guaranteed that the data being written is L2B endian safe when sharing between platforms...
Regards,
- Jorgen
The arbitrary data Write is simple, but I am wondering how to inmplement the read side. One way is to return a pointer the user must delete themselves, but a more solid method is creating a wxArchiveData class that you can pass. Something like;
wxArchiveData my_data;
my_data.SetData(void *ptr, size_t size);
This will copy the pointer for size bytes. Ofcourse it will own the memory. Then;
stream << my_data;
And to read back;
stream >> my_data;
And to use it;
my_data.Len(); // will produce the size of bytes read back
my_data.GetData(); // will produce a void * to the data
When my_data runs out of scope (or when new data is assigned to it) the old data is automatically cleaned up.
Is this an acceptable solution? I will not provide any conversion on the data, so it's not guaranteed that the data being written is L2B endian safe when sharing between platforms...
Regards,
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
-
- Super wx Problem Solver
- Posts: 424
- Joined: Tue Jul 12, 2005 8:44 pm
- Location: Alabama, USA
Thanks Jorg. That sounds like a good solution, but could you use the wxMemoryBuffer rather than creating a new wxArchiveData class? I think it generally functions in the manner you proposed, and I already use it with the DatabaseLayer library to write the same data to a blob field in the database. It just seems that it would be easier than creating a new class...
-Scott
-Scott
wxMSW 2.6.2, VS 2002, 2003 and 2005, Code::Blocks and mingw, Windows XP Pro
Thanks I didn't knew it existed. Indeed that would make it easier. I think this feature would not take much time so I will update my site tonight probably with the latest code, and release v1.0.1 (I consider this a bugfix, so v1.1 will contain new features in the future).
- Jorgen
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Ok, new version is uploaded! I changed the online help as well, to reflect the new API.
You can download it here:
http://wastebucket.solidsteel.nl/cms/mo ... downloads/
- Jorgen
You can download it here:
http://wastebucket.solidsteel.nl/cms/mo ... downloads/
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
- Ryan Norton
- wxWorld Domination!
- Posts: 1319
- Joined: Mon Aug 30, 2004 6:01 pm