V
Vincent RICHOMME
Hi,
I am developping a software to test smartcard and one of my class is
shown below :
class SCardCmd
{
public:
SCardCmd(const wxString& strCardName, const wxString& strCmdName):
m_strCardName(strCardName),
m_strCmdName(strCmdName),
m_CLA(0),
m_INS(0),
m_P1(0),
m_P2(0),
m_Lc(0),
m_Data(0),
m_Le(0),
m_Resp(0),
m_SW(0){}
const wxString GetCmdName() { return m_strCmdName; }
const wxString GetCardName() { return m_strCardName; }
private:
wxString m_strCardName;
wxString m_strCmdName;
u8 m_CLA;
u8 m_INS;
u8 m_P1;
u8 m_P2;
u8 m_Lc;
u8 m_Data;
u8 m_Le;
u8 m_Resp;
u16 m_SW;
};
then I want to display this information but my problem is to convert all
my values to string.
What is the better solution :
1)write a class with static methods to convert types :
ex
class StrConv
{
static std::string StrConv(u8 value) {...;}
static std::string StrConv(u16 value) {...;}
};
2)define object type something like :
struct U8
{
u8 value;
std::string toString();
};
or a template class that would allow me to write
Type<u8> mytype;
Type<u16> mytype2;
std::sring string = mytype.tostring();
Actually I am looking for intersting ways of doing this simple thing.
I am developping a software to test smartcard and one of my class is
shown below :
class SCardCmd
{
public:
SCardCmd(const wxString& strCardName, const wxString& strCmdName):
m_strCardName(strCardName),
m_strCmdName(strCmdName),
m_CLA(0),
m_INS(0),
m_P1(0),
m_P2(0),
m_Lc(0),
m_Data(0),
m_Le(0),
m_Resp(0),
m_SW(0){}
const wxString GetCmdName() { return m_strCmdName; }
const wxString GetCardName() { return m_strCardName; }
private:
wxString m_strCardName;
wxString m_strCmdName;
u8 m_CLA;
u8 m_INS;
u8 m_P1;
u8 m_P2;
u8 m_Lc;
u8 m_Data;
u8 m_Le;
u8 m_Resp;
u16 m_SW;
};
then I want to display this information but my problem is to convert all
my values to string.
What is the better solution :
1)write a class with static methods to convert types :
ex
class StrConv
{
static std::string StrConv(u8 value) {...;}
static std::string StrConv(u16 value) {...;}
};
2)define object type something like :
struct U8
{
u8 value;
std::string toString();
};
or a template class that would allow me to write
Type<u8> mytype;
Type<u16> mytype2;
std::sring string = mytype.tostring();
Actually I am looking for intersting ways of doing this simple thing.