git-svn-id: svn://db.shs.com.ru/pip@224 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Byte array
|
||||
Copyright (C) 2015 Ivan Pelipenko peri4ko@gmail.com
|
||||
Copyright (C) 2016 Ivan Pelipenko peri4ko@gmail.com, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
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
|
||||
@@ -73,10 +73,9 @@ public:
|
||||
PIByteArray & convertFromBase64();
|
||||
|
||||
//! Return converted to Base 64 data
|
||||
PIByteArray toBase64() const {PIByteArray ba(*this); ba.convertToBase64(); return ba;}
|
||||
PIByteArray toBase64() const;
|
||||
|
||||
//! Return converted from Base 64 data
|
||||
PIByteArray fromBase64() const {PIByteArray ba(*this); ba.convertFromBase64(); return ba;}
|
||||
|
||||
PIByteArray & compressRLE(uchar threshold = 192);
|
||||
PIByteArray & decompressRLE(uchar threshold = 192);
|
||||
@@ -84,6 +83,7 @@ public:
|
||||
PIByteArray decompressedRLE(uchar threshold = 192) {PIByteArray ba(*this); ba.decompressRLE(threshold); return ba;}
|
||||
|
||||
PIString toString(int base = 16) const;
|
||||
PIString toHex() const;
|
||||
|
||||
//! Add to the end data "data" with size "size"
|
||||
PIByteArray & append(const void * data_, int size_) {uint ps = size(); enlarge(size_); memcpy(data(ps), data_, size_); return *this;}
|
||||
@@ -107,26 +107,8 @@ public:
|
||||
void operator =(const PIDeque<uchar> & d) {resize(d.size()); memcpy(data(), d.data(), d.size());}
|
||||
|
||||
static PIByteArray fromString(PIString str);
|
||||
|
||||
private:
|
||||
union base64HelpStruct {
|
||||
base64HelpStruct() {memset(this, 0, sizeof(base64HelpStruct));}
|
||||
struct {
|
||||
uchar ascii0: 6;
|
||||
uchar ascii1: 6;
|
||||
uchar ascii2: 6;
|
||||
uchar ascii3: 6;
|
||||
} ascii;
|
||||
struct {
|
||||
uchar byte0;
|
||||
uchar byte1;
|
||||
uchar byte2;
|
||||
} byte;
|
||||
};
|
||||
|
||||
static const char base64Table[64];
|
||||
static const char base64InvTable[256];
|
||||
|
||||
static PIByteArray fromHex(PIString str);
|
||||
static PIByteArray fromBase64(const PIByteArray &base64);
|
||||
};
|
||||
|
||||
inline bool operator <(const PIByteArray & v0, const PIByteArray & v1) {if (v0.size() == v1.size()) {for (uint i = 0; i < v0.size(); ++i) if (v0[i] != v1[i]) return v0[i] < v1[i]; return false;} return v0.size() < v1.size();}
|
||||
|
||||
Reference in New Issue
Block a user