Re: bit field serialization
Hi GreG,
I will add one comment that may or may not be necessary.
( I got nothing else to do.)
I still cant stand using bool and opt for using BOOL instead.
It gets me everytime, so I use it very sparingly.
When storing a bool, it won't work. It has to be cast to a BOOL or char.
That may or may not be what you are doing, but it is just something to =
keep in mind when archivng.
HTH,
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message =
news:ovng935occndpti5rs6lu6q76dpbjm2sc7@4ax.com...
Bit field is not a primitive type. Therefore, it can only be =
serialized by first
converting it to a serializable type (for output) and froma =
serializable type (for input).
It probably would be easier to guess what you intended if you showed =
an example of the
structure you are trying to serialize.
Also note that in most cases, storing flags in bit fields is not often =
a valuable thing to
do unless there are compelling reasons; it is not something you =
undertake casually. The
usual reason is that some external data structure (such as a message) =
has specifications
at this level. But without seeing some idea of what you are actually =
trying to serialize,
it is hard to make suggestions.
(And, as others have pointed out, using the MFC binary serialization =
is rarely a good
idea, and a lot of us prefer to avoid it entirely and use XML)
joe
On Fri, 13 Jul 2007 19:00:01 -0700, Greg G =
<GregG@discussions.microsoft.com> wrote:
Where can I find example code showing serialization of a bit field in =
MFC?
I built a bit field class derived from CObject and see in the VC++
documentation how to IMPLEMENT_SERIAL. However, I can not seem to =
figure out
how to write the
void CMyBitField::Serialize( CArchive& archive)
{
if( archive.IsStroring() )
{
archive << <unsigned int> bits << etc. ?????
}
else
{
archive >> ????
)
}
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm