Loading...
Searching...
No Matches
draft.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2003-2023, John Wiegley. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * - Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * - Neither the name of New Artisans LLC nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
42#pragma once
43
44#include "exprbase.h"
45#include "value.h"
46
47namespace ledger {
48
49class journal_t;
50class xact_t;
51
52class draft_t : public expr_base_t<value_t>
53{
55
56 struct xact_template_t
57 {
61 mask_t payee_mask;
62
77
78 std::list<post_template_t> posts;
79
80 xact_template_t() {
81 TRACE_CTOR(xact_template_t, "");
82 }
83 xact_template_t(const xact_template_t& other)
84 : date(other.date),
85 code(other.code),
86 note(other.note),
87 payee_mask(other.payee_mask),
88 posts(other.posts)
89 {
90 TRACE_CTOR(xact_template_t, "copy");
91 }
92 ~xact_template_t() throw() {
93 TRACE_DTOR(xact_template_t);
94 }
95
96 void dump(std::ostream& out) const;
97 };
98
100
101public:
102 draft_t(const value_t& args) : base_type() {
103 if (! args.empty())
104 parse_args(args);
105 TRACE_CTOR(draft_t, "value_t");
106 }
107 virtual ~draft_t() throw() {
109 }
110
111 void parse_args(const value_t& args);
112
114 assert(false);
115 return true;
116 }
117
119
120 virtual void dump(std::ostream& out) const {
121 if (tmpl)
122 tmpl->dump(out);
123 }
124};
125
128
129} // namespace ledger
#define TRACE_DTOR(cls)
Definition utils.h:144
#define TRACE_CTOR(cls, args)
Definition utils.h:143
#define assert(x)
Definition utils.h:92
Abstract dynamic type representing various numeric types.
value_t xact_command(call_scope_t &args)
gregorian::date date
Definition utils.h:64
value_t template_command(call_scope_t &args)
T & downcast(U &object)
Definition utils.h:468
virtual ~draft_t()
Definition draft.h:107
virtual result_type real_calc(scope_t &)
Definition draft.h:113
xact_t * insert(journal_t &journal)
draft_t(const value_t &args)
Definition draft.h:102
virtual void dump(std::ostream &out) const
Definition draft.h:120
void parse_args(const value_t &args)
Dynamic type representing various numeric types.
Definition value.h:83
bool empty() const
Definition value.h:922