steghide 0.5.1
BitString.h
Go to the documentation of this file.
1/*
2 * steghide 0.5.1 - a steganography program
3 * Copyright (C) 1999-2003 Stefan Hetzl <shetzl@chello.at>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 *
19 */
20
21#ifndef SH_BITSTRING_H
22#define SH_BITSTRING_H
23
24#include <vector>
25#include <string>
26
27#include "AUtils.h"
28#include "common.h"
29
42class BitString {
43 public:
47 BitString (EmbValue arity = 2) ;
48
52 BitString (const BitString& bs) ;
53
57 BitString (const unsigned long l) ;
58
62 BitString (const std::vector<BYTE>& d) ;
63
67 BitString (const std::string& d) ;
68
69 void setArity (EmbValue arity) ;
70
71 EmbValue getArity (void) const
72 { return Arity ; } ;
73
77 UWORD32 getLength (void) const
78 { return Length ; } ;
79
84 { return AUtils::div_roundup<UWORD32> (Length, ArityNBits) ; } ;
85
89 BitString& clear (void) ;
90
94 BitString& append (const BIT v) ;
95
101 BitString& append (const BYTE v, const unsigned short n = 8) ;
102
108 BitString& append (const UWORD16 v, const unsigned short n = 16) ;
109
115 BitString& append (const UWORD32 v, const unsigned short n = 32) ;
116
120 BitString& append (const std::string& v) ;
121
125 BitString& append (const std::vector<BYTE>& v) ;
126
131 BitString& append (const BitString& v) ;
132
138 BitString& setBit (unsigned long i, BIT v) ;
139
146 BitString getBits (const unsigned long s, const unsigned long l) const ;
147
156 BitString cutBits (const unsigned long s, const unsigned long l) ;
157
164 UWORD32 getValue (const unsigned long s, const unsigned short l) const ;
165
172 const std::vector<BYTE>& getBytes (void) const ;
173
180 BitString& truncate (const unsigned long s, const unsigned long e) ;
181
187 BitString& pad (const unsigned long mult, const BIT v) ;
188
193 BitString& padRandom (const unsigned long mult) ;
194
200 BYTE getNAry (unsigned long p) const ;
201
206 void appendNAry (BYTE v) ;
207
208#ifdef USE_ZLIB
216 BitString& compress (int level) ;
217
231 BitString& uncompress (unsigned long idestlen) ;
232#endif // def USE_ZLIB
233
237 BIT operator[] (const unsigned long i) const ;
238
243 BitString& operator^= (const BitString &v) ;
244
249 bool operator== (const BitString& v) const ;
250
255 bool operator!= (const BitString& v) const ;
256
257 void print (unsigned short spc = 0) const ;
258#ifdef DEBUG
259 void printDebug (unsigned short level, unsigned short spc = 0) const ;
260#endif
261
262 private:
268 unsigned short ArityNBits ;
270 std::vector<BYTE> Data ;
271
272 void _append (BIT v) ;
273
277 void clearUnused (void) ;
278} ;
279
280#endif // ndef SH_BITSTRING_H
a string of bits
Definition BitString.h:42
UWORD32 Length
the number of bits in Data
Definition BitString.h:264
void print(unsigned short spc=0) const
Definition BitString.cc:440
BitString & pad(const unsigned long mult, const BIT v)
Definition BitString.cc:244
void _append(BIT v)
Definition BitString.cc:98
BitString & append(const BIT v)
Definition BitString.cc:107
EmbValue getArity(void) const
Definition BitString.h:71
BitString & clear(void)
Definition BitString.cc:91
void setArity(EmbValue arity)
Definition BitString.cc:80
UWORD32 getLength(void) const
Definition BitString.h:77
BitString & padRandom(const unsigned long mult)
Definition BitString.cc:252
BitString cutBits(const unsigned long s, const unsigned long l)
Definition BitString.cc:185
EmbValue Arity
the arity that will be used for getLength/getNAry/appendNAry
Definition BitString.h:266
BYTE getNAry(unsigned long p) const
Definition BitString.cc:260
BitString getBits(const unsigned long s, const unsigned long l) const
Definition BitString.cc:176
BitString & operator^=(const BitString &v)
Definition BitString.cc:414
UWORD32 getNAryLength(void) const
Definition BitString.h:83
void clearUnused(void)
Definition BitString.cc:426
BitString & truncate(const unsigned long s, const unsigned long e)
Definition BitString.cc:220
void appendNAry(BYTE v)
Definition BitString.cc:270
bool operator==(const BitString &v) const
Definition BitString.cc:376
std::vector< BYTE > Data
the actual data
Definition BitString.h:270
const std::vector< BYTE > & getBytes(void) const
Definition BitString.cc:214
unsigned short ArityNBits
the number of Bits per n-ary digit (where n is Arity)
Definition BitString.h:268
UWORD32 getValue(const unsigned long s, const unsigned short l) const
Definition BitString.cc:204
BIT operator[](const unsigned long i) const
Definition BitString.cc:161
bool operator!=(const BitString &v) const
Definition BitString.cc:395
BitString & setBit(unsigned long i, BIT v)
Definition BitString.cc:167
unsigned char BYTE
Definition common.h:47
unsigned long UWORD32
Definition common.h:45
unsigned short UWORD16
Definition common.h:46
BYTE EmbValue
Definition common.h:66
bool BIT
Definition common.h:65