C++ Practice

M

mc

Hi all,

I've a long experience with C but am just getting up to speed with C++, so
please bear with me if that's obvious.

I've got a class that parses a data file and creates a vector of AESKey, a
vector of Package, GPS data and more. This data is not sequential in the
file so the parsing in the file is cumbersome and out of my control
(provided by customer).

Now, I've got another class that is build based of AESKey objects.
Currently, the constructor is as follows:
CryptoEngine(int numKeys, AESKey * keys);

To make it more elegant -or so I think, I'm thinking of passing a vector of
AESKey to make it like this:
CryptoEngine(std::vector<AESKey>& keys);

so that the CryptoEngine "owns" this vector (it's anyways the only object
using it). This would be best as when the object is deleted, all the data
it needs is deleted as well.

The problem is that this vector of AESKey can be huge (100 of Mb), don't ask
me why, that's how our application is. :-( So when I'd be copying the
argument being passed to the CryptoEngine, the amount of RAM needed for the
argument is duplicated by the copy constructor and there's basically a
"memcpy". Is there a way to work this around in a C++ way? The obvious
would be to parse the file in the CryptoEngine but it's a no-can-do as this
file contains data (non sequential) for mutiple types of objects.

Thank you in advance.

Best regards,


Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,175
Messages
2,570,945
Members
47,492
Latest member
gabbywilliam

Latest Threads

Top