I`d need to read a typical text file with an unknown number of fields (and type, but let´s supose the are all char-type). The name of that fields is stored on the first row of the file. The file is delimited with a character, for example the | character.
the goal is to read the file and store the content of the file into a database. Then the question is : Is it possible to generate a struct dinamically from the information given in the first row? Is a struct the correct way to solve it? I can´t figure out a possible solution for this.
You more or less already have a dynamic type system in the database. Just read all of the data into a vector of strings. Then use the database API to coerce the strings into the field types they map to.
thank you for the answers.. the fact is I used the tern database to simplify the question, but I want to create a my own "database" and the parsing of the text file would go to a "table" , that would be a binary file. So i get the idea about using dynamic types and vectors, even I'll need a more complex structure of classes, that store other information like the name of the field , the vectors read and other propertiers and functions..