I'd like to ask you some question and  so hope on your help.

I will explain the problem.

We have some tool which convert binary file to text file. This tool is using c++ core, xml, xslt.

Today we'd like to have some tool which will convert text format file to binary format file.
While the variable in binary file must follow the certain defined format.
This conversion should be done in real time execution.
I give you the example.

Let say the text file is:
Variable_A : 21      (8 bits)
Variable_B:    1      (3 bits)
Variable_C :   0      (3 bits)
Variable_D:    1      (1 bits)

The first solution which is coming  to go to c++, pull the value of variables - (21, 1, 0, 1).
But if we define A, B, C, D as integer it will be 32 bits each, isn't it? Then we have to
have some definition table where we give the length to each variable and so on.

My question is: which strategy we can use to accomplish this conversion (text->binary with defined format),
is it exist some possibility to use the xml here, if yes, can you explain?

I will so appreciate your opinion and suggestions.
Please, response me. I'm sure it exist some strategy which will simplify this task.

If it is not your area of competence, maybe you can refer me someone, or send this message to this person.

Thank you very much in advance.