diff options
Diffstat (limited to 'lib/lemma.h')
| -rw-r--r-- | lib/lemma.h | 78 |
1 files changed, 39 insertions, 39 deletions
| diff --git a/lib/lemma.h b/lib/lemma.h index 8c8d1c1..407fa3c 100644 --- a/lib/lemma.h +++ b/lib/lemma.h | |||
| @@ -13,110 +13,110 @@ | |||
| 13 | struct sqlite3_stmt; | 13 | struct sqlite3_stmt; |
| 14 | 14 | ||
| 15 | namespace verbly { | 15 | namespace verbly { |
| 16 | 16 | ||
| 17 | class database; | 17 | class database; |
| 18 | 18 | ||
| 19 | class lemma { | 19 | class lemma { |
| 20 | public: | 20 | public: |
| 21 | 21 | ||
| 22 | // Default constructor | 22 | // Default constructor |
| 23 | 23 | ||
| 24 | lemma() = default; | 24 | lemma() = default; |
| 25 | 25 | ||
| 26 | // Construct from database | 26 | // Construct from database |
| 27 | 27 | ||
| 28 | lemma(const database& db, sqlite3_stmt* row); | 28 | lemma(const database& db, sqlite3_stmt* row); |
| 29 | 29 | ||
| 30 | // Accessors | 30 | // Accessors |
| 31 | 31 | ||
| 32 | operator bool() const | 32 | operator bool() const |
| 33 | { | 33 | { |
| 34 | return valid_; | 34 | return valid_; |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | int getId() const | 37 | int getId() const |
| 38 | { | 38 | { |
| 39 | if (!valid_) | 39 | if (!valid_) |
| 40 | { | 40 | { |
| 41 | throw std::domain_error("Bad access to uninitialized lemma"); | 41 | throw std::domain_error("Bad access to uninitialized lemma"); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | return id_; | 44 | return id_; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | const form& getBaseForm() const; | 47 | const form& getBaseForm() const; |
| 48 | 48 | ||
| 49 | bool hasInflection(inflection category) const; | 49 | bool hasInflection(inflection category) const; |
| 50 | 50 | ||
| 51 | const std::vector<form>& getInflections(inflection category) const; | 51 | const std::vector<form>& getInflections(inflection category) const; |
| 52 | 52 | ||
| 53 | // Type info | 53 | // Type info |
| 54 | 54 | ||
| 55 | static const object objectType; | 55 | static const object objectType; |
| 56 | 56 | ||
| 57 | static const std::list<std::string> select; | 57 | static const std::list<std::string> select; |
| 58 | 58 | ||
| 59 | // Query fields | 59 | // Query fields |
| 60 | 60 | ||
| 61 | static const field id; | 61 | static const field id; |
| 62 | 62 | ||
| 63 | operator filter() const | 63 | operator filter() const |
| 64 | { | 64 | { |
| 65 | if (!valid_) | 65 | if (!valid_) |
| 66 | { | 66 | { |
| 67 | throw std::domain_error("Bad access to uninitialized lemma"); | 67 | throw std::domain_error("Bad access to uninitialized lemma"); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | return (id == id_); | 70 | return (id == id_); |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | // Relationships to other objects | 73 | // Relationships to other objects |
| 74 | 74 | ||
| 75 | static const field word; | 75 | static const field word; |
| 76 | 76 | ||
| 77 | class inflection_field { | 77 | class inflection_field { |
| 78 | public: | 78 | public: |
| 79 | 79 | ||
| 80 | inflection_field(inflection category) : category_(category) | 80 | inflection_field(inflection category) : category_(category) |
| 81 | { | 81 | { |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | const inflection getCategory() const | 84 | const inflection getCategory() const |
| 85 | { | 85 | { |
| 86 | return category_; | 86 | return category_; |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | operator filter() const; | 89 | operator filter() const; |
| 90 | 90 | ||
| 91 | private: | 91 | private: |
| 92 | 92 | ||
| 93 | const inflection category_; | 93 | const inflection category_; |
| 94 | }; | 94 | }; |
| 95 | 95 | ||
| 96 | static const inflection_field form(inflection category) | 96 | static const inflection_field form(inflection category) |
| 97 | { | 97 | { |
| 98 | return inflection_field(category); | 98 | return inflection_field(category); |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | friend filter operator%=(lemma::inflection_field check, filter joinCondition); | 101 | friend filter operator%=(lemma::inflection_field check, filter joinCondition); |
| 102 | 102 | ||
| 103 | private: | 103 | private: |
| 104 | 104 | ||
| 105 | void initializeForm(inflection category) const; | 105 | void initializeForm(inflection category) const; |
| 106 | 106 | ||
| 107 | bool valid_ = false; | 107 | bool valid_ = false; |
| 108 | 108 | ||
| 109 | int id_; | 109 | int id_; |
| 110 | 110 | ||
| 111 | mutable std::map<inflection, std::vector<class form>> forms_; | 111 | mutable std::map<inflection, std::vector<class form>> forms_; |
| 112 | 112 | ||
| 113 | const database* db_; | 113 | const database* db_; |
| 114 | 114 | ||
| 115 | static const field formJoin; | 115 | static const field formJoin; |
| 116 | static const field inflectionCategory; | 116 | static const field inflectionCategory; |
| 117 | 117 | ||
| 118 | }; | 118 | }; |
| 119 | 119 | ||
| 120 | }; | 120 | }; |
| 121 | 121 | ||
| 122 | #endif /* end of include guard: LEMMA_H_0A180D30 */ | 122 | #endif /* end of include guard: LEMMA_H_0A180D30 */ |
