本文介绍了在内存数据库中使用Reg C ++实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个容器,它包含相同类型的对象(用户定义

类),其中每个对象都有多个属性。这些对象有两个

属性组合形成的主键(类似于数据库),但我希望通过查看
来支持多个数据视图
不同的属性组合,在某些情况下我可能希望将
结合起来。例如,假设该类有四个属性

a1,a2,a3,a4;并且主键是a1 + a4,现在我可以构建一个视图,通过对这些对象进行搜索,

具有此类对象的子集

具有特定值属性a3,这可以给我回来

多个对象,我想将a2具有相同

值的对象合并为一个;这看起来像一个经典的数据库

实现,但我没有真正的数据库在我的情况下,而是我有

对象集和我正在做的查询是基于这些对象在

类的属性组合。关于如何使用STL类的任何指示

将不胜感激。我正在研究使用

关联容器。这是否已由某人实施?我不太关心效率,因为我不会有超过100个这样的物品......

谢谢,

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.

推荐答案





sqlite安装和运行都很简单。它可以处理数据文件并可以执行任意复杂的SQL语句,例如连接。


-

Phlip
< - 不是博客!!!



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

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!





Boost.MultiIndex库可以做这样的事情:



还有关系模板库(RTL) )在增强沙箱中:



问候

Andy Little



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


这篇关于在内存数据库中使用Reg C ++实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 18:48