📄 lxbankcodedata.cc
字号:
// ****************************************************************************// // LxBank - home-banking for Linux using the HBCI standard// // Author: Franz Zimmermann 83043 Bad Aibling// // Copyright (C) 2002-2003 Franz Zimmermann - arafang@users.sourceforge.net// // This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.// // This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.// // You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.// // ***************************************************************************//// $Name: $//// $State: Exp $//// $Log: LxBankCodeData.cc,v $// Revision 1.3 2003/05/08 02:39:53 arafang// Error checking of money transfer improved. Use library ktoblzcheck to validate account id's.//// Revision 1.2 2003/05/03 16:24:04 arafang// New class LxBankSelectionList. Used in LxRemittanceWorkDialog to present information about all banks of one bank code id.//// Revision 1.1 2003/05/01 14:06:19 arafang// Format of bank code data file changed: was blz.txt - ascii, new blz.bin - binary////#ifdef HAVE_CONFIG_H#include <config.h>#endif#include "LxBankCodeData.h"#include <sstream>LxBankCodeData::LxBankCodeData() : state(Canceled), bankCode(0), sqeNo(0), successionSqeNo(0), cancelDate(7999, 1, 1){}LxBankCodeData::LxBankCodeData (ifstream &inp){ short yearDel = 7999, monthDel = 1, dayDel = 1; char len; char buf[128]; inp.read ((char *)&bankCode, sizeof(int)); inp.read ((char *)&sqeNo, sizeof(int)); inp.read ((char *)&state, sizeof(int)); if ( state == Canceled ){ inp.read ((char *)&yearDel, sizeof(short)); inp.read ((char *)&monthDel, sizeof(short)); inp.read ((char *)&dayDel, sizeof(short)); inp.read ((char *)&successionSqeNo, sizeof(int)); } cancelDate.setYMD (yearDel, monthDel, dayDel); inp.read (&len, sizeof(char)); inp.read (buf, len); buf[len] = '\0'; bankCodeStr = buf; inp.read (&len, sizeof(char)); inp.read (buf, len); buf[len] = '\0'; name = buf; inp.read (&len, sizeof(char)); inp.read (buf, len); buf[len] = '\0'; zipCode = buf; inp.read (&len, sizeof(char)); inp.read (buf, len); buf[len] = '\0'; city = buf; inp.read (&len, sizeof(char)); inp.read (buf, len); buf[len] = '\0'; btxName = buf; inp.read (&len, sizeof(char)); inp.read (buf, len); buf[len] = '\0'; pzMethode = buf;}LxBankCodeData::LxBankCodeData(const string &blz, const string &sqeno, const string &nam, const string &zipcode, const string &location, const string &btxname, const string &method, const string &canceldate, const string &sucsqeno) : state(Valid), bankCodeStr(blz), bankCode(0), sqeNo(0), successionSqeNo(0), name(nam), zipCode(zipcode), city(location), btxName(btxname), pzMethode(method), cancelDate(7999, 1, 1){ int yearDel, monthDel, dayDel; istringstream buf(blz); buf >> bankCode; if ( buf.fail() ){ bankCode = 0; buf.clear(); } bankCodeStr.insert(6, " "); bankCodeStr.insert(3, " "); buf.str (sqeno); buf >> sqeNo; if ( buf.fail() ){ sqeNo = 0; buf.clear(); } if ( !canceldate.empty() ){ buf.str (sucsqeno); buf >> successionSqeNo; if ( buf.fail() ){ successionSqeNo = 0; buf.clear(); } string y(canceldate.substr(0,2)); string m(canceldate.substr(2)); buf.str (y); if ( buf >> yearDel ){ yearDel += 2000; buf.str (m); if ( buf >> monthDel ){ dayDel = 1; if ( QDate::isValid(yearDel, monthDel, dayDel) ){ cancelDate.setYMD (yearDel, monthDel, dayDel); while ( cancelDate.dayOfWeek () != Saturday ){ ++dayDel; cancelDate.setYMD (yearDel, monthDel, dayDel); } dayDel += 2; cancelDate.setYMD (yearDel, monthDel, dayDel); state = Canceled; }else{ cancelDate.setYMD (7999, 1, 1); successionSqeNo = 0; } }else{ cancelDate.setYMD (7999, 1, 1); successionSqeNo = 0; } }else{ cancelDate.setYMD (7999, 1, 1); successionSqeNo = 0; } }else{ cancelDate.setYMD (7999, 1, 1); successionSqeNo = 0; }}LxBankCodeData::LxBankCodeData(const string &txtLine) : state(Valid), bankCode(0), sqeNo(0), successionSqeNo(0), cancelDate(7999, 1, 1){ char tab = '\t'; string tmp; string::size_type idx1, idx2; int yearDel, monthDel, dayDel; istringstream buf; idx1 = 0; idx2 = txtLine.find ( tab, idx1 ); bankCodeStr.assign (txtLine, idx1, idx2-idx1); buf.str (bankCodeStr); buf >> bankCode; if ( buf.fail() ){ bankCode = 0; buf.clear(); } bankCodeStr.insert(6, " "); bankCodeStr.insert(3, " "); idx1 = idx2+1; idx2 = txtLine.find ( tab, idx1 ); if ( idx2-idx1 ){ string y, m; y.assign (txtLine, idx1,2); m.assign (txtLine, idx1+2, 2); buf.str (y); if ( buf >> yearDel ){ yearDel += 2000; buf.str (m); if ( buf >> monthDel ){ dayDel = 1; if ( QDate::isValid(yearDel, monthDel, dayDel) ){ cancelDate.setYMD (yearDel, monthDel, dayDel); while ( cancelDate.dayOfWeek () != Saturday ){ ++dayDel; cancelDate.setYMD (yearDel, monthDel, dayDel); } dayDel += 2; cancelDate.setYMD (yearDel, monthDel, dayDel); state = Canceled; }else{ cancelDate.setYMD (7999, 1, 1); successionSqeNo = 0; idx1 = idx2+1; idx2 = txtLine.find ( tab, idx1 ); } }else{ cancelDate.setYMD (7999, 1, 1); successionSqeNo = 0; idx1 = idx2+1; idx2 = txtLine.find ( tab, idx1 ); } }else{ cancelDate.setYMD (7999, 1, 1); successionSqeNo = 0; idx1 = idx2+1; idx2 = txtLine.find ( tab, idx1 ); } idx1 = idx2+1; idx2 = txtLine.find ( tab, idx1 ); tmp.assign(txtLine, idx1, idx2-idx1); buf.str (tmp); buf >> successionSqeNo; if ( buf.fail() ){ successionSqeNo = 0; buf.clear(); } }else{ cancelDate.setYMD (7999, 1, 1); successionSqeNo = 0; idx1 = idx2+1; idx2 = txtLine.find ( tab, idx1 ); } idx1 = idx2+1; idx2 = txtLine.find ( tab, idx1 ); name.assign (txtLine, idx1, idx2-idx1); idx1 = idx2+1; idx2 = txtLine.find ( tab, idx1 ); zipCode.assign (txtLine, idx1, idx2-idx1); idx1 = idx2+1; idx2 = txtLine.find ( tab, idx1 ); city.assign (txtLine, idx1, idx2-idx1); idx1 = idx2+1; idx2 = txtLine.find ( tab, idx1 ); btxName.assign (txtLine, idx1, idx2-idx1); idx1 = idx2+1; idx2 = txtLine.find ( tab, idx1 ); pzMethode.assign (txtLine, idx1, idx2-idx1); idx1 = idx2+1; idx2 = txtLine.size (); tmp.assign(txtLine, idx1, idx2-idx1); buf.str (tmp); buf >> sqeNo; if ( buf.fail() ){ sqeNo = 0; buf.clear(); } }LxBankCodeData::LxBankCodeData(const LxBankCodeData &bcd) : state(bcd.state), bankCodeStr(bcd.bankCodeStr), bankCode(bcd.bankCode), sqeNo(bcd.sqeNo), successionSqeNo(bcd.successionSqeNo), name(bcd.name), zipCode(bcd.zipCode), city(bcd.city), btxName(bcd.btxName), pzMethode(bcd.pzMethode), cancelDate(bcd.cancelDate){}LxBankCodeData::~LxBankCodeData( ){}const LxBankCodeData & LxBankCodeData::operator=(const LxBankCodeData &bcd){ if (this == &bcd) return *this; state = bcd.state; bankCodeStr = bcd.bankCodeStr; bankCode = bcd.bankCode; sqeNo = bcd.sqeNo; successionSqeNo = bcd.successionSqeNo; name = bcd.name; zipCode = bcd.zipCode; city = bcd.city; btxName = bcd.btxName; pzMethode = bcd.pzMethode; cancelDate = bcd.cancelDate; return *this;}ostream& LxBankCodeData::dump (ostream &out) const{ out << "\nBLZ: " << bankCode << "\nbankCodeStr " << bankCodeStr << "\nLfd Nr " << sqeNo << "\nState " << ((state == Valid) ? "Valid" : "Canceled") << "\nBezeichnung: " << name << "\nPLZ: " << zipCode << "\nOrt: " << city << "\nBTX-Bezeichnung: " << btxName << "\nPr黤ziffer: " << pzMethode << "\nL鰏chungsdatum: " << cancelDate.toString () << "\nHinweis: " << successionSqeNo << endl; return out;}void LxBankCodeData::binaerDump (ofstream &out){ char len; short yearDel = cancelDate.year(); short monthDel = cancelDate.month(); short dayDel = cancelDate.day(); out.write ((char *)&bankCode, sizeof(int)); out.write ((char *)&sqeNo, sizeof(int)); out.write ((char *)&state, sizeof(int)); if ( state == Canceled ){ out.write ((char *)&yearDel, sizeof(short)); out.write ((char *)&monthDel, sizeof(short)); out.write ((char *)&dayDel, sizeof(short)); out.write ((char *)&successionSqeNo, sizeof(int)); } len = bankCodeStr.size(); out.write (&len, sizeof(char)); out.write (bankCodeStr.c_str(), len); len = name.size(); out.write (&len, sizeof(char)); out.write (name.c_str(), len); len = zipCode.size(); out.write (&len, sizeof(char)); out.write (zipCode.c_str(), len); len = city.size(); out.write (&len, sizeof(char)); out.write (city.c_str(), len); len = btxName.size(); out.write (&len, sizeof(char)); out.write (btxName.c_str(), len); len = pzMethode.size(); out.write (&len, sizeof(char)); out.write (pzMethode.c_str(), len);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -