| 1 |
/* |
| 2 |
* FeliCa2Money |
| 3 |
* |
| 4 |
* Copyright (C) 2001-2007 Takuya Murakami |
| 5 |
* |
| 6 |
* This program is free software; you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU General Public License as published by |
| 8 |
* the Free Software Foundation; either version 2 of the License, or |
| 9 |
* (at your option) any later version. |
| 10 |
* |
| 11 |
* This program is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with this program; if not, write to the Free Software |
| 18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 19 |
*/ |
| 20 |
|
| 21 |
#ifndef _CARD_H |
| 22 |
#define _CARD_H |
| 23 |
|
| 24 |
#include <stdio.h> |
| 25 |
#include "Transaction.h" |
| 26 |
|
| 27 |
/** |
| 28 |
@brief カード情報クラス |
| 29 |
*/ |
| 30 |
class CardBase { |
| 31 |
protected: |
| 32 |
AnsiString Ident; ///< カード名 (Ident) |
| 33 |
AnsiString CardName; ///< カード名 |
| 34 |
AnsiString CardId; ///< カード固有ID (IDm) |
| 35 |
|
| 36 |
public: |
| 37 |
/// カードIDを設定する |
| 38 |
inline void SetCardId(AnsiString &id) { |
| 39 |
CardId = id; |
| 40 |
} |
| 41 |
|
| 42 |
/// Ident を返す |
| 43 |
inline char *getIdent(void) { return Ident.c_str(); } |
| 44 |
|
| 45 |
/// カード名を返す |
| 46 |
inline char *getCardName(void) { return CardName.c_str(); } |
| 47 |
|
| 48 |
/// カード固有IDを返す |
| 49 |
inline char *getCardId(void) { return CardId.c_str(); } |
| 50 |
}; |
| 51 |
|
| 52 |
/** |
| 53 |
@brief カード情報クラス(トランザクション管理つき) |
| 54 |
*/ |
| 55 |
class Card : public CardBase |
| 56 |
{ |
| 57 |
protected: |
| 58 |
vector<Transaction*> list; ///< トランザクションリスト |
| 59 |
|
| 60 |
private: |
| 61 |
int prev_key, serial; ///< トランザクションID生成用 |
| 62 |
|
| 63 |
public: |
| 64 |
Card(); |
| 65 |
virtual ~Card(); |
| 66 |
|
| 67 |
/** |
| 68 |
@brief カードを読み込む |
| 69 |
|
| 70 |
カードを読み込み、カードIDを取得し、トランザクションリストを構成する。 |
| 71 |
*/ |
| 72 |
virtual int ReadCard(void) = 0; |
| 73 |
|
| 74 |
inline bool hasAnyTransaction(void) { return list.size() > 0 ? true : false; } |
| 75 |
|
| 76 |
inline vector<Transaction *>::iterator begin() { |
| 77 |
return list.begin(); |
| 78 |
} |
| 79 |
inline vector<Transaction *>::iterator end() { |
| 80 |
return list.end(); |
| 81 |
} |
| 82 |
|
| 83 |
/** トランザクション ID 生成 */ |
| 84 |
int GenerateTransactionId(int key); |
| 85 |
}; |
| 86 |
|
| 87 |
/** |
| 88 |
@brief カード情報クラス (ラインパーサ付き) |
| 89 |
*/ |
| 90 |
class CardWithLineParser : public Card |
| 91 |
{ |
| 92 |
public: |
| 93 |
int ParseLines(TStringList *lines, bool reverse = false); |
| 94 |
|
| 95 |
private: |
| 96 |
/** |
| 97 |
@brief トランザクションの生成 |
| 98 |
@param nrows[in] 入力カラム数 |
| 99 |
@param rows[in] 入力カラムの各文字列 |
| 100 |
@param err[out] エラーコード |
| 101 |
@return トランザクション |
| 102 |
|
| 103 |
SFCPeep の各出力行に対し、各行のカラムを分解したものが引数に渡される。 |
| 104 |
本関数は、これを解析し、トランザクションを生成して返す。 |
| 105 |
*/ |
| 106 |
virtual Transaction *GenerateTransaction(int nrows, AnsiString *rows, int *err) = 0; |
| 107 |
|
| 108 |
/** タブで区切られたトークンを切り出す */ |
| 109 |
char * getTabbedToken(char **pos); |
| 110 |
}; |
| 111 |
|
| 112 |
#endif // _CARD_H |