15.10.2012 - version 0.2.0 - PIIODevice - base of file, ethernet, serial and packets extractor. PIEthernet now support also TCP (client and server). PIConsole now can align labels in each column individually.
This commit is contained in:
22
pibytearray.h
Normal file → Executable file
22
pibytearray.h
Normal file → Executable file
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Byte array
|
||||
Copyright (C) 2011 Ivan Pelipenko peri4ko@gmail.com
|
||||
Copyright (C) 2012 Ivan Pelipenko peri4ko@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -75,7 +75,7 @@ class PIByteArray;
|
||||
class PIHuffman {
|
||||
public:
|
||||
PIVector<uchar> compress(const PIVector<uchar> & src);
|
||||
|
||||
|
||||
private:
|
||||
struct node {
|
||||
int freq;
|
||||
@@ -95,27 +95,29 @@ public:
|
||||
PIByteArray() {;}
|
||||
PIByteArray(const uint size) {resize(size);}
|
||||
PIByteArray(const void * data, const uint size) {for (uint i = 0; i < size; ++i) push_back(((uchar * )data)[i]);}
|
||||
|
||||
|
||||
PIByteArray resized(int new_size) {PIByteArray tv(*this); tv.resize(new_size); return tv;}
|
||||
|
||||
PIByteArray & convertToBase64();
|
||||
PIByteArray & convertFromBase64();
|
||||
PIByteArray toBase64() {PIByteArray ba(*this); ba.convertToBase64(); return ba;}
|
||||
PIByteArray fromBase64() {PIByteArray ba(*this); ba.convertFromBase64(); return ba;}
|
||||
|
||||
|
||||
PIByteArray & compressRLE(uchar threshold = 192);
|
||||
PIByteArray & decompressRLE(uchar threshold = 192);
|
||||
PIByteArray compressedRLE(uchar threshold = 192) {PIByteArray ba(*this); ba.compressedRLE(threshold); return ba;}
|
||||
PIByteArray decompressedRLE(uchar threshold = 192) {PIByteArray ba(*this); ba.decompressedRLE(threshold); return ba;}
|
||||
|
||||
|
||||
PIByteArray & compressHuffman() {*this = huffman.compress(*this); return *this;}
|
||||
|
||||
|
||||
uchar checksumPlain8();
|
||||
uint checksumPlain32();
|
||||
uchar checksumCRC8();
|
||||
ushort checksumCRC16();
|
||||
uint checksumCRC32();
|
||||
|
||||
|
||||
void operator =(const PIVector<uchar> & d) {resize(d.size()); for (uint i = 0; i < size(); ++i) (*this)[i] = d[i];}
|
||||
|
||||
|
||||
private:
|
||||
union base64HelpStruct {
|
||||
struct {
|
||||
@@ -130,9 +132,9 @@ private:
|
||||
uchar byte2;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
static PIHuffman huffman;
|
||||
|
||||
|
||||
};
|
||||
|
||||
inline std::ostream & operator <<(std::ostream & s, const PIByteArray & ba) {for (uint i = 0; i < ba.size(); ++i) s << ba[i]; return s;}
|
||||
|
||||
Reference in New Issue
Block a user