|
-
May 16th, 2007, 03:30 PM
#1
Resources on extending STL classes needed
We need to accept, then move around, a large, highly specialized c structure within C++ code and then pass it back to some c library calls. We also need to populate, and de-populate the structure as well. This structure is an array and will only ever be populated from, or depopulated to, vectors. Never a list or some other container( or at least they are willing to enforce this).
I wrote some code, works great, but now the "powers that be" suggested I extend the vector class to hide all this dirty work from the coders who will need this structure. In other words, they would like to see a class that allows future coders to do something like:
================================
// Please don't syntax critique - just
// trying to communicate an idea
#include wrapper::to::hpp:with::c::structure
std::vector<void *> myVec;
myWrapper::cStructure gnarlyStructure.
// Get a structure full of data from a
// legacy c call
rc = myLegacyCRoutine(gnarlyStrucure)
if (0U == rc) {
myVec.populateVector(gnarlyStructure)
}
...go do stuff with vector like.....
for <iterator loop>
// Pass vector elements one at a time to
// another legacy c routine
callAnotherLegacyCRoutine((*i))
}
================================
Of course the reverse wil be done too, but you get the idea. It should be said I have only used the STL, never messed with it and have no significant experience with templates in general - only very simple templates where I needed flexibility in data typing. Nothing fancy that is for sure.
So my question is: I assume this has been done before but am having a hard time finding a succinct helpful document on template specialization/extension that seems relevant or is written with folks like me in mind. In short, does anyone here know of any good resources that would help me learn to do the above?
Thanks in advance,
NCNdian
C++ - on AIX
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|