The BinX API - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

The BinX API

Description:

... nesc.ac.uk/binx' file src='binary.bin' byteOrder='littleEndian' ... file src='binary.bin' byteOrder='littleEndian' useType typeName='array'/ /dataset ... – PowerPoint PPT presentation

Number of Views:10
Avg rating:3.0/5.0
Slides: 22
Provided by: Ted52
Category:
Tags: api | binx | littleendian

less

Transcript and Presenter's Notes

Title: The BinX API


1
The BinX API
  • eDIKT project team
  • May 2003
  • Ted Wen tedwen_at_nesc.ac.uk
  • Robert Carroll robertc_at_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
  • ltdataset byteOrderbigEndiangt
  • ltdefinitionsgt
  • ltdefineType typeNamemyTypgt
  • ltarrayFixedgt
  • ltcharacter-8/gt
  • ltdim indexTo9/gt
  • lt/arrayFixedgt
  • lt/defineTypegt
  • lt/definitionsgt
  • ltfile srcmyfile.bingt
  • ltuseType typeNamemyTyp/gt
  • ltinteger-32 varNameX /gt
  • lt/filegt
  • lt/datasetgt

Root element
Data class section
Abstract data type
Data instance section
4
The BinX document
  • lt?xml version1.0?gt
  • ltdataset xmlnshttp//schema.nesc.ac.uk/binxgt
  • ltfile srcbinary.bin byteOrderlittleEndiangt
  • ltshort-16/gt
  • ltinteger-32/gt
  • ltieeeDouble-64/gt
  • lt/filegt
  • lt/datasetgt

5
Another BinX document
  • ltdefinitionsgt
  • ltdefineType typeName"array"gt
  • ltarrayFixedgt
  • ltbyte-8/gt
  • ltdim indexTo"15"/gt
  • lt/arrayFixedgt
  • lt/defineType gt
  • lt/definitionsgt
  • ltfile srcbinary.bin byteOrderlittleEndiangt
  • ltuseType typeNamearray/gt
  • lt/datasetgt

6
The binary data file
Binary Data 1100100 10011100010000
Hexadecimal 00 64 00 00 27 10
  • DataBinX
  • ltshort-16gt100lt/short-16gt
  • ltinteger-32gt10000lt/integer-32gt

7
BinX Data Types
8
Primitive data types
  • ltbyte-8gt
  • ltcharacter-8gt
  • ltshort-16gt
  • ltinteger-32gt
  • ltlongInteger-64gt
  • ltunsignedShort-16gt
  • ltunsignedInteger-32gt
  • ltunsignedLongInteger-64gt
  • ltieeeFloat-32gt
  • ltieeeDouble-64gt
  • ltieeeExtended-80gt
  • ltieeeQuadruple-128gt
  • BxByte8
  • BxCharacter8
  • BxShort16
  • BxInteger32
  • BxLong64
  • BxUnsignedShort16
  • BxUnsignedInteger32
  • BxUnsignedLong64
  • BxFloat32
  • BxDouble64
  • BxExtended80
  • BxQuadruple128

9
Complex data types
  • ltstructgt
  • ltuniongt
  • ltarrayFixedgt
  • ltarrayVariablegt
  • ltarrayStreamedgt
  • BxDataset
  • BxUnion
  • BxArrayFixed
  • BxArrayVariable
  • BxArrayStreamed

10
User type definition
  • ltdefineType typeNamemyStructgt
  • ltstructgt
  • lt/structgt
  • lt/defineTypegt
  • ltdefineType typeNamemyArraygt
  • ltarrayFixedgt
  • lt/arrayFixedgt
  • lt/defineTypegt
  • ltdefineType typeNamemyUniongt
  • ltuniongt
  • lt/uniongt
  • lt/defineTypegt

11
DataBinX Document
12
Primate types in DataBinX
  • lt?xml version1.0?gt
  • ltdataset xmlnsbxhttp//schema.nesc.ac.uk/binxgt
  • ltfilegt
  • ltshort-16gt32lt/short-16gt
  • ltinteger-32gt100lt/integer-32gt
  • ltieeeDouble-64gt50.5lt/ieeeDouble-64gt
  • lt/filegt
  • lt/datasetgt

13
Struct in DataBinX
  • ltstructgt
  •   ltunicodeCharacter-16gt0lt/unicodeCharacter-16gt
  •   ltlongInteger-64gt1lt/longInteger-64gt
  •   ltunicodeCharacter-16gt2lt/unicodeCharacter-16gt
  •   ltunsignedInteger-32gt3lt/unsignedInteger-32gt
  •   ltieeeDouble-64gt4lt/ieeeDouble-64gt
  •   ltshort-16gt5lt/short-16gt
  •   ltlongInteger-64gt6lt/longInteger-64gt
  •   ltieeeExtended-80gt7lt/ieeeExtended-80gt
  •   ltunicodeCharacter-32gt8lt/unicodeCharacter-32gt
  •   ltieeeExtended-80gt9lt/ieeeExtended-80gt
  •   lt/structgt

14
Array in DataBinX
  • ltarrayFixedgt
  • ltbyte-8/gt
  • ltdim namej indexTo1/gt
  • ltdim namei indexTo1/gt
  • lt/arrayFixedgt

ltarraydatagt ltdim index1 nameigt
ltdim index0 namejgt
ltbyte-8gt1lt/byte-8gtlt/dimgt ltdim index0
namejgt ltbyte-8gt2lt/byte-8gtlt/dimgt
lt/dimgt ltdim index1 nameigt ltdim
index0 namejgt
ltbyte-8gt3lt/byte-8gtlt/dimgt ltdim index0
namejgt ltbyte-8gt4lt/byte-8gtlt/dimgt
lt/dimgt lt/arraydatagt
15
BinX Library API
16
Parsing a BinX document
  • BxBinxFile pReader new BxBinxFile()
  • If (pReader-gtparse(mybinx.xml))
  • BxDataset pDataset pReader-gtgetDataset()

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 pWriternew 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-gtaddDataObject(i16)
  • Add data to the dataset

19
Creating BinX document
  • BxBinaryFile pbf new BxBinaryFile()
  • Create a new binary file
  • pbf-gtsetDatasetPointer(pData)
  • Create a link to the BinX document
  • pWriter-gtsetBinaryFilePtr(pbf)
  • pWriter-gtsave("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-gtgetDataset()
  • BxDataset pDataset2 pFile2-gtgetDataset()
  • BxArray pArray1 pDataset1-gtgetArray(0)
  • BxArray pArray2 pDataset2-gtgetArray(0)
  • BxDataObject pData1 pArray1-gtgetNext()
  • BxDataObject pData2 pArray2-gtgetNext()
  • FILE fo fopen(output.dat,wb)
  • pData1-gttoStreamBinary(fo)
  • pData2-gttoStreamBinary(fo)

21
Summary
  • One BinX document can describe
  • many binary files
  • Generate BinX document from code
  • Easy to use interfaces
  • Flexible
Write a Comment
User Comments (0)
About PowerShow.com