Main Page | Class List | Directories | File List | Class Members | File Members

IbanCheck Class Reference

IBAN bank information database and IBAN verification. More...

#include <iban.h>

List of all members.

Public Types

enum  Result {

Public Member Functions

 IbanCheck (const std::string &filename="")
 ~IbanCheck ()
Result check (const Iban &iban, const std::string &country="") const
Result check (const std::string &iban, const std::string &country="") const
Result bic_position (const std::string &iban, int &start, int &end) const
bool error () const
bool selftest ()

Static Public Member Functions

static const char * resultText (Result res)


std::istream & operator>> (std::istream &is, Spec &spec)
std::istream & operator>> (std::istream &is, Country &c)


struct  Country
struct  Spec

Detailed Description

IBAN bank information database and IBAN verification.

Stores a mapping of IBAN-prefixes to required length of the IBAN and BIC (Bank Identification Code) position inside the IBAN, and a second mapping of the ISO 3166 2-character country code to the list of prefixes for that country (usually one, identically to the country code).

The mappings are read from a file when an instance of the class is created.

Member Enumeration Documentation

enum Result

Code returned by check() (and also by bic_position()).

Enumeration values:
OK  IBAN is formally correct (length and checksum).
TOO_SHORT  IBAN is too short to even check.
PREFIX_NOT_FOUND  the 2-character IBAN prefix is unknown
WRONG_LENGTH  IBAN has the wrong length.
COUNTRY_NOT_FOUND  the country code to check against is unknown
WRONG_COUNTRY  the IBAN doesn't belong to the country
BAD_CHECKSUM  Bad IBAN checksum, i.e. the IBAN probably contains a typo.

Constructor & Destructor Documentation

IbanCheck const std::string &  filename = ""  ) 

Constructor that initalizes the mappings from a data file at filename.

If the file name argument is empty, then the compile-time datafile will be used. On Windows, the location of the datafile will be looked up in the registry.

If the file could not be found or is not successfully read, the mappings will be empty. Use error() to check for such an error condition.

filename If empty, then the compile-time file name will be used. Otherwise the relative or absolute full filename of the data file

~IbanCheck  ) 

Default destructor

Member Function Documentation

Result bic_position const std::string &  iban,
int &  start,
int &  end

Returns the position of the BIC inside the IBAN. The iban should be formally correct, if not an error Result might be returned.

iban [in] IBAN in transmission format
start [out] start of BIC (0-based index)
end [out] first position after BIC (0-based index)

Result check const std::string &  iban,
const std::string &  country = ""

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

iban IBAN in transmission format
country 2-character country code (ISO 3166)

Result check const Iban iban,
const std::string &  country = ""
const [inline]

Check the formal correctness of a given iban. This function checks if the prefix is known, if the length is correct for the prefix, if the checksum is ok and if the prefix is valid for a given country (if set).

iban Iban instance
country 2-character country code (ISO 3166)

bool error  )  const [inline]

false if the data file could not be opened and successfully read.

static const char* resultText Result  res  )  [static]

Convert Result code into an english message string.

if the value of res is an integer not inside the enum range, a special message will be returned.
res Result code from check() or bic_position()

bool selftest  ) 

uses the example data to test the check routines.

false if not successful

Friends And Related Function Documentation

std::istream& operator>> std::istream &  is,
Country &  c

std::istream& operator>> std::istream &  is,
Spec &  spec

The documentation for this class was generated from the following file:
Generated on Thu Nov 23 13:33:27 2006 for ktoblzcheck by  doxygen 1.4.1