the binx api

21
The BinX API The BinX API eDIKT project team eDIKT project team May 2003 May 2003 Ted Wen Ted Wen [email protected] [email protected] Robert Carroll Robert Carroll [email protected] [email protected]

Upload: tirza

Post on 22-Jan-2016

32 views

Category:

Documents


0 download

DESCRIPTION

The BinX API. eDIKT project team May 2003 Ted Wen [email protected] Robert Carroll [email protected]. 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. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: The BinX API

The BinX APIThe BinX API

eDIKT project teameDIKT project team

May 2003May 2003

Ted Wen Ted Wen [email protected]@nesc.ac.uk

Robert Carroll Robert Carroll [email protected]@nesc.ac.uk

Page 2: The BinX API

ContentsContents

Format of the BinX documentFormat of the BinX document The binary data fileThe binary data file BinX data typesBinX data types Format of the dataBinX documentFormat of the dataBinX document BinX library APIBinX library API

Page 3: The BinX API

A BinX documentA BinX document <<dataset dataset

byteOrderbyteOrder=“bigEndian”>=“bigEndian”> <<definitionsdefinitions>>

<defineType <defineType typeNametypeName=“myTyp”>=“myTyp”>

<arrayFixed><arrayFixed> <character-8/><character-8/> <dim <dim indexToindexTo=“9”/>=“9”/>

</arrayFixed></arrayFixed> </defineType></defineType>

</</definitionsdefinitions>> <<filefile srcsrc=“=“myfile.binmyfile.bin”>”>

<useType <useType typeNametypeName=“myTyp”/>=“myTyp”/> <integer-32 <integer-32 varNamevarName=“X” />=“X” />

</</filefile>> </</datasetdataset>>

Root element

Data class section

Data instance section

Abstract data type

Page 4: The BinX API

The BinX documentThe BinX document

<?xml version=“1.0”?><?xml version=“1.0”?>

<dataset xmlns=“<dataset xmlns=“http://http://schema.nesc.ac.uk/binxschema.nesc.ac.uk/binx”>”>

<file src=“binary.bin” <file src=“binary.bin” byteOrder=“littleEndian”>byteOrder=“littleEndian”>

<short-16/><short-16/>

<integer-32/><integer-32/>

<ieeeDouble-64/><ieeeDouble-64/>

</file></file>

</dataset></dataset>

Page 5: The BinX API

Another BinX documentAnother BinX document

… …… …<definitions><definitions><<defineTypedefineType typeName="array"> typeName="array">

<arrayFixed><arrayFixed><byte-8/><byte-8/><dim indexTo="15"/><dim indexTo="15"/>

</arrayFixed</arrayFixed>></</defineTypedefineType > ></definitions></definitions><file src=“binary.bin” byteOrder=“littleEndian”><file src=“binary.bin” byteOrder=“littleEndian”>

<useType typeName=“array”/><useType typeName=“array”/></dataset></dataset>

Page 6: The BinX API

The binary data fileThe binary data file

DataBinXDataBinX

<short-16>100</short-16> <short-16>100</short-16>

<integer-32>10000</integer-32><integer-32>10000</integer-32>

Binary Data

1100100

10011100010000

Hexadecimal

00 64

00 00 27 10

Page 7: The BinX API

BinX Data TypesBinX Data Types

Page 8: The BinX API

Primitive data typesPrimitive data types <byte-8><byte-8> <character-8><character-8> <short-16><short-16> <integer-32><integer-32> <longInteger-64><longInteger-64> <unsignedShort-16><unsignedShort-16> <unsignedInteger-32><unsignedInteger-32> <unsignedLongInteger-<unsignedLongInteger-

64>64> <ieeeFloat-32><ieeeFloat-32> <ieeeDouble-64><ieeeDouble-64> <ieeeExtended-80><ieeeExtended-80> <ieeeQuadruple-128><ieeeQuadruple-128>

BxByte8BxByte8 BxCharacter8BxCharacter8 BxShort16BxShort16 BxInteger32BxInteger32 BxLong64BxLong64 BxUnsignedShort16BxUnsignedShort16 BxUnsignedInteger32BxUnsignedInteger32 BxUnsignedLong64BxUnsignedLong64 BxFloat32BxFloat32 BxDouble64BxDouble64 BxExtended80BxExtended80 BxQuadruple128BxQuadruple128

Page 9: The BinX API

Complex data typesComplex data types

<struct><struct> <union><union> <arrayFixed><arrayFixed> <arrayVariable><arrayVariable> <arrayStreamed><arrayStreamed>

BxDatasetBxDataset BxUnionBxUnion BxArrayFixedBxArrayFixed BxArrayVariableBxArrayVariable BxArrayStreamedBxArrayStreamed

Page 10: The BinX API

User type definitionUser type definition

<defineType typeName=“myStruct”><defineType typeName=“myStruct”><struct><struct></struct></struct>

</defineType></defineType><defineType typeName=“myArray”><defineType typeName=“myArray”>

<arrayFixed><arrayFixed></arrayFixed></arrayFixed>

</defineType></defineType><defineType typeName=“myUnion”><defineType typeName=“myUnion”>

<union><union></union></union>

</defineType></defineType>

Page 11: The BinX API

DataBinX DataBinX DocumentDocument

Page 12: The BinX API

Primate types in Primate types in DataBinXDataBinX

<?xml version=“1.0”?><?xml version=“1.0”?>

<dataset xmlns:bx=“<dataset xmlns:bx=“http://http://schema.nesc.ac.uk/binxschema.nesc.ac.uk/binx”>”>

<file><file>

<short-16>32</short-16><short-16>32</short-16>

<integer-32>100</integer-32><integer-32>100</integer-32>

<ieeeDouble-64>50.5</ieeeDouble-64><ieeeDouble-64>50.5</ieeeDouble-64></file></file>

</dataset></dataset>

Page 13: The BinX API

Struct in DataBinXStruct in DataBinX… …… … <struct><struct>   <unicodeCharacter-16><unicodeCharacter-16>00</unicodeCharacter-16> </unicodeCharacter-16>    <longInteger-64><longInteger-64>11</longInteger-64> </longInteger-64>    <unicodeCharacter-16><unicodeCharacter-16>22</unicodeCharacter-16> </unicodeCharacter-16>    <unsignedInteger-32><unsignedInteger-32>33</unsignedInteger-32> </unsignedInteger-32>    <ieeeDouble-64><ieeeDouble-64>44</ieeeDouble-64> </ieeeDouble-64>    <short-16><short-16>55</short-16> </short-16>    <longInteger-64><longInteger-64>66</longInteger-64> </longInteger-64>    <ieeeExtended-80><ieeeExtended-80>77</ieeeExtended-80> </ieeeExtended-80>    <unicodeCharacter-32><unicodeCharacter-32>88</unicodeCharacter-32> </unicodeCharacter-32>    <ieeeExtended-80><ieeeExtended-80>99</ieeeExtended-80> </ieeeExtended-80>    </struct></struct>

Page 14: The BinX API

Array in DataBinXArray in DataBinX<arrayFixed><arrayFixed>

<byte-8/><byte-8/>

<dim name=“j” <dim name=“j” indexTo=“1”/>indexTo=“1”/>

<dim name=“i” <dim name=“i” indexTo=“1”/>indexTo=“1”/>

</arrayFixed></arrayFixed>

<arraydata><arraydata>

<dim index=“1” name=“i”><dim index=“1” name=“i”>

<dim index=“0” name=“j”><dim index=“0” name=“j”>

<byte-8>1</byte-8></dim><byte-8>1</byte-8></dim>

<dim index=“0” name=“j”><dim index=“0” name=“j”>

<byte-8>2</byte-8></dim><byte-8>2</byte-8></dim>

</dim></dim>

<dim index=“1” name=“i”><dim index=“1” name=“i”>

<dim index=“0” name=“j”><dim index=“0” name=“j”>

<byte-8>3</byte-8></dim><byte-8>3</byte-8></dim>

<dim index=“0” name=“j”><dim index=“0” name=“j”>

<byte-8>4</byte-8></dim><byte-8>4</byte-8></dim>

</dim></dim>

</arraydata></arraydata>

Page 15: The BinX API

BinX Library APIBinX Library API

Page 16: The BinX API

Parsing a BinX documentParsing a BinX document

BxBinxFile* pReader = new BxBinxFile* pReader = new BxBinxFile();BxBinxFile();

If (pReader->parse(“mybinx.xml”)) If (pReader->parse(“mybinx.xml”))

{{BxDataset* pDataset = pReader-BxDataset* pDataset = pReader-

>getDataset();>getDataset();

}}

Page 17: The BinX API

Output from the libraryOutput from the library

DataBinXDataBinX

The combined data and BinX The combined data and BinX documentdocument

SchemaBinXSchemaBinX Binary data streamBinary data stream

DataBinX = SchemaBinX + Binary DataBinX = SchemaBinX + Binary datadata

Page 18: The BinX API

Creating BinX documentCreating BinX document

BxBinxFileWriter* pWriter=new BxBinxFileWriter* pWriter=new BxBinxFileWriter();BxBinxFileWriter();

Create a object to write out the documentCreate a object to write out the document

BxDataset* pData = new BxDataset();BxDataset* pData = new BxDataset(); Create a new dataset (in memory BinX Create a new dataset (in memory BinX

document)document)

BxShort16* i16 = new BxShort16(100);BxShort16* i16 = new BxShort16(100);pData->addDataObject(i16);pData->addDataObject(i16); Add data to the datasetAdd data to the dataset

Page 19: The BinX API

Creating BinX documentCreating BinX document

BxBinaryFile* pbf = new BxBinaryFile();BxBinaryFile* pbf = new BxBinaryFile(); Create a new binary fileCreate a new binary file

pbf->setDatasetPointer(pData);pbf->setDatasetPointer(pData); Create a link to the BinX documentCreate a link to the BinX document

pWriterpWriter->setBinaryFilePtr(pbf);->setBinaryFilePtr(pbf);pWriterpWriter->save("TestDataset.xml");->save("TestDataset.xml"); Save the BinX documentSave the BinX document

Page 20: The BinX API

Merge binary dataMerge binary data

BxBinxFileReader * pFile1 = new BxBinxFileReader * pFile1 = new BxBinxFileReader(“file1.xml”);BxBinxFileReader(“file1.xml”);

BxBinxFileReader * pFile2 = new BxBinxFileReader * pFile2 = new BxBinxFileReader(“file2.xml”);BxBinxFileReader(“file2.xml”);

BxDataset * pDataset1 = pFile1->getDataset();BxDataset * pDataset1 = pFile1->getDataset();BxDataset * pDataset2 = pFile2->getDataset();BxDataset * pDataset2 = pFile2->getDataset();BxArray * pArray1 = pDataset1->getArray(0);BxArray * pArray1 = pDataset1->getArray(0);BxArray * pArray2 = pDataset2->getArray(0);BxArray * pArray2 = pDataset2->getArray(0);BxDataObject * pData1 = pArray1->getNext();BxDataObject * pData1 = pArray1->getNext();BxDataObject * pData2 = pArray2->getNext();BxDataObject * pData2 = pArray2->getNext();FILE * fo = fopen(“output.dat”,”wb”);FILE * fo = fopen(“output.dat”,”wb”);pData1->toStreamBinary(fo);pData1->toStreamBinary(fo);pData2->toStreamBinary(fo);pData2->toStreamBinary(fo);

Page 21: The BinX API

SummarySummary

One BinX document can describeOne BinX document can describe

many binary filesmany binary files Generate BinX document from codeGenerate BinX document from code Easy to use interfacesEasy to use interfaces FlexibleFlexible