Simple example to create OME-XML from C++?

Dear Developers,

I’d like to create an ome xml string in C++, based on a set of key-value properties that describe a microscope acquisition. I do not care about the actual xml parser / creator / validator, only about the final, correct representation as a std::string that I can store.

I’ve browsed the ome-files documentation but most topics focus on creating a full tiff file including the xml. Is it possible to use a subset of ome-files just to create a standalone xml? Which repositories are required? And is there an example for the setters that create the xml?

I was hoping for something like:

ome::xml vXML("2016-06");
vXML.setDescription("My first OME XML");
vXML.setExperimentID("SomeID");
...
const std::string vOMEXMLString = vXML.getString();

I found by chance this documentation that looks promising. But it seems to be from version 0.5.0, its unclear to which source repository it belongs, and I can not find the mentioned header Annotation.h anywhere in the gitlab repositories. Is this documentation deprecated? Are there updated docs?

Am I at all on the right track here? Could you help me find a start? Then I’m sure I can take it from there.

All the best, Mario

Hi Mario,

The current documentation for OME-XML is linked to from here. The class you mentioned is in the class list which you might have found hard to find, because all of these classes are generated from the OME Data Model XML schema. The equivalent documentation links for OME Files are found here.

I don’t think what you are asking for has ever been fully documented for either the C++ or Java codebases. The best I can point you to is the OME Files C++ metadata examples section of the OME Files tutorial page. The metadata-io example includes modifications to the MetadataStore to add a new Image. To create one from scratch yourself, you would need to copy that logic. Also, look at copying how OME Files sets up a new empty store from scratch in MetadataTools using the various fill (populate in the equivalent Java code) and create methods. Arguably, much of this should be both in dedicated examples, and also in the OME-XML component rather than the OME Files component, but this was reimplemented to work exactly like the Java implementation for strict compatibility.

I hope that’s enough to get you started. Please don’t hesitate to ask if you have any questions!

Kind regards,
Roger