V
Volkan YAZICI
Hi,
I'd like to implement a simple database, that is, a collection of
tables, where the tables are just a vector of rows, and rows are just
a vector of fields with varying data types. I use a vector<Field> to
represent a row, and Field has children like IntField, StringField,
etc. Field class would have a getData() method, which is obviously
expected to be defined as a purely virtual function in Field. But the
problem is, what would be the function footprint of such a purely
virtual function? That is, for IntField, it will be "const int&
getData() const"; for StringField, it will be "const string& getData()
const", etc. Can anybody help me on this, please? How should I
approach the problem? Do you recommend another solution? (BTW, Field
is also expected to have relevant ctor and comparison methods as well.
FYI.)
OTOH, one can argue that, why not using sth like Field<int>(),
Field<string>(), etc.? In such a case, I won't be able to define a
vector of different data types. That is, to denote a row, I'll use
vector<Field<int>>, and I'll only be able to store "int"s, no other
data types will be permitted.
Regards.
I'd like to implement a simple database, that is, a collection of
tables, where the tables are just a vector of rows, and rows are just
a vector of fields with varying data types. I use a vector<Field> to
represent a row, and Field has children like IntField, StringField,
etc. Field class would have a getData() method, which is obviously
expected to be defined as a purely virtual function in Field. But the
problem is, what would be the function footprint of such a purely
virtual function? That is, for IntField, it will be "const int&
getData() const"; for StringField, it will be "const string& getData()
const", etc. Can anybody help me on this, please? How should I
approach the problem? Do you recommend another solution? (BTW, Field
is also expected to have relevant ctor and comparison methods as well.
FYI.)
OTOH, one can argue that, why not using sth like Field<int>(),
Field<string>(), etc.? In such a case, I won't be able to define a
vector of different data types. That is, to denote a row, I'll use
vector<Field<int>>, and I'll only be able to store "int"s, no other
data types will be permitted.
Regards.