472,362 Members | 1,800 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,362 software developers and data experts.

map and BYTE[]

Hi,

I am starting to play with with C++ and I have some questions.
I need to parse a XML file that describes a smart card file structure
and to initialize my data structure.
First I chose this structure :

A CCardObject has files (index by SFID) and each file has
records(indexed by RecNo) and each record can be splitted into
data(index by string).
class CDataIndex
{
public :
int m_nSFID; // FileID
int m_nRecNo; // RecNo
int m_nOffset; // Offset
int m_nSize; // DataLen
CDataIndex() { }
CDataIndex(int nSFID, int nRecNo, int nOffset, int size) {
m_nSFID = nSFID;
m_nRecNo = nRecNo;
m_nOffset = nOffset;
m_nSize = size;
}

CDataIndex(const CDataIndex& ob)
{
m_nSFID = ob.m_nSFID;
m_nRecNo = ob.m_nRecNo;
m_nOffset = ob.m_nOffset;
m_nSize = ob.m_nSize;
}

void operator = (const CDataIndex& ob)
{
m_nSFID = ob.m_nSFID;
m_nRecNo = ob.m_nRecNo;
m_nOffset = ob.m_nOffset;
m_nSize = ob.m_nSize;
}
};
class CCardRecord
{
public :
int m_nRecNo;
int m_nRecSize;
map<int, BYTE[29]> m_RecData;

CCardRecord() {}
CCardRecord( int nRecNo ) { m_nRecNo = nRecNo;}

int GetRecNo() { return m_nRecNo; }
int GetRecSize() { return m_nRecSize; }
int GetData(int nOffset, int nSize);
};

class CCardFile
{
public :
int m_nSFID;
map<int, CCardRecord> m_records;

CCardFile() {}
CCardFile( int nSFID ) { m_nSFID = nSFID;}

};

class CCardObj
{
public:
CCardObj();
virtual ~CCardObj();
BOOL LoadCardMapping();
BOOL ReadMappingFile(CXMLReader &xml);
void XMLCardFile(CXMLReader &xml);
void XMLCardRecord( CXMLReader &xml );
void XMLCardData( CXMLReader &xml );

CString m_csTag;
int m_nSFID;
int m_nRecNo;
int m_nRecSize;
int m_nDataOffset;
int m_nDataType;
int m_nDataSize;
CString m_csName;
BYTE m_Data[29];

// CardReader Object - LOW LEVEL API
CCardReader* m_pCardReader;

// Associate stringwith SFID, RecNo, Offset and Size
map<CString, CDataIndex> m_dataIndex;

// File collection index by Short File Id (SFID)
map<int, CCardFile> m_FileIndex;
};

When I parse the XML file and I find the <CardRecord> tag I get its
attributes and I would like to add a new array of byte.
How can I do that ?

void CCardObj::XMLCardRecord( CXMLReader &xml )
{
xml.getAttribute( "index", m_nRecNo ); // Get record No
xml.getAttribute( "size", m_nRecSize );// Get record size

m_FileIndex[ m_nSFID ].m_records[ m_nRecNo ] = ????

xml.intoTag();
while ( xml.nextTag( m_csTag ) ){
if (m_csTag == "CardData"){
XMLCardData( xml );
}
}
xml.outofTag();
}
Jul 22 '05 #1
7 2675

"Vince" <vs**@caramail.com> wrote in message
news:41***********************@news.free.fr...
Hi,

When I parse the XML file and I find the <CardRecord> tag I get its
attributes and I would like to add a new array of byte.
How can I do that ?


unsigned char array = new char[how_many_chars];
/* work with the array */
delete[] array;
Jul 22 '05 #2
On Mon, 17 Jan 2005 22:42:15 +0000, Mike Wahler wrote:
ITYM:
unsigned char* array = new char[how_many_chars];
/* work with the array */
delete[] array;


Jul 22 '05 #3
Mike Wahler wrote:
"Vince" <vs**@caramail.com> wrote in message
news:41***********************@news.free.fr...
Hi,

When I parse the XML file and I find the <CardRecord> tag I get its
attributes and I would like to add a new array of byte.
How can I do that ?

unsigned char array = new char[how_many_chars];


unsigned char *array = new char[how_many_chars];
/* work with the array */
delete[] array;


V
Jul 22 '05 #4

"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:wo*******************@newsread1.mlpsca01.us.t o.verio.net...
Mike Wahler wrote:
"Vince" <vs**@caramail.com> wrote in message
news:41***********************@news.free.fr...
Hi,

When I parse the XML file and I find the <CardRecord> tag I get its
attributes and I would like to add a new array of byte.
How can I do that ?

unsigned char array = new char[how_many_chars];


unsigned char *array = new char[how_many_chars];


Dang! I think I'll go do some laundry or something. :-)

Thanks for the correction.

-Mike
Jul 22 '05 #5
Victor Bazarov wrote:
Mike Wahler wrote:
"Vince" <vs**@caramail.com> wrote in message
news:41***********************@news.free.fr...

unsigned char array = new char[how_many_chars];


unsigned char *array = new char[how_many_chars];

^^^^^^^^^^^^^ ^^^^

Those aren't the same type.

Sjoerd

Jul 22 '05 #6

"Sjoerd A. Schreuder" <sa**********@wanadoo.nl> wrote in message
news:41***********************@news.wanadoo.nl...
Victor Bazarov wrote:
Mike Wahler wrote:
"Vince" <vs**@caramail.com> wrote in message
news:41***********************@news.free.fr...

unsigned char array = new char[how_many_chars];


unsigned char *array = new char[how_many_chars];

^^^^^^^^^^^^^ ^^^^

Those aren't the same type.


Hmm, yes I missed that, as well as those who corrected my
other error.

One more try:

unsigned char *array = new unsigned char[how_many_chars];

-Mike
Jul 22 '05 #7
Vince wrote:

class CCardRecord
{
public :
int m_nRecNo;
int m_nRecSize;
map<int, BYTE[29]> m_RecData;


You cannot have an array as the value type for a standard
library container. I suggest you replace BYTE[29] with
a std::vector<BYTE> . (That also avoids having to do
the 'new' statement that has been problematic in this thread).

Jul 22 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: David Cook | last post by:
Java's InetAddress class has some methods that use a byte-array to hold what it describes as a 'raw IP address'. So, I assume that they mean an array like: byte ba = new byte; would hold an...
8
by: intrepid_dw | last post by:
Hello, all. I've created a C# dll that contains, among other things, two functions dealing with byte arrays. The first is a function that returns a byte array, and the other is intended to...
6
by: Dennis | last post by:
I was trying to determine the fastest way to build a byte array from components where the size of the individual components varied depending on the user's input. I tried three classes I built: (1)...
8
by: moondaddy | last post by:
I need to convert a byte array to a string and pass it as a parameter in a URL and then convert it back to the original byte array. However, its getting scrambled in the conversion. In short,...
16
by: johannblake | last post by:
I have a variable that is 1 bit wide. I also have a variable that is a byte. I want to shift the bits out of the byte into the bit variable (one at a time) but am not sure how to do this or whether...
4
by: Frederick Gotham | last post by:
What do you think of the following code for setting and retrieving the value of bytes in an unsigned integer? The least significant bit has index 0, then the next least significant bit has index 1,...
1
by: MimiMi | last post by:
I'm trying to decrypt a byte array in java that was encrypted in C#. I don't get any error messages, just a result that's completely not what I was hoping for. I think I am using the same type of...
2
by: MimiMi | last post by:
I'm trying to decrypt a byte array in java that was encrypted in C#. I don't get any error messages, just a result that's completely not what I was hoping for. I think I am using the same type of...
10
by: Scott Townsend | last post by:
So I need to talk to a devices that expects all of the bits and bytes I sent it to be in specific places (not yet 100% defined). I wanted to create a structure/class with all of the data in it...
2
by: O.B. | last post by:
When using Marshal to copy data from a byte array to the structure below, only the first byte of the "other" array is getting copied from the original byte array. What do I need to specify to get...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
1
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.