BitString.h
Go to the documentation of this file.
/*
* steghide 0.5.1 - a steganography program
* Copyright (C) 1999-2003 Stefan Hetzl <shetzl@chello.at>
*
* 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 the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef SH_BITSTRING_H
#define SH_BITSTRING_H
#include <vector>
#include <string>
#include "AUtils.h"
#include "common.h"
class BitString {
public:
BitString (EmbValue arity = 2) ;
BitString (const BitString& bs) ;
BitString (const unsigned long l) ;
BitString (const std::vector<BYTE>& d) ;
BitString (const std::string& d) ;
void setArity (EmbValue arity) ;
EmbValue getArity (void) const
{ return Arity ; } ;
UWORD32 getLength (void) const
{ return Length ; } ;
UWORD32 getNAryLength (void) const
{ return AUtils::div_roundup<UWORD32> (Length, ArityNBits) ; } ;
BitString& clear (void) ;
BitString& append (const BIT v) ;
BitString& append (const BYTE v, const unsigned short n = 8) ;
BitString& append (const UWORD16 v, const unsigned short n = 16) ;
BitString& append (const UWORD32 v, const unsigned short n = 32) ;
BitString& append (const std::string& v) ;
BitString& append (const std::vector<BYTE>& v) ;
BitString& append (const BitString& v) ;
BitString& setBit (unsigned long i, BIT v) ;
BitString getBits (const unsigned long s, const unsigned long l) const ;
BitString cutBits (const unsigned long s, const unsigned long l) ;
UWORD32 getValue (const unsigned long s, const unsigned short l) const ;
const std::vector<BYTE>& getBytes (void) const ;
BitString& truncate (const unsigned long s, const unsigned long e) ;
BitString& pad (const unsigned long mult, const BIT v) ;
BitString& padRandom (const unsigned long mult) ;
BYTE getNAry (unsigned long p) const ;
void appendNAry (BYTE v) ;
#ifdef USE_ZLIB
BitString& compress (int level) ;
BitString& uncompress (unsigned long idestlen) ;
#endif // def USE_ZLIB
BIT operator[] (const unsigned long i) const ;
BitString& operator^= (const BitString &v) ;
bool operator== (const BitString& v) const ;
bool operator!= (const BitString& v) const ;
void print (unsigned short spc = 0) const ;
#ifdef DEBUG
void printDebug (unsigned short level, unsigned short spc = 0) const ;
#endif
private:
UWORD32 Length ;
EmbValue Arity ;
unsigned short ArityNBits ;
std::vector<BYTE> Data ;
void _append (BIT v) ;
void clearUnused (void) ;
} ;
#endif // ndef SH_BITSTRING_H
BitString::getLength
UWORD32 getLength(void) const
Definition: BitString.h:77
BitString::getNAry
BYTE getNAry(unsigned long p) const
Definition: BitString.cc:260
BitString::operator[]
BIT operator[](const unsigned long i) const
Definition: BitString.cc:161
BIT
bool BIT
Definition: common.h:65
BitString::append
BitString & append(const BIT v)
Definition: BitString.cc:107
BitString::cutBits
BitString cutBits(const unsigned long s, const unsigned long l)
Definition: BitString.cc:185
BitString::getArity
EmbValue getArity(void) const
Definition: BitString.h:71
BitString::operator!=
bool operator!=(const BitString &v) const
Definition: BitString.cc:395
BYTE
unsigned char BYTE
Definition: common.h:47
AUtils.h
UWORD16
unsigned short UWORD16
Definition: common.h:46
BitString::setBit
BitString & setBit(unsigned long i, BIT v)
Definition: BitString.cc:167
BitString::Length
UWORD32 Length
the number of bits in Data
Definition: BitString.h:264
UWORD32
unsigned long UWORD32
Definition: common.h:45
BitString::appendNAry
void appendNAry(BYTE v)
Definition: BitString.cc:270
BitString::getBytes
const std::vector< BYTE > & getBytes(void) const
Definition: BitString.cc:214
BitString::clear
BitString & clear(void)
Definition: BitString.cc:91
BitString
a string of bits
Definition: BitString.h:42
BitString::Arity
EmbValue Arity
the arity that will be used for getLength/getNAry/appendNAry
Definition: BitString.h:266
BitString::getValue
UWORD32 getValue(const unsigned long s, const unsigned short l) const
Definition: BitString.cc:204
BitString::operator^=
BitString & operator^=(const BitString &v)
Definition: BitString.cc:414
BitString::_append
void _append(BIT v)
Definition: BitString.cc:98
BitString::ArityNBits
unsigned short ArityNBits
the number of Bits per n-ary digit (where n is Arity)
Definition: BitString.h:268
common.h
BitString::Data
std::vector< BYTE > Data
the actual data
Definition: BitString.h:270
BitString::setArity
void setArity(EmbValue arity)
Definition: BitString.cc:80
EmbValue
BYTE EmbValue
Definition: common.h:66
BitString::operator==
bool operator==(const BitString &v) const
Definition: BitString.cc:376
BitString::getBits
BitString getBits(const unsigned long s, const unsigned long l) const
Definition: BitString.cc:176
BitString::truncate
BitString & truncate(const unsigned long s, const unsigned long e)
Definition: BitString.cc:220
BitString::pad
BitString & pad(const unsigned long mult, const BIT v)
Definition: BitString.cc:244
BitString::BitString
BitString(EmbValue arity=2)
Definition: BitString.cc:34
BitString::getNAryLength
UWORD32 getNAryLength(void) const
Definition: BitString.h:83
BitString::padRandom
BitString & padRandom(const unsigned long mult)
Definition: BitString.cc:252
BitString::clearUnused
void clearUnused(void)
Definition: BitString.cc:426
BitString::print
void print(unsigned short spc=0) const
Definition: BitString.cc:440