1 / 21

The BinX API

The BinX API. eDIKT project team May 2003 Ted Wen tedwen@nesc.ac.uk Robert Carroll robertc@nesc.ac.uk. Contents. Format of the BinX document The binary data file BinX data types Format of the dataBinX document BinX library API. A BinX document. Root element.

tirza
Download Presentation

The BinX API

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The BinX API eDIKT project team May 2003 Ted Wen tedwen@nesc.ac.uk Robert Carroll robertc@nesc.ac.uk

  2. Contents • Format of the BinX document • The binary data file • BinX data types • Format of the dataBinX document • BinX library API

  3. A BinX document Root element • <dataset byteOrder=“bigEndian”> • <definitions> • <defineType typeName=“myTyp”> • <arrayFixed> • <character-8/> • <dim indexTo=“9”/> • </arrayFixed> • </defineType> • </definitions> • <filesrc=“myfile.bin”> • <useType typeName=“myTyp”/> • <integer-32 varName=“X” /> • </file> • </dataset> Data class section Abstract data type Data instance section

  4. The BinX document <?xml version=“1.0”?> <dataset xmlns=“http://schema.nesc.ac.uk/binx”> <file src=“binary.bin” byteOrder=“littleEndian”> <short-16/> <integer-32/> <ieeeDouble-64/> </file> </dataset>

  5. Another BinX document … … <definitions> <defineType typeName="array"> <arrayFixed> <byte-8/> <dim indexTo="15"/> </arrayFixed> </defineType > </definitions> <file src=“binary.bin” byteOrder=“littleEndian”> <useType typeName=“array”/> </dataset>

  6. The binary data file DataBinX <short-16>100</short-16> <integer-32>10000</integer-32> Binary Data 1100100 10011100010000 Hexadecimal 00 64 00 00 27 10

  7. BinX Data Types

  8. <byte-8> <character-8> <short-16> <integer-32> <longInteger-64> <unsignedShort-16> <unsignedInteger-32> <unsignedLongInteger-64> <ieeeFloat-32> <ieeeDouble-64> <ieeeExtended-80> <ieeeQuadruple-128> BxByte8 BxCharacter8 BxShort16 BxInteger32 BxLong64 BxUnsignedShort16 BxUnsignedInteger32 BxUnsignedLong64 BxFloat32 BxDouble64 BxExtended80 BxQuadruple128 Primitive data types

  9. <struct> <union> <arrayFixed> <arrayVariable> <arrayStreamed> BxDataset BxUnion BxArrayFixed BxArrayVariable BxArrayStreamed Complex data types

  10. User type definition <defineType typeName=“myStruct”> <struct> </struct> </defineType> <defineType typeName=“myArray”> <arrayFixed> </arrayFixed> </defineType> <defineType typeName=“myUnion”> <union> </union> </defineType>

  11. DataBinX Document

  12. Primate types in DataBinX <?xml version=“1.0”?> <dataset xmlns:bx=“http://schema.nesc.ac.uk/binx”> <file> <short-16>32</short-16> <integer-32>100</integer-32> <ieeeDouble-64>50.5</ieeeDouble-64> </file> </dataset>

  13. Struct in DataBinX … … <struct> <unicodeCharacter-16>0</unicodeCharacter-16> <longInteger-64>1</longInteger-64> <unicodeCharacter-16>2</unicodeCharacter-16> <unsignedInteger-32>3</unsignedInteger-32> <ieeeDouble-64>4</ieeeDouble-64> <short-16>5</short-16> <longInteger-64>6</longInteger-64> <ieeeExtended-80>7</ieeeExtended-80> <unicodeCharacter-32>8</unicodeCharacter-32> <ieeeExtended-80>9</ieeeExtended-80> </struct>

  14. Array in DataBinX <arraydata> <dim index=“1” name=“i”> <dim index=“0” name=“j”> <byte-8>1</byte-8></dim> <dim index=“0” name=“j”> <byte-8>2</byte-8></dim> </dim> <dim index=“1” name=“i”> <dim index=“0” name=“j”> <byte-8>3</byte-8></dim> <dim index=“0” name=“j”> <byte-8>4</byte-8></dim> </dim> </arraydata> <arrayFixed> <byte-8/> <dim name=“j” indexTo=“1”/> <dim name=“i” indexTo=“1”/> </arrayFixed>

  15. BinX Library API

  16. Parsing a BinX document BxBinxFile* pReader = new BxBinxFile(); If (pReader->parse(“mybinx.xml”)) { BxDataset* pDataset = pReader->getDataset(); }

  17. Output from the library • DataBinX The combined data and BinX document • SchemaBinX • Binary data stream DataBinX = SchemaBinX + Binary data

  18. Creating BinX document BxBinxFileWriter* pWriter=new BxBinxFileWriter(); • Create a object to write out the document BxDataset* pData = new BxDataset(); • Create a new dataset (in memory BinX document) BxShort16* i16 = new BxShort16(100); pData->addDataObject(i16); • Add data to the dataset

  19. Creating BinX document BxBinaryFile* pbf = new BxBinaryFile(); • Create a new binary file pbf->setDatasetPointer(pData); • Create a link to the BinX document pWriter->setBinaryFilePtr(pbf); pWriter->save("TestDataset.xml"); • Save the BinX document

  20. Merge binary data BxBinxFileReader * pFile1 = new BxBinxFileReader(“file1.xml”); BxBinxFileReader * pFile2 = new BxBinxFileReader(“file2.xml”); BxDataset * pDataset1 = pFile1->getDataset(); BxDataset * pDataset2 = pFile2->getDataset(); BxArray * pArray1 = pDataset1->getArray(0); BxArray * pArray2 = pDataset2->getArray(0); BxDataObject * pData1 = pArray1->getNext(); BxDataObject * pData2 = pArray2->getNext(); FILE * fo = fopen(“output.dat”,”wb”); pData1->toStreamBinary(fo); pData2->toStreamBinary(fo);

  21. Summary • One BinX document can describe many binary files • Generate BinX document from code • Easy to use interfaces • Flexible

More Related