Reg C++ implementation for in memory database

S

sunil

Hi,
I have a container that holds objects of same type (user defined
class), where each object has multiple attributes. These objects have
primary key (similar to a database) formed by combination of two
attributes, but I want to support multiple views of data by looking at
different combination of attributes and in some cases I might want to
combine these. For instance, lets say the class has four attributes
a1,a2,a3,a4; and primary key is a1+a4, now I can construct a view that
has subset of objects of this class by doing a search on these objects
that have specific values for attribute a3, and this can give me back
multiple objects and I want to combine the objects that have same
value for a2 into one ; this looks like a classic database
implementation but I dont have real database in my case, instead I have
set of objects and the query I am doing is on these objects based on
combination of attributes of the class. Any pointers on how to do this
using STL classes would be appreciated. I am looking into using
associative containers.. Is this already implemented by someone? I dont
care too much about efficiency since I wont have more than 100 of these
objects...
Thanks,
Sunil.
 
P

Phlip

sunil said:
I have a container that holds objects of same type (user defined
class), where each object has multiple attributes. These objects have
primary key (similar to a database) formed by combination of two
attributes, but I want to support multiple views of data by looking at
different combination of attributes and in some cases I might want to
combine these. For instance, lets say the class has four attributes
a1,a2,a3,a4; and primary key is a1+a4...

sqlite is trivial to install and run. It works off a data file and can do
arbitrarily complex SQL statements, such as joins.
 
A

andy

sunil said:
Hi,
I have a container that holds objects of same type (user defined
class), where each object has multiple attributes. These objects have
primary key (similar to a database) formed by combination of two
attributes, but I want to support multiple views of data by looking at
different combination of attributes and in some cases I might want to
combine these.
[...]

this looks like a classic database
implementation but I dont have real database in my case, instead I have
set of objects and the query I am doing is on these objects based on
combination of attributes of the class. Any pointers on how to do this
using STL classes would be appreciated. I am looking into using
associative containers.. Is this already implemented by someone? I dont
care too much about efficiency since I wont have more than 100 of these
objects...
Thanks,
Sunil.

Boost.MultiIndex library can do this sort of thing:
http://www.boost.org/libs/multi_index/doc/index.html

Also there is relational Template Library (RTL) in boost sandbox:
http://tinyurl.com/zwe2o

regards
Andy Little
 
S

sunil

Thank you all for input, I looked at boost multi-index library and they
seem to have done a nice job. I cannot use it though due to some
restrictions on third party software. I think I can implement for my
case using maps and multimaps.....
Sunil
 
P

Phlip

sunil said:
Thank you all for input, I looked at boost multi-index library and they
seem to have done a nice job. I cannot use it though due to some
restrictions on third party software.

Excuse me? Boost's license is free with no restrictions. Our lawyer just
recently approved it for our shrink-wrap and turn-key solutions.

Maybe your boss likes paying expensive programmers to sit around reinventing
wheels all day. How's your C++ compiler coming along?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top