summary refs log tree commit diff stats
path: root/lib/frame.cpp
blob: 2351973612e84745d4578a9cb17fb6e3d7b2f6a4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "frame.h"
#include <sqlite3.h>
#include "database.h"
#include "query.h"

namespace verbly {

  const object frame::objectType = object::frame;

  const std::list<std::string> frame::select = {"frame_id", "group_id", "length"};

  const field frame::id = field::integerField(object::frame, "frame_id");
  const field frame::length = field::integerField(object::frame, "length");

  const field frame::words = field::joinField(object::frame, "group_id", object::word);

  field frame::parts()
  {
    return field::joinField(object::frame, "frame_id", object::part);
  }

  field frame::parts(int index)
  {
    return field::joinWhere(object::frame, "frame_id", object::part, "part_index", index);
  }

  frame::frame(const database& db, sqlite3_stmt* row) : db_(&db), valid_(true)
  {
    id_ = sqlite3_column_int(row, 0);
    groupId_ = sqlite3_column_int(row, 1);
    length_ = sqlite3_column_int(row, 2);

    parts_ = db.parts(*this, verbly::part::index, -1).all();
  }

};