tags:

views:

43

answers:

1

Hi,

I have a scenario where I am given data records at runtime. The datatype of the cells of the record are variable and only known at runtime. How wil I store these records?

For e.g.,

At runtime, I get record_Info = "char[]","int16","int32" Then I get records = "abc" "2" "30", "def" "3" "40"

how can I store these when I cant initialize their types?

A: 

Assuming you want to store them in a file. Store the type information at the beginning of the file(say like a header). There are only a predefined set of types. With the type info available you can have converter functions to convert the data into the respective types and store them as binary data in the file. If you have some upper limit of variable data(char[]), then better store fixed data records in the file. It would be easier to access and modify.

If there is no upper limit on the variable data, then u need to store the variable data in TLV format.

aeh