<commit_before>// Bun.cpp : Defines the entry point for the console application.
//

#include "blib/bun/SqliteDb.hpp"

namespace test {
  struct Test {
    int one;
    float two;
    std::string three;
  };

  struct SomeOtherTest {
    int one;
    float two;
    std::string three;
    SomeOtherTest() = default;
  };
}

GENERATE_BINDING( (test::Test, one, two) );
GENERATE_BINDING( (test::SomeOtherTest, one, two, three) );

int main() {
  namespace bun = blib::bun;
  bun::dbConnect( "test.db" );
  blib::bun::createSchema<test::Test>();
  blib::bun::createSchema<test::SomeOtherTest>();

  for (int i = 1; i < 100; ++i) {
    bun::PRef<test::SomeOtherTest> t = new test::SomeOtherTest;
    t->one = i;
    t->two = i * i / i + 1;
    t->three = std::to_string( t->two );
    t.persist();
  }

  for (int i = 0; i < 10; ++i) {
    bun::PRef<test::Test> t = new test::Test;
    t->one = 11;
    t->two = 666;
    t.persist();
  }

  blib::bun::SimpleOID oid;
  oid.high = 10;
  oid.low = 1547777240864505;
  bun::PRef<test::Test> t1( oid );
  t1->one = 12;
  t1->two = 667;
  t1.persist();

  auto vec_list = blib::bun::getAllOids<test::Test>();
  auto objs = blib::bun::getAllObjects<test::Test>();

  auto vec_list1 = blib::bun::getAllOids<test::SomeOtherTest>();
  auto objs1 = blib::bun::getAllObjects<test::SomeOtherTest>();

  return 0;
}
<commit_msg>Adding the examples in the bun.cpp file<commit_after>// Bun.cpp : Defines the entry point for the console application.
//

#include "blib/bun/SqliteDb.hpp"

namespace test {
  struct Test {
    int one;
    float two;
    std::string three;
  };

  struct SomeOtherTest {
    int one;
    float two;
    std::string three;
    SomeOtherTest() = default;
  };
}

namespace test {
  struct Person {
    std::string name;
    int age;
    float height;
  };
}

GENERATE_BINDING( (test::Person, name, age, height) );

int main() {
  namespace bun = blib::bun;
  // Connect the db. If the db is not there it will be created.
  // It should include the whole path
  bun::dbConnect( "test.db" );
  // Create the schema. We can create the schema multile times. If its already created
  // it will be safely ignored
  blib::bun::createSchema<test::Person>();

  // Creat some entries in the database
  for (int i = 1; i < 10000; ++i) {
    // PRef is a reference to the persistant object.
    // PRef keeps the ownership of the memory. Release the memory when it is destroyed.
    // Internally it holds the object in a unique_ptr
    // PRef also has a oid associated with the object
    bun::PRef<test::Person> p = new test::Person;

    // Assign the members values
    p->age = i+10;
    p->height = 5.6;
    p->name = fmt::format("Brainless_{}", i);
    // Persist the object and get a oid for the persisted object.
    const blib::bun::SimpleOID oid = p.persist();

    //Getting the object from db using oid.
    bun::PRef<test::Person> p1(oid);
  }

  // To get all the object oids of a particular object.
  // oids is a vector of tyoe std::vector<blib::bun<>SimpleOID<test::Person>>
  const auto person_oids = blib::bun::getAllOids<test::Person>();

  // To get the objects of a particular type
  // std::vector<blib::bun::Pref<test::Person>>
  const auto person_objs = blib::bun::getAllObjects<test::Person>();

  return 0;
}
{'fraction_non_alphanumeric': 0.1493763310009127, 'fraction_numerical': 0.01673258290234256, 'mean_word_length': 3.193877551020408, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1912115', 'n_tokens_mistral': 1225, 'n_tokens_neox': 1161, 'n_words': 342}