This probably me being extremely tired, but I can't figure out how to copy part of a vector into a new vector.
What I am trying to do, is find inside an std::vector (where char is typedefed as byte) where the starting tag is, and copy the data from there, up to the closing tag (which is at the end, and is 7 chars long).
typedef char byte;
std::vector<byte> imagebytes;
std::vector<byte> bytearray_;
for ( unsigned int i = 0; i < bytearray_.size(); i++ )
{
if ( (i + 5) < (bytearray_.size()-7) )
{
std::string temp ( &bytearray_[i], 5 );
if ( temp == "<IMG>" )
{
// This is what isn't working
std::copy( std::vector<byte>::iterator( bytearray_.begin() + i + 5 ),
std::vector<byte>::iterator( bytearray_.end() - 7 )
std::back_inserter( imagebytes) );
}
}
}
I know this loop looks horrible, I am open to suggestions! Please note, bytearray_ contains raw bytes of images, or audio files. Hence the vector.
Aucun commentaire:
Enregistrer un commentaire