the binx api edikt project team may 2003 ted wen robert carroll
DESCRIPTION
A BinX document Root element Data class section Data instance section Abstract data typeTRANSCRIPT
The BinX APIThe BinX APIeDIKT project teameDIKT project team
May 2003May 2003Ted Wen Ted Wen [email protected]@nesc.ac.uk
Robert Carroll Robert Carroll [email protected]@nesc.ac.uk
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
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
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>
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>
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
BinX Data TypesBinX Data Types
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
Complex data typesComplex data types <struct><struct> <union><union> <arrayFixed><arrayFixed> <arrayVariable><arrayVariable> <arrayStreamed><arrayStreamed>
BxDatasetBxDataset BxUnionBxUnion BxArrayFixedBxArrayFixed BxArrayVariableBxArrayVariable BxArrayStreamedBxArrayStreamed
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>
DataBinX DataBinX DocumentDocument
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>
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>
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>
BinX Library APIBinX Library API
Parsing a BinX documentParsing a BinX documentBxBinxFile* 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();
}}
Output from the libraryOutput from the library DataBinXDataBinXThe combined data and BinX The combined data and BinX
documentdocument SchemaBinXSchemaBinX Binary data streamBinary data stream
DataBinX = SchemaBinX + Binary DataBinX = SchemaBinX + Binary datadata
Creating BinX documentCreating BinX documentBxBinxFileWriter* 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
Creating BinX documentCreating BinX documentBxBinaryFile* 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
Merge binary dataMerge binary dataBxBinxFileReader * 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);
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