I want to store the following information in a file. My program is consisted of set of string that are connected forming a graph. I call each single string "Tag".
let's say we have 3 main tags $Mohammed
, $car
, $color
Each of the main tags contains sub tags and each sub tag has a value or another sub tag or set of sub tags.
$Mohammad:
$Age: "18"
$color: $red
$kind_of: $human
$car:
$type: $toyota
$color: $blue
$doors:
$number: "3"
$car:
$made_of: $metal
$used_for: $transporting
$types: {$mercedes,$toyota,$nissan}
$best_color: $red
$color:
$usedto: $coloring_things
$example: {$red,$green,$blue,...}
But this in not the only thing, there is a connection between the tags of the same name, so that $Mohammed->$car->$color
must be connected with the main tag $color
. and $Mohammed->$color:$red
, $car->$best_color:$red
, $color->$best_color: $red
and the main tag $red must all be connected to each other.
The tags connected means be stored in a way that I can call the connected tags at once. just like the computer memory. when it calls something from the memory, it calls the information before and after the requested information.
When I looked to my situation in the first time, I thought that XML would solve it, but then I realized that XML can't represent graph.
I don't want to use databases for this. I want to keep database as my last weapon.
Any idea or suggestion about how can I store,connect and recall the informations from my program? Thanks in advance.
Take a loot at boost's property_tree
It contains a nice c++ way to represent your graph, and let's you very easily decide what kind of file-representation you want. Be that xml
, json
, info
.
Also, I don't see why your graph can't be represented by xml
, as it supports named nodes.
Although property_tree
also supports the ini
format, that actually can't represent your >2 level deep tree.