31 fin.read(
reinterpret_cast<char*
>(&readValue), 8);
37 fin.read(
reinterpret_cast<char*
>(&readValue), 4);
43 fin.read(
reinterpret_cast<char*
>(&readValue), 2);
49 fin.read(
reinterpret_cast<char*
>(&readValue), 1);
171 char* readCharArray =
new char[stringSize + 1];
172 fin.read(readCharArray, stringSize);
173 readCharArray[stringSize]=
'\0';
174 return readCharArray;
176 inline std::string
readString(std::ifstream& fin,
int stringSize)
179 std::string returnString = std::string(readCharArray);
180 delete readCharArray;
187 for(
int i = 0 ; i < stringSize ; i++)
189 return readCharArray;
194 std::string returnString = std::string(readCharArray);
195 delete readCharArray;
216 fout.write(
reinterpret_cast<char*
>(&writeValue),
sizeof(writeValue));
220 fout.write(
reinterpret_cast<char*
>(&writeValue),
sizeof(writeValue));
224 fout.write(
reinterpret_cast<char*
>(&writeValue),
sizeof(writeValue));
228 fout.write(
reinterpret_cast<char*
>(&writeValue),
sizeof(writeValue));
234 fout.write(
reinterpret_cast<char*
>(&writeValueBigEndian),
sizeof(writeValueBigEndian));
239 fout.write(
reinterpret_cast<char*
>(&writeValueBigEndian),
sizeof(writeValueBigEndian));
244 fout.write(
reinterpret_cast<char*
>(&writeValueBigEndian),
sizeof(writeValueBigEndian));
249 fout.write(
reinterpret_cast<char*
>(&writeValueBigEndian),
sizeof(writeValueBigEndian));
255 fout.write(
reinterpret_cast<char*
>(&writeValueLittleEndian),
sizeof(writeValueLittleEndian));
260 fout.write(
reinterpret_cast<char*
>(&writeValueLittleEndian),
sizeof(writeValueLittleEndian));
265 fout.write(
reinterpret_cast<char*
>(&writeValueLittleEndian),
sizeof(writeValueLittleEndian));
270 fout.write(
reinterpret_cast<char*
>(&writeValueLittleEndian),
sizeof(writeValueLittleEndian));
277 fout.write(
reinterpret_cast<char*
>(&writeValueByteSwappedBigEndian),
sizeof(writeValueByteSwappedBigEndian));
283 fout.write(
reinterpret_cast<char*
>(&writeValueByteSwappedBigEndian),
sizeof(writeValueByteSwappedBigEndian));
289 fout.write(
reinterpret_cast<char*
>(&writeValueByteSwappedBigEndian),
sizeof(writeValueByteSwappedBigEndian));
295 fout.write(
reinterpret_cast<char*
>(&writeValueByteSwappedBigEndian),
sizeof(writeValueByteSwappedBigEndian));
302 fout.write(
reinterpret_cast<char*
>(&writeValueByteSwappedLittleEndian),
sizeof(writeValueByteSwappedLittleEndian));
308 fout.write(
reinterpret_cast<char*
>(&writeValueByteSwappedLittleEndian),
sizeof(writeValueByteSwappedLittleEndian));
314 fout.write(
reinterpret_cast<char*
>(&writeValueByteSwappedLittleEndian),
sizeof(writeValueByteSwappedLittleEndian));
320 fout.write(
reinterpret_cast<char*
>(&writeValueByteSwappedLittleEndian),
sizeof(writeValueByteSwappedLittleEndian));
325 uint8_t nullChar = 0;
326 size_t charArraySize = 1;
327 for( ; (0 !=
writeCharArray[charArraySize-1] && charArraySize != outputSize); charArraySize++);
329 for( ; charArraySize < outputSize ; charArraySize++)
330 fout.write(
reinterpret_cast<char*
>(&nullChar), 1);
334 uint8_t nullChar = 0;
336 if((0 == outputSize) || (outputSize >= stringSize))
340 for( ; stringSize < outputSize ; stringSize++)
341 fout.write(
reinterpret_cast<char*
>(&nullChar), 1);
346 uint8_t nextChar = 0;
347 size_t charArraySize = 1;
348 for( ; (0 !=
writeCharArray[charArraySize-1] && charArraySize != outputSize); charArraySize++);
349 for(
size_t i = 0 ; i < charArraySize ; i++){
351 fout.write(
reinterpret_cast<char*
>(&nextChar), 1);
354 for( ; charArraySize < outputSize ; charArraySize++)
355 fout.write(
reinterpret_cast<char*
>(&nextChar), 1);
359 uint8_t nextChar = 0;
361 if((0 == outputSize) || (outputSize >= stringSize)) {
362 for(
size_t i = 0 ; i < stringSize ; i++){
364 fout.write(
reinterpret_cast<char*
>(&nextChar), 1);
367 for(
size_t i = 0 ; i < outputSize ; i++){
369 fout.write(
reinterpret_cast<char*
>(&nextChar), 1);
373 for( ; stringSize < outputSize ; stringSize++)
374 fout.write(
reinterpret_cast<char*
>(&nextChar), 1);
Endianness
< Endianness in byteman is represented not only by big/little endian, but also by potential bit swapp...
@ BE_BS
Big endian with bit swaps inside each byte.
@ LE_BS
Little endian with bit swaps inside each byte.
@ LE
Little endian ("LE" instead of full-er name, so it does not conflict with linux's reserved endianess ...
@ BE
Big endian ("BE" instead of full-er name, so it does not conflict with linux's reserved endianess wor...
@ NATIVE
System native will always be the fastest endianess to process.
uint64_t NativeToBigEndian64(uint64_t x)
uint8_t BigEndianToNative8(uint8_t x)
uint16_t BitSwap16(uint16_t x)
uint8_t BitSwap8(uint8_t x)
uint8_t LittleEndianToNative8(uint8_t x)
uint16_t NativeToLittleEndian16(uint16_t x)
uint32_t NativeToLittleEndian32(uint32_t x)
uint64_t BitSwap64(uint64_t x)
uint32_t BigEndianToNative32(uint32_t x)
uint64_t BigEndianToNative64(uint64_t x)
uint64_t NativeToLittleEndian64(uint64_t x)
uint32_t NativeToBigEndian32(uint32_t x)
uint16_t NativeToBigEndian16(uint16_t x)
uint64_t LittleEndianToNative64(uint64_t x)
uint32_t LittleEndianToNative32(uint32_t x)
uint32_t BitSwap32(uint32_t x)
uint16_t LittleEndianToNative16(uint16_t x)
uint16_t BigEndianToNative16(uint16_t x)
void writeCharArray(std::ofstream &fout, char *writeCharArray, size_t outputSize=0)
uint8_t readNative8(std::ifstream &fin)
std::string readString(std::ifstream &fin, int stringSize)
uint64_t read64(std::ifstream &fin, Endianness e=Endianness::NATIVE)
void writeBitSwappedLittleEndian8(std::ofstream &fout, uint8_t writeValue)
uint64_t readBitSwappedLittleEndian64(std::ifstream &fin)
uint64_t readBitSwappedBigEndian64(std::ifstream &fin)
uint32_t readBigEndian32(std::ifstream &fin)
uint8_t readBitSwappedLittleEndian8(std::ifstream &fin)
uint32_t readNative32(std::ifstream &fin)
void writeBitSwappedBigEndian16(std::ofstream &fout, uint16_t writeValue)
void writeBigEndian16(std::ofstream &fout, uint16_t writeValue)
uint32_t readLittleEndian32(std::ifstream &fin)
void writeBitSwappedLittleEndian32(std::ofstream &fout, uint32_t writeValue)
char * readBitSwappedStringIntoCharArray(std::ifstream &fin, int stringSize)
void writeString(std::ofstream &fout, std::string writeString, size_t outputSize=0)
uint16_t readBigEndian16(std::ifstream &fin)
void write16(std::ofstream &fout, uint16_t writeValue, Endianness e=Endianness::NATIVE)
uint64_t readLittleEndian64(std::ifstream &fin)
void write64(std::ofstream &fout, uint64_t writeValue, Endianness e=Endianness::NATIVE)
uint32_t readBitSwappedLittleEndian32(std::ifstream &fin)
uint32_t readBitSwappedBigEndian32(std::ifstream &fin)
uint16_t readBitSwappedLittleEndian16(std::ifstream &fin)
void writeBigEndian32(std::ofstream &fout, uint32_t writeValue)
void writeBitSwappedCharArray(std::ofstream &fout, char *writeCharArray, size_t outputSize=0)
uint64_t readBigEndian64(std::ifstream &fin)
void writeLittleEndian32(std::ofstream &fout, uint32_t writeValue)
std::string readBitSwappedString(std::ifstream &fin, int stringSize)
void writeLittleEndian8(std::ofstream &fout, uint8_t writeValue)
uint16_t read16(std::ifstream &fin, Endianness e=Endianness::NATIVE)
void writeBigEndian8(std::ofstream &fout, uint8_t writeValue)
void writeNative16(std::ofstream &fout, uint16_t writeValue)
char * readStringIntoCharArray(std::ifstream &fin, int stringSize)
void writeBitSwappedLittleEndian64(std::ofstream &fout, uint64_t writeValue)
void writeLittleEndian16(std::ofstream &fout, uint16_t writeValue)
void writeBitSwappedString(std::ofstream &fout, std::string writeString, size_t outputSize=0)
void write8(std::ofstream &fout, uint8_t writeValue, Endianness e=Endianness::NATIVE)
uint64_t readNative64(std::ifstream &fin)
void writeNative64(std::ofstream &fout, uint64_t writeValue)
void writeLittleEndian64(std::ofstream &fout, uint64_t writeValue)
void writeBitSwappedLittleEndian16(std::ofstream &fout, uint16_t writeValue)
uint32_t read32(std::ifstream &fin, Endianness e=Endianness::NATIVE)
void writeNative32(std::ofstream &fout, uint32_t writeValue)
void writeBigEndian64(std::ofstream &fout, uint64_t writeValue)
void writeBitSwappedBigEndian64(std::ofstream &fout, uint64_t writeValue)
uint8_t readBitSwappedBigEndian8(std::ifstream &fin)
uint16_t readNative16(std::ifstream &fin)
uint8_t readBigEndian8(std::ifstream &fin)
uint8_t read8(std::ifstream &fin, Endianness e=Endianness::NATIVE)
void writeBitSwappedBigEndian32(std::ofstream &fout, uint32_t writeValue)
uint8_t readLittleEndian8(std::ifstream &fin)
uint16_t readBitSwappedBigEndian16(std::ifstream &fin)
void writeBitSwappedBigEndian8(std::ofstream &fout, uint8_t writeValue)
void writeNative8(std::ofstream &fout, uint8_t writeValue)
uint16_t readLittleEndian16(std::ifstream &fin)
void write32(std::ofstream &fout, uint32_t writeValue, Endianness e=Endianness::NATIVE)