Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes

YAPET::PWGEN::CharacterPool Class Reference

Generate character pools. More...

#include <charpool.h>

List of all members.

Public Member Functions

 CharacterPool (int p) throw (std::runtime_error)
 CharacterPool (SUBPOOLS p) throw (std::runtime_error)
 CharacterPool (const CharacterPool &cp) throw (std::runtime_error)
SUBPOOLS fromPool (char c) const
 Return the pool the character belongs to.
int getAllocatedPools () const
size_t getPoolLength () const throw ()
size_t getPoolPos (SUBPOOLS p, size_t *start) const
 The position and length of the pool.
int getPoolsWithRead () const
 Which pools had been read from.
bool hadPoolReads (SUBPOOLS p) const
bool isPoolAllocated (SUBPOOLS p) const
int numPoolsAllocated () const
int numPoolsNotRead () const
 Number of pools not read.
size_t operator() () const throw ()
const CharacterPooloperator= (const CharacterPool &cp) throw (std::runtime_error)
char operator[] (size_t pos) throw (std::logic_error)
 Return a character at the position specified.
int print_pools_allocated () const
void resetPoolsWithRead ()
 Reset the bitmask of pools that have reads.
virtual ~CharacterPool () throw ()

Protected Member Functions

const char * getPool (size_t *len) const throw (std::runtime_error)
const char * getPool () const throw ()
size_t pool_digits_len () const
size_t pool_len (SUBPOOLS p) const
size_t pool_letters_len () const
size_t pool_other_len () const
size_t pool_punct_len () const
size_t pool_special_len () const

Static Protected Member Functions

static const char * get_digits ()
static const char * get_letters ()
static const char * get_other ()
static const char * get_punct ()
static const char * get_special ()

Private Member Functions

void init (int p) throw (std::runtime_error)

Private Attributes

char * pool
 hold the pool of characters returned
size_t pool_length
int pools_allocated
int pools_reads

Static Private Attributes

static const char digits [] = "0123456789"
static const char letters [] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
static const char other [] = "§°@#\\|$£~`^"
static const char punct [] = ".,;:-!?'"
static const char special [] = "_+\"*%&/()[]={}<>"

Detailed Description

Generate character pools according defined parameters.

Definition at line 81 of file charpool.h.


Constructor & Destructor Documentation

CharacterPool::CharacterPool ( int  p  )  throw (std::runtime_error) [explicit]

Definition at line 123 of file charpool.cc.

CharacterPool::CharacterPool ( SUBPOOLS  p  )  throw (std::runtime_error) [explicit]

Definition at line 131 of file charpool.cc.

CharacterPool::~CharacterPool (  )  throw () [virtual]

Definition at line 139 of file charpool.cc.

References pool.

CharacterPool::CharacterPool ( const CharacterPool cp  )  throw (std::runtime_error)

Definition at line 147 of file charpool.cc.


Member Function Documentation

SUBPOOLS CharacterPool::fromPool ( char  c  )  const

Definition at line 225 of file charpool.cc.

References digits, letters, other, punct, and special.

Referenced by YAPET::PWGEN::PWGen::sanitize_password().

Here is the caller graph for this function:

const char * CharacterPool::get_digits (  )  [inline, static, protected]

Definition at line 48 of file charpool.cc.

References digits.

const char * CharacterPool::get_letters (  )  [inline, static, protected]

Definition at line 45 of file charpool.cc.

References letters.

const char * CharacterPool::get_other (  )  [inline, static, protected]

Definition at line 57 of file charpool.cc.

References other.

const char * CharacterPool::get_punct (  )  [inline, static, protected]

Definition at line 51 of file charpool.cc.

References punct.

const char * CharacterPool::get_special (  )  [inline, static, protected]

Definition at line 54 of file charpool.cc.

References special.

int YAPET::PWGEN::CharacterPool::getAllocatedPools (  )  const [inline]

Definition at line 187 of file charpool.h.

References pools_allocated.

Referenced by YAPET::PWGEN::PWGen::getCharacterPools(), and YAPET::PWGEN::PWGen::getCharFromUnusedPools().

Here is the caller graph for this function:

const char* YAPET::PWGEN::CharacterPool::getPool ( size_t *  len  )  const throw (std::runtime_error) [inline, protected]

Definition at line 160 of file charpool.h.

References pool, and pool_length.

const char* YAPET::PWGEN::CharacterPool::getPool (  )  const throw () [inline, protected]

Definition at line 172 of file charpool.h.

References pool.

size_t YAPET::PWGEN::CharacterPool::getPoolLength (  )  const throw () [inline]

Definition at line 228 of file charpool.h.

References pool_length.

Referenced by operator()().

Here is the caller graph for this function:

size_t CharacterPool::getPoolPos ( SUBPOOLS  p,
size_t *  start 
) const

Return the position and length of the pool.

Returns 0 and sets start=0 if the pool p is not allocated.

Remember that start+length is not the last character of the pool in question, but the first character of the adjacent pool (if any!!).

Parameters:
p the pool in question.
start pointer to size_t where the start position will be stored.
Returns:
the length of the pool. If zero, an error occured.

Definition at line 204 of file charpool.cc.

References isPoolAllocated(), YAPET::PWGEN::LETTERS, and pool_len().

Referenced by YAPET::PWGEN::PWGen::getCharFromUnusedPools().

Here is the call graph for this function:

Here is the caller graph for this function:

int YAPET::PWGEN::CharacterPool::getPoolsWithRead (  )  const [inline]

Return the pools that had at least one read so far.

Returns:
bitmask of the pools with reads.

Definition at line 203 of file charpool.h.

References pools_reads.

Referenced by YAPET::PWGEN::PWGen::getCharFromUnusedPools().

Here is the caller graph for this function:

bool YAPET::PWGEN::CharacterPool::hadPoolReads ( SUBPOOLS  p  )  const [inline]

Definition at line 193 of file charpool.h.

References pools_reads.

Referenced by numPoolsNotRead().

Here is the caller graph for this function:

void CharacterPool::init ( int  p  )  throw (std::runtime_error) [private]
bool YAPET::PWGEN::CharacterPool::isPoolAllocated ( SUBPOOLS  p  )  const [inline]

Definition at line 190 of file charpool.h.

References pools_allocated.

Referenced by getPoolPos(), numPoolsAllocated(), and numPoolsNotRead().

Here is the caller graph for this function:

int CharacterPool::numPoolsAllocated (  )  const

Returns the number of pools allocated.

Definition at line 168 of file charpool.cc.

References isPoolAllocated(), and YAPET::PWGEN::LETTERS.

Referenced by print_pools_allocated(), and YAPET::PWGEN::PWGen::sanitize_password().

Here is the call graph for this function:

Here is the caller graph for this function:

int CharacterPool::numPoolsNotRead (  )  const

Return the number of pools from which not have been read so far

Definition at line 178 of file charpool.cc.

References hadPoolReads(), isPoolAllocated(), and YAPET::PWGEN::LETTERS.

Referenced by YAPET::PWGEN::PWGen::getCharFromUnusedPools(), and YAPET::PWGEN::PWGen::sanitize_password().

Here is the call graph for this function:

Here is the caller graph for this function:

size_t YAPET::PWGEN::CharacterPool::operator() (  )  const throw () [inline]

Definition at line 235 of file charpool.h.

References getPoolLength().

Here is the call graph for this function:

const CharacterPool & CharacterPool::operator= ( const CharacterPool cp  )  throw (std::runtime_error)

Definition at line 272 of file charpool.cc.

char CharacterPool::operator[] ( size_t  pos  )  throw (std::logic_error)

Return the character at the postion pos specified from the pool.

Parameters:
pos the position of the character to retrieve. Zero based, must be less than the value reported by getPoolLength()
Returns:
The character at the specified position, or zero upon error, i.e. pos greater than or equal to getPoolLength()

Definition at line 250 of file charpool.cc.

References YAPET::PWGEN::LETTERS.

size_t YAPET::PWGEN::CharacterPool::pool_digits_len (  )  const [inline, protected]

Definition at line 124 of file charpool.h.

References digits.

Referenced by pool_len().

Here is the caller graph for this function:

size_t YAPET::PWGEN::CharacterPool::pool_len ( SUBPOOLS  p  )  const [inline, protected]

Definition at line 136 of file charpool.h.

References YAPET::PWGEN::ALL, YAPET::PWGEN::DIGITS, YAPET::PWGEN::LETTERS, YAPET::PWGEN::OTHER, pool_digits_len(), pool_letters_len(), pool_other_len(), pool_punct_len(), pool_special_len(), YAPET::PWGEN::PUNCT, and YAPET::PWGEN::SPECIAL.

Referenced by getPoolPos().

Here is the call graph for this function:

Here is the caller graph for this function:

size_t YAPET::PWGEN::CharacterPool::pool_letters_len (  )  const [inline, protected]

Definition at line 121 of file charpool.h.

References letters.

Referenced by pool_len().

Here is the caller graph for this function:

size_t YAPET::PWGEN::CharacterPool::pool_other_len (  )  const [inline, protected]

Definition at line 133 of file charpool.h.

References other.

Referenced by pool_len().

Here is the caller graph for this function:

size_t YAPET::PWGEN::CharacterPool::pool_punct_len (  )  const [inline, protected]

Definition at line 127 of file charpool.h.

References punct.

Referenced by pool_len().

Here is the caller graph for this function:

size_t YAPET::PWGEN::CharacterPool::pool_special_len (  )  const [inline, protected]

Definition at line 130 of file charpool.h.

References special.

Referenced by pool_len().

Here is the caller graph for this function:

int CharacterPool::print_pools_allocated (  )  const

Definition at line 300 of file charpool.cc.

References YAPET::PWGEN::DIGITS, YAPET::PWGEN::LETTERS, numPoolsAllocated(), YAPET::PWGEN::OTHER, pools_allocated, YAPET::PWGEN::PUNCT, and YAPET::PWGEN::SPECIAL.

Here is the call graph for this function:

void YAPET::PWGEN::CharacterPool::resetPoolsWithRead (  )  [inline]

Reset (set to zero) the bitmask of the pools that have been read from.

Definition at line 212 of file charpool.h.

References pools_reads.


Member Data Documentation

const char CharacterPool::digits = "0123456789" [static, private]

Definition at line 84 of file charpool.h.

Referenced by fromPool(), get_digits(), and pool_digits_len().

const char CharacterPool::letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" [static, private]

Definition at line 83 of file charpool.h.

Referenced by fromPool(), get_letters(), and pool_letters_len().

const char CharacterPool::other = "§°@#\\|$£~`^" [static, private]

Definition at line 87 of file charpool.h.

Referenced by fromPool(), get_other(), and pool_other_len().

Warning:
pool is NOT zero terminated!

Hold the pool of characters returned to the caller later on. This class will take care of allocating and deallocating the pool.

Definition at line 98 of file charpool.h.

Referenced by getPool(), and ~CharacterPool().

Definition at line 100 of file charpool.h.

Referenced by getPool(), and getPoolLength().

The pools that have been allocated.

Definition at line 105 of file charpool.h.

Referenced by getAllocatedPools(), isPoolAllocated(), and print_pools_allocated().

Keeps track of which pools had at least one read.

Definition at line 110 of file charpool.h.

Referenced by getPoolsWithRead(), hadPoolReads(), and resetPoolsWithRead().

const char CharacterPool::punct = ".,;:-!?'" [static, private]

Definition at line 85 of file charpool.h.

Referenced by fromPool(), get_punct(), and pool_punct_len().

const char CharacterPool::special = "_+\"*%&/()[]={}<>" [static, private]

Definition at line 86 of file charpool.h.

Referenced by fromPool(), get_special(), and pool_special_len().


The documentation for this class was generated from the following files: