DMelt:IO/Advanced IO

From HandWiki

Input/output in C++

You will need CBook [1] package if you want:

  • Create a file with all jhplot data containers using a C++ program. This file is written using Googl's Protocol Buffers file which can be understood by the PFile Java class
  • Create a data record which can be loaded into a Java program.

PFile class writes and reads all jhplot objects using a protocol buffers template file which is located in the directory "macros/system/HRecord.proto". This file was used to generate Java and C++ code as:

protoc --java_out=src               HRecord.proto
protoc --cpp_out=CBook/src/HRecord  HRecord.proto

C++ header file is located in the CBook package, while the corresponding Java class located in package. The PFile Java class is directly based on

Try to generate a file with the extension pbu from C++ program and read it using DataMelt. Go to the directory "CBook/doc/example_pbook" compile and run it. It creates a protocol buffers file with several histograms. Then use the Jython scripts located in this directory and run it using DataMelt.

In fact, you can do much more than this. You can write an arbitrary data structure in a C++ and read it using Java. Look at the directory "doc/example_epbook" to get an idea.