1 /* vi: set sw=4 ts=4: 2 * 3 * Copyright (C) 2020 Christian Hohnstaedt. 4 * 5 * All rights reserved. 6 */ 7 8 #ifndef __BIOBYTEARRAY_H 9 #define __BIOBYTEARRAY_H 10 11 #include <QByteArray> 12 #include <QString> 13 #include <openssl/bio.h> 14 15 class BioByteArray 16 { 17 protected: 18 BIO *read_write; 19 BIO *read_only; 20 QByteArray store; 21 22 void set(const QByteArray &qba); 23 void add(const QByteArray &qba); 24 void biowrite(const QByteArray &qba); 25 void cleanse_and_free(BIO *bio); 26 27 public: BioByteArray(const QByteArray & qba)28 BioByteArray(const QByteArray &qba) : 29 read_write(NULL), read_only(NULL), store(qba) { } BioByteArray(const BioByteArray & bba)30 BioByteArray(const BioByteArray &bba) : 31 read_write(NULL), read_only(NULL), store(bba.byteArray()) { } BioByteArray()32 BioByteArray() : 33 read_write(NULL), read_only(NULL), store() { } 34 ~BioByteArray(); 35 int size() const; 36 BIO *bio(); 37 BIO *ro(); 38 QByteArray byteArray() const; 39 QString qstring() const; 40 operator BIO*(); 41 operator QByteArray(); 42 BioByteArray &operator = (const BioByteArray &other); 43 BioByteArray &operator = (const QByteArray &qba); 44 BioByteArray &operator += (const BioByteArray &other); 45 BioByteArray &operator += (const QByteArray &qba); 46 }; 47 #endif 48