D-styled data file

Georg Wrede georg.wrede at iki.fi
Wed Apr 29 06:35:48 PDT 2009


Saaa wrote:
> Thanks for your reply
> 
> "Georg Wrede" <georg.wrede at iki.fi> wrote in message 
> news:gt96lc$dig$1 at digitalmars.com...
>> Saaa wrote:
>>> I changed the prototype to:
>>>
>>> void get(in char[] varName, ...)
>>>
>>> I'm not totally happy with it because I only need one variadic argument 
>>> and :
>>>
>>> How do I get the .stringof of an variadic type?
>>> _arguments[0].stringof doesn't work :)
>>>
>>> How do I mutate the original argument? (ref)
>>>
>>> Please tell me if I'm on the totally wrong track here.
>> What you're doing is called serialization.
> Isn't serialization the other way around?

Technically yes, deserialization. Although the whole thing comprising 
both of these is still called serialization.

> Of course a d-styled fileformat would be very handy when it comes to 
> serialization,
> but I started because of the inverse: I wanted to read data which would be 
> easily put into D types.
> 
>> I often find it good to get some background info. That often helps me 
>> rethink and maybe redefine the problem. It takes time to read stuff, but 
>> in the end it often saves even more time. Or effort. A couple of pointers:
>>
>> http://en.wikipedia.org/wiki/Serialization_(computing)#Human-readable_serialization
>>
>> Thinking about what your file might look like could also help:
>>
>> http://en.wikipedia.org/wiki/JSON#Data_types.2C_syntax_and_example
> The problem with this format (to me) would be that multidimensional arrays 
> aren't standard.
> 
> Because the compiler can (of course) already read d styled data files I know 
> the code
> must be there already.
> 
> I'm still dangling between a full parsing at load and parse on demand.
> A parse on demand (get) would do the following steps:
> Get the type of the variable in which the data must be stored (in string 
> format)
> Search for this type in every line of the char[][], when found check whether 
> the name is the same
> and then convert the chars to that type and place the data in the variable.

This sounds complicated. Can you decide the input file format? Or is it 
from some other program that you can't change?

Suppose you already had this get function. How would you use it? An 
example would help.


More information about the Digitalmars-d-learn mailing list