Re: Advice needed binary configuration files



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.
>
>


.



Relevant Pages

  • [TOMOYO #15 3/8] Common functions for TOMOYO Linux.
    ... This file contains common functions (e.g. policy I/O, pattern matching). ... Since TOMOYO Linux is a name based access control, ... TOMOYO Linux's string manipulation functions make reviewers feel crazy, ... the Linux kernel accepts all characters but NUL character ...
    (Linux-Kernel)
  • RfD: Escaped Strings version 4
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... as an escape character for the entry of characters that cannot be ... \b BS (backspace, ASCII 8) ...
    (comp.lang.forth)
  • RfD: Escaped Strings version 4
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... as an escape character for the entry of characters that cannot be ... \b BS (backspace, ASCII 8) ...
    (comp.lang.forth)
  • Re: RfD: Escaped Strings
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... \b BS (backspace, ASCII 8) ... \ ** escapes to characters much as C does. ...
    (comp.lang.forth)
  • Re: A note on computing thugs and coding bums
    ... code is valid for any character set that is legal in C (which is a ... characters in the required source character set ... A String, in C Sharp or Java, can be redefined. ... allow programmers to handle some other data format, ...
    (comp.programming)