ktoblzcheck  1.52.0
ktoblzcheck.h
Go to the documentation of this file.
1 
31 #ifndef KTOBLZCHECK_H
32 #define KTOBLZCHECK_H
33 
34 /*
35  * This file is AUTO-GENERATED from ktoblzcheck.h.in! All changes
36  * here will be lost!
37  */
38 
42 #define KTOBLZCHECK_VERSION_MAJOR 1
43 
46 #define KTOBLZCHECK_VERSION_MINOR 52
47 
55 #ifdef __cplusplus
56 
57 #include <string>
58 #include <map>
59 #include <vector>
60 #include <ctime>
61 
72 public:
73 
90  typedef enum Result {
92  OK = 0,
95  UNKNOWN = 1,
98  ERROR = 2,
101  } Result;
102 
120  class Record {
121  public:
123  unsigned long bankId;
128  std::string method;
131  std::string bankName;
133  std::string location;
135  Record();
137  Record(unsigned long id, const std::string& method,
138  const std::string& name,
139  const std::string& loc);
141  Record(const char *id, const char *method,
142  const char *name,
143  const char *loc);
144  };
145 
161 
172  AccountNumberCheck(const std::string& filename);
173 
182 
183 
195  Result check(const std::string& bankId, const std::string& accountId,
196  const std::string& method="") const;
197 
213  const Record& findBank(const std::string& bankId) const;
214 
218  unsigned int bankCount() const;
219 
220 
228  std::time_t dataValidStartDate() const { return data_valid_start; }
229 
235  std::time_t dataValidEndDate() const { return data_valid_end; }
236 
243  bool isDataValidForDate(std::time_t date) const;
244 
253  bool isValidDataAvailable(std::time_t date) const;
254 
265  std::time_t closestValidData(std::time_t date) const;
266 
278  bool loadDataForDate(std::time_t date);
279 
286  std::string getFilenameClosestDateToday() const;
288 
297  void createIndex();
298 
302  static std::string resultToString(Result r);
303 
327  static const char* stringEncoding();
334  static const char* libraryVersion();
340  static std::string bankdata_dir();
342 
343 private:
345  typedef std::map<unsigned long, Record*> banklist_type;
347  banklist_type data;
348 
349 public:
350 #ifndef DOXYGEN_IGNORE
351 
352  typedef Result (*MethodFunc)(const int *account, int *weight);
354  typedef Result (*MethodFuncLong)(const int *account, int *weight,
355  const std::string& accountId, const std::string& bankId);
356 #endif // DOXYGEN_IGNORE
357 
358 private:
359  typedef std::map<std::string, MethodFunc> method_map_t;
360  method_map_t method_map;
361  typedef std::map<std::string, MethodFuncLong> method_map2_t;
362  method_map2_t method_map2;
363 
364  std::time_t data_valid_start;
365  std::time_t data_valid_end;
366  typedef std::pair<std::time_t, std::time_t> Daterange;
367  typedef std::pair<std::string, Daterange> FileDaterange;
368  typedef std::vector<FileDaterange> DatedFiles;
371  DatedFiles dated_files;
372 
374  void init_datafile_list();
375 
377  void populate_dated_files(const std::string& dirname, bool print_errormessages);
378 
381  const FileDaterange& find_closest_datafile(std::time_t date) const;
382 
385  void readDatedFile(const FileDaterange& filename);
386 
388  void deleteList();
391  void readFile(const std::string &filename);
392 
394  void initMethodMap();
395 };
396 
399 
400 extern "C" {
401 #else /* __cplusplus */
402 typedef int AccountNumberCheck_Result;
405 #endif /* __cplusplus */
406 
409 
425 
436  AccountNumberCheck *AccountNumberCheck_new_file(const char *filename);
437 
447 
469  const char *bankId,
470  const char *accountId);
471 
487  const char *bankId);
488 
492  unsigned int
494 
525  const char* AccountNumberCheck_stringEncoding();
532  const char* AccountNumberCheck_libraryVersion();
546  void
548 
556 
558  unsigned long
560 
563  const char *
565 
567  const char *
571 #ifdef __cplusplus
572 }
573 #endif /* __cplusplus */
574 
575 #endif /* KTOBLZCHECK_H */
576 
577 /*
578  * This file is AUTO-GENERATED from ktoblzcheck.h.in! All changes
579  * here will be lost!
580  */
Result
Definition: ktoblzcheck.h:90
AccountNumberCheck * AccountNumberCheck_new_file(const char *filename)
const char * AccountNumberCheck_stringEncoding()
unsigned long bankId
Definition: ktoblzcheck.h:123
unsigned long AccountNumberCheck_Record_bankId(const AccountNumberCheck_Record *a)
std::string location
Definition: ktoblzcheck.h:133
void AccountNumberCheck_Record_delete(AccountNumberCheck_Record *a)
bool isDataValidForDate(std::time_t date) const
German bank information database and account code verification.
Definition: ktoblzcheck.h:71
const char * AccountNumberCheck_libraryVersion()
static std::string bankdata_dir()
Result check(const std::string &bankId, const std::string &accountId, const std::string &method="") const
Definition: ktoblzcheck.h:95
AccountNumberCheck::Result AccountNumberCheck_Result
Definition: ktoblzcheck.h:397
Definition: ktoblzcheck.h:100
AccountNumberCheck_Record * AccountNumberCheck_Record_copy(const AccountNumberCheck_Record *a)
AccountNumberCheck * AccountNumberCheck_new()
const AccountNumberCheck_Record * AccountNumberCheck_findBank(const AccountNumberCheck *a, const char *bankId)
static const char * libraryVersion()
AccountNumberCheck_Result AccountNumberCheck_check(const AccountNumberCheck *a, const char *bankId, const char *accountId)
std::time_t closestValidData(std::time_t date) const
static const char * stringEncoding()
void AccountNumberCheck_createIndex(AccountNumberCheck *a)
std::string bankName
Definition: ktoblzcheck.h:131
bool loadDataForDate(std::time_t date)
static std::string resultToString(Result r)
const Record & findBank(const std::string &bankId) const
const char * AccountNumberCheck_Record_location(const AccountNumberCheck_Record *a)
void AccountNumberCheck_delete(AccountNumberCheck *a)
std::string method
Definition: ktoblzcheck.h:128
Definition: ktoblzcheck.h:92
std::time_t dataValidEndDate() const
Definition: ktoblzcheck.h:235
std::string getFilenameClosestDateToday() const
char * AccountNumberCheck_bankdata_dir()
unsigned int AccountNumberCheck_bankCount(const AccountNumberCheck *a)
unsigned int bankCount() const
const char * AccountNumberCheck_Record_bankName(const AccountNumberCheck_Record *a)
Available information about one bank.
Definition: ktoblzcheck.h:120
std::time_t dataValidStartDate() const
Definition: ktoblzcheck.h:228
AccountNumberCheck::Record AccountNumberCheck_Record
Definition: ktoblzcheck.h:398
Definition: ktoblzcheck.h:98
bool isValidDataAvailable(std::time_t date) const