wxArchive v1.0 Released!

Do you like to promote your wxWidgets based application or component!? Post it here and let's see what the critics have to say. Also, if you found that ONE wx component the world needs to know about, put it here for future reference.
Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

wxArchive v1.0 Released!

Post by Jorg » Sun Jan 22, 2006 8:55 pm

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
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

Vexator
I live to help wx-kind
I live to help wx-kind
Posts: 187
Joined: Sun Jan 30, 2005 2:50 pm
Location: Heidelberg, Germany

Post by Vexator » Mon Jan 23, 2006 8:09 am

handy for undo/redo mechanisms
so how whould i, for example, realize this with wxArchive?
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

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Mon Jan 23, 2006 10:07 am

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
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Post by priyank_bolia » Mon Jan 23, 2006 1:38 pm

Great Work! Does it is compatible with other wxArchive* classes.

Vexator
I live to help wx-kind
I live to help wx-kind
Posts: 187
Joined: Sun Jan 30, 2005 2:50 pm
Location: Heidelberg, Germany

Post by Vexator » Mon Jan 23, 2006 1:55 pm

mh this sounds really interesting. exactly what i need for my apps :) great work! will you eventually supply some examples on how to work with wxarchive?
Windows 7 Pro
Visual Studio 2010
wxWidgets 2.9.3

priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Post by priyank_bolia » Mon Jan 23, 2006 2:21 pm

I guess the code is very well documentated, have a look in that for usage.

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Mon Jan 23, 2006 5:46 pm

Thanks priyank!
Any suggestions are always welcome ofcourse.

What do you mean with this?
Great Work! Does it is compatible with other wxArchive* classes
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Post by priyank_bolia » Tue Jan 24, 2006 4:55 am

Jorg wrote:Thanks priyank!
Any suggestions are always welcome ofcourse.

What do you mean with this?
Great Work! Does it is compatible with other wxArchive* classes
- Jorgen

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.

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Tue Jan 24, 2006 7:48 am

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
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

toxicBunny
Super wx Problem Solver
Super wx Problem Solver
Posts: 424
Joined: Tue Jul 12, 2005 8:44 pm
Location: Alabama, USA

Post by toxicBunny » Wed Jan 25, 2006 4:31 pm

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.

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);
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
wxMSW 2.6.2, VS 2002, 2003 and 2005, Code::Blocks and mingw, Windows XP Pro

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Thu Jan 26, 2006 8:11 am

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
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

toxicBunny
Super wx Problem Solver
Super wx Problem Solver
Posts: 424
Joined: Tue Jul 12, 2005 8:44 pm
Location: Alabama, USA

Post by toxicBunny » Thu Jan 26, 2006 2:44 pm

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
wxMSW 2.6.2, VS 2002, 2003 and 2005, Code::Blocks and mingw, Windows XP Pro

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Thu Jan 26, 2006 2:55 pm

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
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Thu Jan 26, 2006 7:30 pm

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
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

User avatar
Ryan Norton
Moderator
Moderator
Posts: 1319
Joined: Mon Aug 30, 2004 6:01 pm

Post by Ryan Norton » Tue Dec 12, 2006 1:08 pm

Neat. Maybe wxSerialize(able) to avoid duplication?
[Mostly retired moderator, still check in to clean up some stuff]

Post Reply