VR-Vantage
Loading...
Searching...
No Matches
byteStream.h
Go to the documentation of this file.
1/*********************************************************************************
2** Copyright (c) 2016 MAK Technologies, Inc.
3** All rights reserved.
4*********************************************************************************/
5
6#pragma once
7
11
12#include "export.h"
13
14#include <vlpi/entityIdentifier.h>
15#include <vlpi/entityType.h>
16#include <matrix/vlVector.h>
17#include <matrix/vlTaitBryan.h>
18#include <matrix/vlQuaternion.h>
19
20#include <vector>
21#include <string>
22
23namespace makRadarFx
24{
28{
29 public:
31 DtStreamReader(unsigned char* buffer, int length, bool makeCopy=false);
32
34 virtual ~DtStreamReader();
35
38
39 virtual bool readBool();
40 virtual char readInt8();
41 virtual unsigned char readUInt8();
42 virtual short readInt16();
43 virtual unsigned short readUInt16();
44 virtual int readInt32();
45 virtual unsigned readUInt32();
46 virtual long long readInt64();
47 virtual unsigned long long readUInt64();
48 virtual float readSingle();
49 virtual double readDouble();
50 virtual std::string readString();
51 virtual DtVector readVector();
52 virtual DtTaitBryan readTaitBryan();
53 DtQuaternion readQuaternion();
54 DtEntityIdentifier readEntityId();
55 DtEntityType readEntityType();
56 //this allocates a new byte array and copies data into it
57 unsigned char* readBytes(int length);
58 //this read from the byte stream into a supplied buffer
59 virtual void readBytes(unsigned char* buffer, int length);
60
62
63 protected:
66 unsigned char* myBuffer;
67 unsigned char* myReadHead;
70};
71
75{
76 public:
79
81 DtStreamWriter(unsigned char* buffer, int length);
82
84 virtual ~DtStreamWriter();
85
87 //{@
88 virtual unsigned char* buffer();
89 virtual int length();
91
94
95 virtual void writeBool(bool b);
96 virtual void writeInt8(char num);
97 virtual void writeUInt8(unsigned char num);
98 virtual void writeInt16(short num);
99 virtual void writeUInt16(unsigned short num);
100 virtual void writeInt32(int num);
101 virtual void writeUInt32(unsigned int num);
102 virtual void writeInt64(long long num);
103 virtual void writeUInt64(unsigned long long num);
104 virtual void writeSingle(float num);
105 virtual void writeDouble(double num);
106 virtual void writeString(std::string& str);
107 virtual void writeVector(DtVector& vec);
108 virtual void writeTaitBryan(DtTaitBryan& tb);
109 virtual void writeQuaternion(const DtQuaternion& q);
110 virtual void writeEntityId(const DtEntityIdentifier& id);
111 virtual void writeEntityType(const DtEntityType& type);
112 virtual void writeBytes(unsigned char* buffer, int length);
114
115 protected:
117 void encodeStringSize(int size);
118 unsigned char* myBuffer;
119 unsigned char* myWriteHead;
122};
123
128{
129 public:
131 DtBigEndianStreamReader(unsigned char* buffer, int length, bool makeCopy = false);
132
135
138
139 virtual short readInt16();
140 virtual unsigned short readUInt16();
141 virtual int readInt32();
142 virtual unsigned readUInt32();
143 virtual long long readInt64();
144 virtual unsigned long long readUInt64();
145 virtual float readSingle();
146 virtual double readDouble();
148
149 protected:
150};
151
155{
156 public:
159
162
165
168
169 void writeInt16(short num);
170 void writeUInt16(unsigned short num);
171 void writeInt32(int num);
172 void writeUInt32(unsigned int num);
173 void writeInt64(long long num);
174 void writeUInt64(unsigned long long num);
175 void writeSingle(float num);
176 void writeDouble(double num);
178
179 protected:
180};
181
184}
DtBigEndianStreamReader(unsigned char *buffer, int length, bool makeCopy=false)
constructor makes a copy of the buffer to work on.
virtual ~DtBigEndianStreamReader()
destructor
virtual short readInt16()
value readers return a value and increment the current position in the byte stream based on the size ...
virtual unsigned short readUInt16()
virtual unsigned long long readUInt64()
void writeInt16(short num)
value readers return a value and increment the current position in the byte stream based on the size ...
void writeUInt16(unsigned short num)
DtBigEndianStreamWriter(unsigned char *buffer, int length)
constructor a given buffer and it's size. Care must be taken to allocate enough space.
void writeUInt64(unsigned long long num)
DtBigEndianStreamWriter(int length)
constructor takes size of internal buffer to create. Care must be taken to allocate enough space.
virtual ~DtBigEndianStreamWriter()
destructor
void writeUInt32(unsigned int num)
virtual double readDouble()
virtual bool readBool()
value readers return a value and increment the current position in the byte stream based on the size ...
DtQuaternion readQuaternion()
virtual DtVector readVector()
DtStreamReader(unsigned char *buffer, int length, bool makeCopy=false)
constructor makes a copy of the buffer to work on.
int decodeStringSize()
determine the size of a string from a variable length encoded integer
virtual DtTaitBryan readTaitBryan()
int myLength
Definition byteStream.h:68
DtEntityType readEntityType()
virtual unsigned readUInt32()
virtual void readBytes(unsigned char *buffer, int length)
virtual unsigned short readUInt16()
DtEntityIdentifier readEntityId()
unsigned char * myReadHead
Definition byteStream.h:67
virtual unsigned long long readUInt64()
virtual float readSingle()
virtual long long readInt64()
virtual ~DtStreamReader()
destructor
bool myShouldDelete
Definition byteStream.h:69
unsigned char * readBytes(int length)
virtual std::string readString()
virtual short readInt16()
virtual unsigned char readUInt8()
unsigned char * myBuffer
Definition byteStream.h:66
virtual void writeQuaternion(const DtQuaternion &q)
virtual void writeInt32(int num)
virtual void writeInt64(long long num)
virtual void writeVector(DtVector &vec)
virtual void writeSingle(float num)
bool myShouldDelete
Definition byteStream.h:121
virtual void writeUInt8(unsigned char num)
virtual void writeInt16(short num)
virtual void writeBytes(unsigned char *buffer, int length)
unsigned char * myBuffer
Definition byteStream.h:118
virtual void writeEntityId(const DtEntityIdentifier &id)
DtStreamWriter(int length)
constructor takes size of internal buffer to create. Care must be taken to allocate enough space.
virtual void writeUInt64(unsigned long long num)
virtual void writeUInt32(unsigned int num)
DtStreamWriter(unsigned char *buffer, int length)
constructor a given buffer and it's size. Care must be taken to allocate enough space.
virtual void writeBool(bool b)
value readers return a value and increment the current position in the byte stream based on the size ...
virtual void writeDouble(double num)
virtual void writeTaitBryan(DtTaitBryan &tb)
unsigned char * myWriteHead
Definition byteStream.h:119
virtual unsigned char * buffer()
get a copy of the internal buffer
virtual ~DtStreamWriter()
destructor
virtual void writeInt8(char num)
virtual void writeUInt16(unsigned short num)
virtual void writeString(std::string &str)
int myLength
Definition byteStream.h:120
virtual void writeEntityType(const DtEntityType &type)
void encodeStringSize(int size)
encode the size of the string as a variable sized integer
#define RFX_DLL_SHARED
Definition include/radarFxShared/export.h:15
Definition radarFxConnector.h:28
RFX_DLL_SHARED int DtEncodedStringLength(std::string str)
Get the size in bytes of the string when it is encoded.