Creating Structs/Classes at runtime?

Brian Brady brian.brady1982 at gmail.com
Mon Feb 18 16:31:27 PST 2013


On Monday, 18 February 2013 at 16:54:59 UTC, Ali Çehreli wrote:
[...]
>
> You mean like this?
>
> 10,20,label,1,2,3,4
>
> Then what are 10 and 20 on that line? Do they belong to the 
> previous label? If so, I think this format is too free-form to 
> be parsed by a general solution like csvReader. It looks like 
> something special needs to be done and it is hard to say 
> without knowing the meanings of 10 and 20 above. :)
>
> Ali

I don't mind reading them all in as strings, and then converting 
them. I imagine I can do that relatively easily (famous last 
words) by checking if all the entries in the string are numeric 
and if so casting to an int/long/double etc.

My question was aimed at how to store them really. What was the 
best dynamic container type that I could use to store data points 
read from csvs.

I want something which is robust enough that I don't have to keep 
changing the code every time I change my csv.

So a program that reads in a csv of the form:

"string, number, number, number"

and stores it in a container/matrix/associative array

could also read in

"number, number, string, number, string, number, number, number"

and store it in a container with similar properties.
Once I can get both csvs input in the same manner, I can work on 
determining what is in each container, and go from there.

While this may seem madness, I hope my explanation describes what 
I am trying to achieve?

Brian


More information about the Digitalmars-d-learn mailing list