00001
00027 #ifndef KTOBLZCHECK_H
00028 #define KTOBLZCHECK_H
00029
00033 #define KTOBLZCHECK_VERSION_MAJOR 1
00034
00037 #define KTOBLZCHECK_VERSION_MINOR 12
00038
00046 #ifdef __cplusplus
00047
00048 #include <string>
00049 #include <map>
00050
00060 class AccountNumberCheck {
00061 public:
00062
00079 typedef enum Result {
00081 OK = 0,
00084 UNKNOWN = 1,
00087 ERROR = 2,
00089 BANK_NOT_KNOWN = 3
00090 } Result;
00091
00109 class Record {
00110 public:
00112 unsigned long bankId;
00117 std::string method;
00120 std::string bankName;
00122 std::string location;
00124 Record();
00126 Record(unsigned long id, const std::string& method,
00127 const std::string& name,
00128 const std::string& loc);
00130 Record(const char *id, const char *method,
00131 const char *name,
00132 const char *loc);
00133 };
00134
00147 AccountNumberCheck();
00148
00159 AccountNumberCheck(const std::string& filename);
00160
00168 ~AccountNumberCheck();
00169
00170
00178 Result check(const std::string& bankId, const std::string& accountId,
00179 const std::string& method="") const;
00180
00196 const Record& findBank(const std::string& bankId) const;
00197
00201 unsigned int bankCount() const;
00202
00211 void createIndex();
00212
00216 static std::string resultToString(Result r);
00217
00241 static const char* stringEncoding();
00248 static const char* libraryVersion();
00250
00251 private:
00253 typedef std::map<unsigned long, Record*> banklist_type;
00255 banklist_type data;
00256
00257 public:
00258 #ifndef DOXYGEN_IGNORE
00259
00260 typedef Result (*MethodFunc)(int *account, int *weight);
00262 typedef Result (*MethodFuncLong)(int *account, int *weight,
00263 const std::string& accountId, const std::string& bankId);
00264 #endif // DOXYGEN_IGNORE
00265
00266 private:
00267 typedef std::map<std::string, MethodFunc> method_map_t;
00268 method_map_t method_map;
00269 typedef std::map<std::string, MethodFuncLong> method_map2_t;
00270 method_map2_t method_map2;
00271
00273 void deleteList();
00276 void readFile(const std::string &filename);
00277
00279 void initMethodMap();
00280 };
00281
00282 typedef AccountNumberCheck::Result AccountNumberCheck_Result;
00283 typedef AccountNumberCheck::Record AccountNumberCheck_Record;
00284
00285 extern "C" {
00286 #else
00287 typedef int AccountNumberCheck_Result;
00288 typedef struct AccountNumberCheck AccountNumberCheck;
00289 typedef struct AccountNumberCheck_Record AccountNumberCheck_Record;
00290 #endif
00291
00294
00307 AccountNumberCheck *AccountNumberCheck_new();
00308
00319 AccountNumberCheck *AccountNumberCheck_new_file(const char *filename);
00320
00329 void AccountNumberCheck_delete(AccountNumberCheck *a);
00330
00350 AccountNumberCheck_Result
00351 AccountNumberCheck_check(const AccountNumberCheck *a,
00352 const char *bankId,
00353 const char *accountId);
00354
00368 const AccountNumberCheck_Record *
00369 AccountNumberCheck_findBank(const AccountNumberCheck *a,
00370 const char *bankId);
00371
00375 unsigned int
00376 AccountNumberCheck_bankCount(const AccountNumberCheck *a);
00377
00382 void AccountNumberCheck_createIndex(AccountNumberCheck *a);
00408 const char* AccountNumberCheck_stringEncoding();
00415 const char* AccountNumberCheck_libraryVersion();
00421 void
00422 AccountNumberCheck_Record_delete(AccountNumberCheck_Record *a);
00423
00429 AccountNumberCheck_Record *
00430 AccountNumberCheck_Record_copy(const AccountNumberCheck_Record *a);
00431
00433 unsigned long
00434 AccountNumberCheck_Record_bankId(const AccountNumberCheck_Record *a);
00435
00438 const char *
00439 AccountNumberCheck_Record_bankName(const AccountNumberCheck_Record *a);
00440
00442 const char *
00443 AccountNumberCheck_Record_location(const AccountNumberCheck_Record *a);
00446 #ifdef __cplusplus
00447 }
00448 #endif
00449
00450 #endif
00451