//| //| Copyright (C) Articque Informatique //| All rights reserved. Duplication and distribution prohibited. //| Les Roches, 37230 Fondettes France //| Telephone +33 02.47.49.90.49 //| Fax +33 02.47.49.91.49 //| E-Mail: info@articque.com //| #include #include #include #include int main (int argc, char **argv) { long idx; // printf(" --- Removing file\n"); remove("metakit_tutorial.db"); // printf(" --- 3) Create database and view\n"); c4_Storage database("metakit_tutorial.db", true); c4_View maps=database.GetAs("maps[mid:S,mwidth:I,mheight:I,mpath:S]"); // printf(" --- 4) Add rows to the view 'maps'\n"); c4_StringProp mid("mid"),mpath("mpath"); c4_IntProp mwidth("mwidth"),mheight("mheight"); c4_Row maprow; mid(maprow)="A"; mwidth(maprow)=10; mheight(maprow)=10; mpath(maprow)="/home/MapA.vxf"; maps.Add(maprow); mid(maprow)="B"; mwidth(maprow)=20; mheight(maprow)=20; mpath(maprow)="/home/MapB.vxf"; maps.Add(maprow); mid(maprow)="C"; mwidth(maprow)=30; mheight(maprow)=30; mpath(maprow)="/home/MapC.vxf"; maps.Add(maprow); // printf(" --- 5) Save file\n"); database.Commit(); // printf(" --- 6) Retreive with SelectRange\n"); c4_Row selectrow_start,selectrow_end; c4_View tableselect; mwidth(selectrow_start)=20; mwidth(selectrow_end)=30; tableselect=maps.SelectRange(selectrow_start,selectrow_end); for (idx=0;idx=0) printf("DATA %s has dmapid=%s\n", (const char*)dpath(datas[idxsearch]), (const char*)dmapid(datas[idxsearch])); else break; } // printf(" --- 9) Retrieve information using a relation\n"); c4_View relation; relation=(datas.Rename(dmapid,mid)).Join(mid,tableselect); for (idx=0;idx=0) { printf("DATA %s at idx=%d is deleted\n", (const char*)dpath(datas[idxsearch]),idxsearch); datas.RemoveAt(idxsearch); } else break; } // printf(" --- 12) Updating view content\n"); c4_Row updaterow; mid(updaterow)="E"; mwidth(updaterow)=90; mheight(updaterow)=90; mpath(updaterow)="/home/MapE.vxf"; maps.SetAt(2,updaterow); printf("new content :\n"); for (idx=0;idx