From: Peter Sippel <[email protected]> - 11 Dec 1998
> c4_Storage myStorage( myFile, TRUE ); c4_View emptyView = > myStorage.GetAs(myStorage.Description()); > > c4_View myOtherView = emptyView; <-- Access Violation
That is to be expected. Storage descriptions are not view descriptions. Storage descriptions can contain any number of views, including zero. View descriptions must contain exactly one.
Your approach will fail for empty files and for files with more than one view (well, it *should* fail - I haven't checked this).
> Other calls, i.e. property access on empty (sub)views, will crash as > well...
Yes, this is a known problem: you cannot store a view with no properties. Once way to avoid this, is something like:
if (view.NumProperties() > 0) storage.Store("view", view); > As long as I can't access empty views like views that have rows, I > can't use Metakit properly. I find, that it's quite normal to make it > possible to the user to clear his files or create new ones.
Also note that you need not use GetAs if the view structure is to be the same as on file, in fact you are only slowing it down by asking for a restructuring check:
c4_String desc = storage.Description(); c4_View view; if (!desc.IsEmpty()) view = storage.View("view"); -- JC