V
Vince
Hi,
I am working on a project involving contactless card and to read or
write into these cards we need some parameters (Key to use for instance).
My problem is to store these parameters in the most efficient way.
I was thinking first in a c manner as a struct array like this :
struct TFileInfo
{
int nSFID, // Short file ID
int nLID, // Long File ID
int nKey
};
// not sure of the syntax, it's been a long time I haven't used it
TFileInfo fileInfo[] =
{
{ 0x17, 0x3127, 0x0E },
{ 0x18, 0x3128, 0x08 },
};
and after I need to be able to get the values associated to nSFID.
ex :
CMyClass::GetKey(int nSFID)
{
for (int i = 0; i < nItems; i++){
if (fileInfo.nSFID == nSFID)
return fileInfo.nKey
}
}
Or another solution would be to use a std::map<int, TFileInFo>
but I am concerned about performance. Besides I don't find the
initialization very elegant
std::map<int, TFileInfo> fileInfo;
TFileInfo stFileInfo;
stFileInfo.nSFID = 0x17;
stFileInfo.nLID = 0x3127;
stFileInfo.nKey = 0x0E;
fileInfo[0x17] = stFileInfo;
stFileInfo.nSFID = 0x18;
stFileInfo.nLID = 0x3128;
stFileInfo.nKey = 0x0E;
fileInfo[0x17] = stFileInfo;
I must add that my numbers of items will be 20 max.
If someone could inform me about this performance problem...
I am working on a project involving contactless card and to read or
write into these cards we need some parameters (Key to use for instance).
My problem is to store these parameters in the most efficient way.
I was thinking first in a c manner as a struct array like this :
struct TFileInfo
{
int nSFID, // Short file ID
int nLID, // Long File ID
int nKey
};
// not sure of the syntax, it's been a long time I haven't used it
TFileInfo fileInfo[] =
{
{ 0x17, 0x3127, 0x0E },
{ 0x18, 0x3128, 0x08 },
};
and after I need to be able to get the values associated to nSFID.
ex :
CMyClass::GetKey(int nSFID)
{
for (int i = 0; i < nItems; i++){
if (fileInfo.nSFID == nSFID)
return fileInfo.nKey
}
}
Or another solution would be to use a std::map<int, TFileInFo>
but I am concerned about performance. Besides I don't find the
initialization very elegant
std::map<int, TFileInfo> fileInfo;
TFileInfo stFileInfo;
stFileInfo.nSFID = 0x17;
stFileInfo.nLID = 0x3127;
stFileInfo.nKey = 0x0E;
fileInfo[0x17] = stFileInfo;
stFileInfo.nSFID = 0x18;
stFileInfo.nLID = 0x3128;
stFileInfo.nKey = 0x0E;
fileInfo[0x17] = stFileInfo;
I must add that my numbers of items will be 20 max.
If someone could inform me about this performance problem...