In our C ++ project, I have a need for some unified data structure, I think it should be very similar to an SQL table. I have a set of arrays (std :: vectors) of the same size with different data types. eg:.
time(int), X(double), Y(double), valid(boolean), number_of_measurements(int)
Assuming they look like a table, I need to have equal access to them. For example, I need functionality to insert a row at an arbitrary position in the table, which will cause all rows to shift one element down, kill row. I may need to sort the table by time, combine it with other tables of the same type.
Is there anything similar in the C ++ world?
Basically, I need a universal solution that supports any number of columns and rows. And of course, performance makes sense, so I prefer to do this more in memory than in the database.
UPDATE
I see that many people suggest defining a simple string structure and storing it in a collection. No, this will not fly, because I need to work with columns often. For instance. I may need to multiply the entire column or calculate the average value from it. I can even interpolate it or apply many different algorithms in a specific column.
And I want to avoid the situation when I extract the column for the vector, apply some algorithms on it, and then return it to the structure. It looks ugly, doesn't it?
I need more or less like this:
table t("time", std::vector<int>(), "X", std::vector<double>(), "Y", std::vector<double>());
t.insert_row( 1, 20.0f, 20.0f );
t["time"][10] = 20;
std::vector<int> time = t["time"];
t.sort_by( "time" );
Any thoughts?