Parse File at compile time, but not embedded

Pie? via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 6 10:31:52 PDT 2016


Is it possible to parse a file at compile time without embedding 
it into the binary?

I have a sort of "configuration" file that defines how to create 
some objects. I'd like to be able to read how to create them but 
not have that config file stick around in the binary.

e.g., (simple contrived example follows)

Config.txt
    x, my1
    y, my1
    z, my2


class my1 { }
class my2 { }

void parseConfig(A)
{
     ....
}

void main()
{
    parseConfig('Config.txt') // Effectively creates a mixin that 
mixes in auto x = new my1; auto y = new my1; auto z = new my2;
}


If parseConfig uses import('Config.txt') then config.txt will end 
up in the binary which I do not want. It would be easier to be 
able to use import and strip it out later if possible. Config.txt 
may contain secure information, which is why is doesn't belong in 
the binary.











More information about the Digitalmars-d-learn mailing list