Project Description
Object database for WinRT (C++/CX)

Declaring persistent classes:

MCLASS(PAddress);
MSTRING(PAddress, Street);
MSTRING(PAddress, City);
MSTRING(PAddress, State);
MSTRING(PAddress, Country);
MENDCLASS(PAddress);

partial ref class PPerson {
public:
  property String^ FullName { String^ get() { return FirstName + " " + LastName; } }
};

MCLASS(PPerson)
MSTRING(PPerson, FirstName)
MSTRING(PPerson, LastName)
MNUMBER(PPerson, Age)
MOBJECT(PPerson, PAddress, Address)
MENDCLASS(PPerson)

Saving objects:

auto database = ref new Database("test.db");
auto address = ref new PAddress;
address->Street = "Street 5678";
address->City = "New York";
address->State = "NY";
address->Country = "USA";
auto person = ref new PPerson;
person->FirstName = "John";
person->LastName = "Smith";
person->Age = 33;
person->Address = _address;
bool success = database->Store(person);

Fetching objects:

database->Fetch(MQUERY(PPerson, p, p->Age > 30), ref new FetchedObjectCallback([](MetroClass^ _obj) {
  PPerson^ obj = (PPerson^) _obj;
  // ...
}));

Last edited Oct 19, 2011 at 11:59 AM by slonzok, version 6