about summary refs log tree commit diff stats
path: root/data/maps/the_entry/rooms/Red Blue Halls.txtpb
blob: 583a310436e4dbd5556fdc4f99884232df473881 (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
generated by cgit-pink 1.4.1 (git 2.36.1) at 2025-09-17 08:45:33 +0000
 


an class="k">const field lemma::formJoin = field::joinField(object::lemma, "form_id", object::form);
  const field lemma::inflectionCategory = field::integerField(object::lemma, "category");
  
  filter operator%=(lemma::inflection_field check, filter joinCondition)
  {
    return (lemma::formJoin %= joinCondition) && (lemma::inflectionCategory == check.getCategory());
  }
  
  lemma::inflection_field::operator filter() const
  {
    return (lemma::inflectionCategory == category_);
  }
  
  lemma::lemma(const database& db, sqlite3_stmt* row) : db_(&db), valid_(true)
  {
    id_ = sqlite3_column_int(row, 0);
  }
  
  const form& lemma::getBaseForm() const
  {
    if (!valid_)
    {
      throw std::domain_error("Bad access to uninitialized lemma");
    }
    
    if (!forms_.count(inflection::base))
    {
      initializeForm(inflection::base);
    }
    
    return forms_.at(inflection::base).front();
  }
  
  bool lemma::hasInflection(inflection category) const
  {
    return !getInflections(category).empty();
  }
  
  const std::vector<form>& lemma::getInflections(inflection category) const
  {
    if (!valid_)
    {
      throw std::domain_error("Bad access to uninitialized lemma");
    }
    
    if (!forms_.count(category))
    {
      initializeForm(category);
    }
    
    return forms_.at(category);
  }
  
  void lemma::initializeForm(inflection infl) const
  {
    forms_[infl] = db_->forms(form::lemma(infl) %= *this, false, -1).all();
  }
  
};