GnuCashew ~ GnuCash Enabled Web
GCW
Item.h
Go to the documentation of this file.
1 #line 2 "src/Dbo/Books/Item.h"
2 
3 #ifndef __DBO_BOOKS_ITEM_H___
4 #define __DBO_BOOKS_ITEM_H___
5 
6 #include "../BaseItem.h"
7 #include "Definition.h"
8 
9 /*
10 ** Predefine the class that fixin to come up.
11 **
12 */
13 namespace GCW {
14  namespace Dbo {
15  namespace Books {
16  class Item;
17  }
18  }
19 }
20 
21 /*
22 ** Define these dbo_traits to prevent the system from
23 ** automatically generating an ID field or a VERSION
24 ** field, and instead substitute the guid field
25 ** as the primary key.
26 **
27 */
28 template<> struct Wt::Dbo::dbo_traits< GCW::Dbo::Books::Item >
29 : public Wt::Dbo::dbo_default_traits
30 {
31  using IdType = std::string;
32  static auto invalidId()-> IdType { return std::string(); }
33  static auto surrogateIdField()-> const char * { return nullptr; }
34  static auto versionField()-> const char * { return nullptr; }
35 };
36 
37 template<> struct Wt::Dbo::dbo_traits< const GCW::Dbo::Books::Item > : Wt::Dbo::dbo_traits< GCW::Dbo::Books::Item > {};
38 
39 /*
40 ** Now we can start building our class!
41 **
42 */
43 namespace GCW {
44  namespace Dbo {
45  namespace Books {
46 
47 /*!
48 ** \brief Books Class
49 **
50 **
51 ** \dot
52 ** digraph BooksMap
53 ** {
54 ** BooksItem;
55 ** }
56 ** \enddot
57 **
58 ** \par Native GnuCash Books Sqlite Schema
59 ** \code
60 ** CREATE TABLE books
61 ** (
62 ** guid text(32) PRIMARY KEY NOT NULL,
63 ** root_account_guid text(32) NOT NULL,
64 ** root_template_guid text(32) NOT NULL
65 ** );
66 ** \endcode
67 **
68 */
69 class Item
70 : public GCW::Dbo::BaseItem< Item >
71 {
72  public:
73 
74  /*!
75  ** \brief ctor
76  */
77  Item(){}
78 
79  /*!
80  ** \brief ctor with guid
81  */
82  Item( const std::string & _guid ): m_guid( _guid ){}
83 
84  /*!
85  ** \brief GUID
86  **
87  ** Return account 'guid' value - the primary key for the account
88  */
89  auto guid() const-> const std::string & { return m_guid; }
90 
91  template< class Action > auto
92  persist( Action & action )-> void
93  {
94  Wt::Dbo::id ( action, m_guid , GCW::Dbo::Books::Field::guid , 32 ); // text(32) PRIMARY KEY NOT NULL,
95  Wt::Dbo::field( action, m_root_account_guid , GCW::Dbo::Books::Field::root_account_guid , 32 ); // text(32) NOT NULL,
96  Wt::Dbo::field( action, m_root_template_guid , GCW::Dbo::Books::Field::root_template_guid , 32 ); // text(32) NOT NULL
97 
98  } // endpersist( Action & action )-> void
99 
100  private:
101 
102  std::string m_guid ; // text(32) PRIMARY KEY NOT NULL,
103  std::string m_root_account_guid ; // text(32) NOT NULL,
104  std::string m_root_template_guid ; // text(32) NOT NULL
105 
106 }; // endclass Item
107 
108  } // endnamespace Books {
109  } // endnamespace Dbo {
110 } // endnamespace GCW {
111 
112 #endif // __DBO_BOOKS_ITEM_H___
113 
Books Class.
Definition: Item.h:71
auto persist(Action &action) -> void
Definition: Item.h:92
std::string m_root_template_guid
Definition: Item.h:104
std::string m_guid
Definition: Item.h:102
Item(const std::string &_guid)
ctor with guid
Definition: Item.h:82
std::string m_root_account_guid
Definition: Item.h:103
auto guid() const -> const std::string &
GUID.
Definition: Item.h:89
const Wt::WFormModel::Field guid
Definition: Books.cpp:10
const Wt::WFormModel::Field root_template_guid
Definition: Books.cpp:12
const Wt::WFormModel::Field root_account_guid
Definition: Books.cpp:11
const Wt::WFormModel::Field action
Definition: Entries.cpp:14
const Wt::WFormModel::Field id
Definition: Definition.h:17
Definition: App.h:17
Definition: guid.cpp:397
static auto versionField() -> const char *
Definition: Item.h:34
static auto surrogateIdField() -> const char *
Definition: Item.h:33
static auto invalidId() -> IdType
Definition: Item.h:32