GnuCashew ~ Web Application compatible with GnuCash sql data files.
GCW
Loading...
Searching...
No Matches
Dbo/Books/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*/
13namespace 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*/
28template<> struct Wt::Dbo::dbo_traits< GCW::Dbo::Books::Item >
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
37template<> 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*/
43namespace 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*/
69class 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,
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
auto persist(Action &action) -> void
std::string m_root_template_guid
Item(const std::string &_guid)
ctor with guid
std::string m_root_account_guid
auto guid() const -> const std::string &
GUID.
void id(Action &action, V &value, const std::string &name="id", int size=-1)
void field(Action &action, V &value, const std::string &name, int size=-1)
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
Definition App.h:18
static auto versionField() -> const char *
static auto surrogateIdField() -> const char *