ktoblzcheck  1.52.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
AccountNumberCheck Class Reference

German bank information database and account code verification. More...

#include <ktoblzcheck.h>

Classes

class  Record
 Available information about one bank. More...
 

Public Types

enum  Result { OK = 0, UNKNOWN = 1, ERROR = 2, BANK_NOT_KNOWN = 3 }
 
typedef enum AccountNumberCheck::Result Result
 

Public Member Functions

 AccountNumberCheck ()
 
 AccountNumberCheck (const std::string &filename)
 
 ~AccountNumberCheck ()
 
Result check (const std::string &bankId, const std::string &accountId, const std::string &method="") const
 
const RecordfindBank (const std::string &bankId) const
 
unsigned int bankCount () const
 
void createIndex ()
 
Bankdata validity date range
std::time_t dataValidStartDate () const
 
std::time_t dataValidEndDate () const
 
bool isDataValidForDate (std::time_t date) const
 
bool isValidDataAvailable (std::time_t date) const
 
std::time_t closestValidData (std::time_t date) const
 
bool loadDataForDate (std::time_t date)
 
std::string getFilenameClosestDateToday () const
 

Static Public Member Functions

static std::string resultToString (Result r)
 
Ktoblzcheck library information
static const char * stringEncoding ()
 
static const char * libraryVersion ()
 
static std::string bankdata_dir ()
 

Detailed Description

German bank information database and account code verification.

Class that stores a list of known German banks, returns banks with given bank codes, and validates account numbers accordings to the bank's known validation/checking algorithms.

The list of known banks is read from the configuration file when this object is constructed.

Member Typedef Documentation

◆ Result

Gives information about the success of the check

  • OK: everything is ok, account and bank match

  • UNKNOWN: Could not be validated because the validation algorithm is unknown/unimplemented in ktoblzcheck

  • ERROR: The result of the validation algorithm is that the account and bank probably do not match

  • BANK_NOT_KNOWN: No bank with the specified bankid could be found

Member Enumeration Documentation

◆ Result

enum Result

Gives information about the success of the check

  • OK: everything is ok, account and bank match

  • UNKNOWN: Could not be validated because the validation algorithm is unknown/unimplemented in ktoblzcheck

  • ERROR: The result of the validation algorithm is that the account and bank probably do not match

  • BANK_NOT_KNOWN: No bank with the specified bankid could be found

Enumerator
OK 

Everything is ok: account and bank match

UNKNOWN 

Could not be validated because the validation algorithm is unknown/unimplemented in ktoblzcheck

ERROR 

The result of the validation algorithm is that the account and bank probably do not match

BANK_NOT_KNOWN 

No bank with the specified bankid could be found

Constructor & Destructor Documentation

◆ AccountNumberCheck() [1/2]

Default Constructor.

This constructor also initializes the bank-database. The bank data is obtained from several files which are located in a directory looked up at run-time (with a fallback check for a compile-time path). Default is $prefix/share/ktoblzcheck (set in configure.in) where default for $prefix is /usr/local.

Inside the data directory, all bankdata files with a date in the filename are processed, according to the three-month validity periods, because each bankdata file is valid for three months. See README for a more detailed explanation.

◆ AccountNumberCheck() [2/2]

AccountNumberCheck ( const std::string &  filename)

Constructor that initialize the bank-database from a data file at filename.

If the file could not be found, then the resulting AccountNumberCheck object simply has an empty bank database and a message is printed to stderr.

Parameters
filenameThe absolute location of the KTOBLZCheck-database

◆ ~AccountNumberCheck()

Destructor. All entries of the bank database are deleted as well.

Note
This destructor also destroys any references that have been returned by findBank()! You have to make sure not to use these references any longer after this destructor has been called.

Member Function Documentation

◆ bankCount()

unsigned int bankCount ( ) const

Returns the number of bank-records currently loaded.

◆ bankdata_dir()

static std::string bankdata_dir ( )
static

Returns the directory where the bankdata file is stored.

This function was introduced in ktoblzcheck-1.13.

◆ check()

Result check ( const std::string &  bankId,
const std::string &  accountId,
const std::string &  method = "" 
) const

Check if bankId and accountId form a valid combination.

Parameters
bankIdThe bank code (BLZ) of the bank to test
accountIdThe account id to check
methodIf not set (default), look up the Record for the given bankId and use the method specified there for the check. If set, no look-up is performed, the specified check-method is used directly, and the database of BLZ and methods is not used.

◆ closestValidData()

std::time_t closestValidData ( std::time_t  date) const

Returns the date closest to the specified date at which valid bankdata is available. If bankdata is available on the given date (i.e. isDataAvaliable() is true), returns the given date unchanged.

Whether this file has already been loaded has to be queried separately through isDataValidForDate().

This function was introduced in ktoblzcheck-1.15.

◆ createIndex()

void createIndex ( )

Generates an index over the bankIds. This is supposed to speed up the checking if you want to check 100s of combination (batch-processing)

Currently this does nothing. The bank list structure (std::map) does not need this anyway.

◆ dataValidEndDate()

std::time_t dataValidEndDate ( ) const
inline

Returns the end date at which the currently loaded bankdata is valid, or 0 if the validity date is unknown.

This function was introduced in ktoblzcheck-1.15.

◆ dataValidStartDate()

std::time_t dataValidStartDate ( ) const
inline

Returns the starting date at which the currently loaded bankdata is valid, or 0 if the validity date is unknown.

This function was introduced in ktoblzcheck-1.15.

◆ findBank()

const Record& findBank ( const std::string &  bankId) const

Find the info-record for a bank specified by bankId or otherwise throw an exception.

Note
The returned objects are still owned by this object! You have to make sure not to use the returned references after the destructor ~AccountNumberCheck() has been called.
Exceptions
intif a bank with bank code bankId (german BLZ) could not be found in the database
Returns
A reference to the resulting bank object. The returned reference is still owned by this AccountNumberObject and it becomes invalid if the AcccountNumberObject is being deleted.

◆ getFilenameClosestDateToday()

std::string getFilenameClosestDateToday ( ) const

Looks up the bank data file name that is closest to today's date and returns that file name. This is also the bank data file that is loaded by default.

Returns
The file name as a string, with full absolute path. If no file was found at all, an empty string is returned.

◆ isDataValidForDate()

bool isDataValidForDate ( std::time_t  date) const

Returns true if the currently loaded bankdata file is valid for the given date. Returns false if the loaded data is valid for a different time range, or if its validity date range is unknown.

This function was introduced in ktoblzcheck-1.15.

◆ isValidDataAvailable()

bool isValidDataAvailable ( std::time_t  date) const

Returns true if a bankdata file valid for the given date is available, otherwise false.

Whether this file has already been loaded has to be queried separately through isDataValidForDate().

This function was introduced in ktoblzcheck-1.15.

◆ libraryVersion()

static const char* libraryVersion ( )
static

Returns the value of ktoblzcheck's configuration variable VERSION as a string, which can be "1.6" or something similar.

This function was introduced in ktoblzcheck-1.7.

◆ loadDataForDate()

bool loadDataForDate ( std::time_t  date)

Loads the bankdata valid for the given date, or bankdata whose validity date is closest to the given date. Returns true if the loaded bankdata is valid for the given date, otherwise false.

(Note: In both cases a new file may or may not have been loaded; this depends on the previously loaded data file. But after this function has been called, it is guaranteed that the closest available bankdata has been loaded by now.)

This function was introduced in ktoblzcheck-1.15.

◆ resultToString()

static std::string resultToString ( Result  r)
static

Returns a meaningful english string explaining the result value

◆ stringEncoding()

static const char* stringEncoding ( )
static

Returns the character encoding that is used when strings are returned. So far this has been "ISO-8859-15" (up to and including version ktoblzcheck-1.15) but at some point in the future it might change into "UTF-8".

To obtain the encoding string in your application in a form that is backward-compatible to all ktoblzcheck-versions, do the following:

    const char *ktoblzcheck_encoding = 
#ifdef KTOBLZCHECK_VERSION_MAJOR
      AccountNumberCheck_stringEncoding()
#else
      "ISO-8859-15"
#endif
      ;
 This function was introduced in ktoblzcheck-1.7.

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