Re: Advice needed binary configuration files
- From: "Computer" <chollan2@xxxxxxxxxx>
- Date: Fri, 28 Oct 2005 17:48:26 -0700
Bored, typing and drunk. Just typing for something to do. You can disregard
this message or use it. It is up to you.
Thinking about binary data....
A file is nothing more than a long number of bytes. Bytes is 8 bits and
equal to a character.
So, you have some file with x number of bytes.
For example: 12345678901234567890.
Well, we don't really know what that means, but you do, since you stored it.
To read a binary file, we have to know what values are stored and the order
they are stored in.
Say we stored long, int, char, double, string.
Well, a long is, let's just say 4 bytes. So, you would read in 4 Characters.
File.Read(buffer, 4); or the equivalent fstream function.
Then, convert the character buffer to the long type.
long l = atol(buffer);
And so on and so on till you get to the string.
Strings can be any length, whereas types have a fixed length.
What to do?
I suppose there is a number of options, like adding a 0 to the end of the
string, or some not printable character?
or, perphaps putting the length of the string at the beginning of the
string. It's a matter of choice.
Regards,
"Computer" <chollan2@xxxxxxxxxx> wrote in message
news:e8SDaGB3FHA.2196@xxxxxxxxxxxxxxxxxxxxxxx
> (Previous message doesn't seem to be making it?)
>
> No Problem.
> If you have other questions, just ask.
>
> I do agree with Tom. It is better to use XML or INI if the registry is not
> an option.
> but, since you ruled them out with binary, and you want it somewhat
> secure, CArchive is the best option.
>
> You could use CFile or fstream to store and load binary formats, including
> strings, but it is difficult.
> CArchive is the easiest and best option.
>
> Regards,
> "Mark F." <user@xxxxxxxxxx> wrote in message
> news:Tww8f.42897$GQ.10171@xxxxxxxxxxxxxxxxxxxxxxx
>> Computer wrote:
>>> Sarcasim detected. Maybe not? If so...
>>>
>>
>> Thanks for elaborating. Sorry about the sarcasim.
>
>
.
- References:
- Advice needed binary configuration files
- From: Mark F.
- Re: Advice needed binary configuration files
- From: Computer
- Re: Advice needed binary configuration files
- From: Computer
- Re: Advice needed binary configuration files
- From: Mark F.
- Advice needed binary configuration files
- Prev by Date: Re: Using CListCtrl in CPropertyPage
- Next by Date: Re: MFC Migration/Integration
- Previous by thread: Re: Advice needed binary configuration files
- Next by thread: Re: Advice needed binary configuration files
- Index(es):
Relevant Pages
|