Ian said:
Surely no matter what you do, you will have to change something when you
make a change?
heh, I can't argue with that
XML/XSLT (generation) and XML/DOM (parse at runtime) are a powerful
techniques of separating the structure from the content. We currently use
the latter, so we don't have to update our application when the data
changes.
Well I don't have much experience with XML but I just brought 3 books on the
subjet. Basicaly I want to define a new type called a property. This is
sorta like making a defining a new type using a class so one can do some
very complex things using simple ideas(say for example using operator
overloading).
My idea is to create a new keyword in C++ called property
the syntax might be osmething like
property base_type type_name = default_value;
base_type is some complex data type such as the first 10 letters of hte
alphebet or the integer range 10 to 58.
then I could do stuff like
type_name.base_type and it will return a string representing the base type
or
type_name.range and it will return a list of the possible values(or a range
indicator such as 10..58 to represent numeric ranges).
or I'd rather define property as
property data_type type_name = range : default_value;
where data_type is one of the simple data type of C++(since thats all I need
for my application.
now, I can do all that using classes and make it pretty efficient on the
coding side... but its going to get pretty bloated. Theres no reason for me
to store the range of the base_type in its object(I could make it static
though) or its name.
The problem with that is I could have many many simple properties that all
have different ranges and I'd have to code a class for each range and type.
I could possibly do this using templates but I have to see if there are
going to be any pitfalls and see if it will work well for what I need(it may
or may not).
It would just be easier for if I could get the compiler/pre-processor to do
most of the work for me in a similar way that one uses templates and
polymorphism.
You still have to provide the content, don't you?
yes, but I don't want to provide it more than once and I don't want to have
to split it up over several parts of the program(because I believe that
leads to many problems).
While I'm not saying your method is wrong or not good enough, I am saying
that I am not sure it is the best... though it may or may not be. I think
actually the templates method would be better but I think that it is not
still not the best. The "best" method would be for "C++" to handle a
properties like keyword similar to what I have shown above. (ofcourse
theres more to it than that but I think it would be much more direct than
the other methods).
I'm going to mess around with templates and see what I get out of it. If its
not satisfactory then I'll go ahead and look at spirit and see what I can do
there(cause I think in the long run its probably better to go ahead and
implement some type of pre-processing so one can "patch" of C++'s
compile-time short-commings).
Jon