Re: How to encode STL vector
Re: How to encode STL vector
- Subject: Re: How to encode STL vector
- From: "Clark S. Cox III" <email@hidden>
- Date: Thu, 7 Nov 2002 08:20:04 -0500
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Wednesday, Nov 6, 2002, at 17:42 US/Eastern, Arthur Clemens wrote:
Thanks, this works. Only the archivers really don't like a vector with
no elements, so as a workaround I first tried to use conditionals: if
(size > 0)
but that gives another error when reading back in: "byte expected".
So I now always keep one element in the vector array. It's a bit
annoying.
Arthur Clemens
Where exactly did you put the if statement? Try this:
//Encode
const unsigned size = myVector.size();
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &size];
if(size) {
[aCoder encodeArrayOfObjCType: @encode(unsigned) count: size at:
&myVector.front()];
}
//Decode
unsigned size;
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &size];
myVector.resize(size);
if(size) {
[aCoder decodeArrayOfObjCType: @encode(unsigned) count: size at:
&myVector.front()];
}
- --
http://homepage.mac.com/clarkcox3/
email@hidden
Clark S. Cox, III
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (Darwin)
iEYEARECAAYFAj3KaI0ACgkQd6STocYT1xWQRACfQtPwNSRnB5Uj3Gjh2kZEIVrm
98kAoJ/nmCNJgk2YjKnGBYdHtpmd0Ek2
=l60m
-----END PGP SIGNATURE-----
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.