R
Razzie
Hey all,
Let's say I have a textfile with 'marked' values in it, for example,
something like this:
Name......... *name*
Street......... *street*
Email.......... *email*
And say I have 1 or more objects with properties equal to the name of those
marked values, for example:
Person.name, Person.street, Person.email
well you get the idea
Now, I want to replace the * * values in the textfile with the properties of
the object. Of course this ain't a problem, however, I do NOT want the
following situation:
//Search the file for a * * string
switch(strToReplace)
{
case "*name*":
// replace strToReplace with Person.name
break;
case "*street*":
// replace strToReplace with Person.street
break;
// etc
}
this code just looks plain ugly to me and besides, if I get like 100+ * *
values in my (more than 1) textfiles, which is quite possible, this is a lot
of work too. I'm hoping for a very easy and clean way instead... is there a
way to call the corresponding property automatically when the names are
equal? Is there another way to do this? I've been looking for a solution
using design patterns but I couldn't find a good one, so I hope someone here
knows a good solution.
THanks a lot in advance,
Razzie
Let's say I have a textfile with 'marked' values in it, for example,
something like this:
Name......... *name*
Street......... *street*
Email.......... *email*
And say I have 1 or more objects with properties equal to the name of those
marked values, for example:
Person.name, Person.street, Person.email
well you get the idea

Now, I want to replace the * * values in the textfile with the properties of
the object. Of course this ain't a problem, however, I do NOT want the
following situation:
//Search the file for a * * string
switch(strToReplace)
{
case "*name*":
// replace strToReplace with Person.name
break;
case "*street*":
// replace strToReplace with Person.street
break;
// etc
}
this code just looks plain ugly to me and besides, if I get like 100+ * *
values in my (more than 1) textfiles, which is quite possible, this is a lot
of work too. I'm hoping for a very easy and clean way instead... is there a
way to call the corresponding property automatically when the names are
equal? Is there another way to do this? I've been looking for a solution
using design patterns but I couldn't find a good one, so I hope someone here
knows a good solution.
THanks a lot in advance,
Razzie