[Nexus] XML format--A way to serialize binary?

tieman tieman at aps.anl.gov
Fri Dec 8 17:17:11 GMT 2006


Peter,

What I have may not be quite what people think of when they talk C++ 
wrapper to nexus...

Enclosed are the headers and a stupid little document I wrote about how 
the library works--don't let the date on the document scare you, it's 
still very relevant!

The short form synopsis:

Napi routines are mapped almost directly to C++ methods in a class 
called nexusapi (nexusapi.h)

An interface class called NexusBoxClass privately inherits nexusapi to 
handle all the direct file access.  NexusBoxClass then provides 
interface methods to the data (nexusbox.h)  Groups, Fields and 
Attributes in Napi are each instantiated as their own classes.  The 
NexusBoxClass acts as a container (hence "box") to hold all the Group, 
Field and Attribute classes.  The Group, Field and Attribute classes are 
arranged in a memory tree that mimics the directory structure of the 
file.  Routines exist to query paths to the data--I call them "index" in 
the header.  An index would be an ascii readable path to the data and 
serves as the "handle" to the data.

Some utility methods are thrown in for good measure.  It's possible to 
read the entire file into the memory tree, or, to save memory, large 
multidimensional data would be read in as "index only" until you 
actually need to access the data.  It's also possible to supply a 
"template file" (described better in NexusBox.doc) that configures how a 
file will be written and allows the library to automagically find some 
of the data it needs to write to the file.  This is akin to the XML data 
definitions and probably should be integrated with them somehow (I've 
been punting this one for a while now!) to provide file validation at 
write time.

Currently, there is no support for linking within a file as I haven't 
had a need for this feature yet.  I'm currently building for Nexus3.0 
and have it all working on Windows.  I need to build it for linux and 
solaris yet, but don't anticipate any problems there.  There is an 
accompanying C wrapper which I've used to call this library from IDL and 
Java plus it's likely python bindings are in the near future...

If this is of interest to you, or anyone else, let me know.  I'll need 
to clean up a few things and add the appropriate contract numbers and 
typical disclaimers, but there's no real barrier to others making use of 
this code--well, other than my general laziness anyway :)

Brian

Peterson, Peter F. wrote:
> Brian,
>
> I have been interested in producing a C++ wrapper around the napi for
> some time. Would you be willing to share this code with NeXus and
> possibly incorporate it into a future release?
>
> P^2
>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: nexusapi.h
Url: http://lists.nexusformat.org/pipermail/nexus/attachments/20061208/25922ae3/attachment-0002.h 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: nexusbox.h
Url: http://lists.nexusformat.org/pipermail/nexus/attachments/20061208/25922ae3/attachment-0003.h 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HDFBox.doc
Type: application/octet-stream
Size: 26624 bytes
Desc: not available
Url : http://lists.nexusformat.org/pipermail/nexus/attachments/20061208/25922ae3/attachment-0001.obj 


More information about the NeXus mailing list