SDL Window Engine  20200905
swe_binarybuf.h
1 /***************************************************************************
2  * Copyright (C) 2017 by SWE team <sdl.window.engine@gmail.com> *
3  * *
4  * Part of the SWE: SDL Window Engine: *
5  * https://github.com/AndreyBarmaley/sdl-window-engine *
6  * *
7  * This program is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program; if not, write to the *
19  * Free Software Foundation, Inc., *
20  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  ***************************************************************************/
22 
23 #ifndef _SWE_BINARYBUF_
24 #define _SWE_BINARYBUF_
25 
26 #include <string>
27 #include <vector>
28 
29 #include "swe_types.h"
30 
32 namespace SWE
33 {
35  class BinaryBuf : public std::vector<u8>
36  {
37  protected:
38  BinaryBuf(const_iterator it1, const_iterator it2) : std::vector<u8>(it1, it2) {}
39 
40  public:
41  BinaryBuf();
42  BinaryBuf(size_t len, int ch = 0);
43  BinaryBuf(const u8* ptr, size_t len);
44  BinaryBuf(const std::vector<u8> &);
45  BinaryBuf(const BinaryBuf &);
46  BinaryBuf(BinaryBuf &&) noexcept;
47  BinaryBuf(std::vector<u8> &&) noexcept;
48 
49  BinaryBuf & operator= (const BinaryBuf &);
50  BinaryBuf & operator= (BinaryBuf &&) noexcept;
51  BinaryBuf & operator= (std::vector<u8> &&) noexcept;
52 
53  BinaryBuf zlibUncompress(size_t real = 0) const;
54  BinaryBuf zlibCompress(void) const;
55 
56  BinaryBuf base64Decode(void) const;
57  BinaryBuf base64Encode(void) const;
58 
59  u32 crc32b(void) const;
60  int crc16b(void) const;
61  std::string toString(void) const;
62  std::string toHexString(const std::string & sep = ", ", bool prefix = true) const;
63 
64  BinaryBuf & append(const BinaryBuf &);
65  };
66 
67 } // SWE
68 #endif
пространство SWE.
Definition: swe_binarybuf.cpp:30
класс бинарного массива
Definition: swe_binarybuf.h:35