#ifndef FORM_H_3A6C962C #define FORM_H_3A6C962C #include #include #include #include #include "field.h" #include "pronunciation.h" #include "filter.h" struct sqlite3_stmt; namespace verbly { class database; class form { public: // Default constructor form() = default; // Construct from database form(const database& db, sqlite3_stmt* row); // Accessors bool isValid() const { return valid_; } int getId() const { if (!valid_) { throw std::domain_error("Bad access to uninitialized form"); } return id_; } std::string getText() const { if (!valid_) { throw std::domain_error("Bad access to uninitialized form"); } return text_; } int getComplexity() const { if (!valid_) { throw std::domain_error("Bad access to uninitialized form"); } return complexity_; } bool isProper() const { if (!valid_) { throw std::domain_error("Bad access to uninitialized form"); } return proper_; } const std::vector& getPronunciations() const; // Convenience bool startsWithVowelSound() const; // Type info static const object objectType; static const std::list select; // Query fields static const field id; static const field text; static const field complexity; static const field proper; operator filter() const { if (!valid_) { throw std::domain_error("Bad access to uninitialized form"); } return (id == id_); } // Relationships to other objects static field words(inflection category); static const field pronunciations; private: bool valid_ = false; int id_; std::string text_; int complexity_ ; bool proper_; const database* db_; mutable bool initializedPronunciations_ = false; mutable std::vector pronunciations_; }; }; #endif /* end of include guard: FORM_H_3A6C962C */