summaryrefslogtreecommitdiff
path: root/examples/cxx/parser/library/library-pimpl.cxx
blob: 7a1e4846fadfe31d76eeb21718591c057a55462a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
// file      : examples/cxx/parser/library/library-pimpl.cxx
// copyright : not copyrighted - public domain

#include "library-pimpl.hxx"

namespace library
{
  // isbn_impl
  //
  isbn isbn_pimpl::
  post_isbn ()
  {
    return post_unsigned_int ();
  }

  // title_pimpl
  //
  void title_pimpl::
  _pre ()
  {
    title_.lang ("");
  }

  void title_pimpl::
  lang (const std::string& lang)
  {
    title_.lang (lang);
  }

  title title_pimpl::
  post_title ()
  {
    title_.assign (post_string ());
    return title_;
  }

  // genre_pimpl
  //
  genre genre_pimpl::
  post_genre ()
  {
    genre r (romance);
    std::string v (post_string ());

    if (v == "romance") r = romance; else
    if (v == "fiction") r = fiction; else
    if (v == "horror") r = horror; else
    if (v == "history") r = history; else
    if (v == "philosophy") r = philosophy;

    return r;
  }

  // person_pimpl
  //
  void person_pimpl::
  _pre ()
  {
    person_.died ("");
  }

  void person_pimpl::
  name (const std::string& name)
  {
    person_.name (name);
  }

  void person_pimpl::
  born (const std::string& born)
  {
    person_.born (born);
  }

  void person_pimpl::
  died (const std::string& died)
  {
    person_.died (died);
  }

  person person_pimpl::
  post_person ()
  {
    return person_;
  }

  // author_pimpl
  //
  void author_pimpl::
  _pre ()
  {
    person_pimpl::_pre ();
    author_.recommends ("");
  }

  void author_pimpl::
  recommends (const std::string& recommends)
  {
    author_.recommends (recommends);
  }

  author author_pimpl::
  post_author ()
  {
    person p (post_person ());

    author_.name (p.name ());
    author_.born (p.born ());
    author_.died (p.died ());

    return author_;
  }

  // book_pimpl
  //
  void book_pimpl::
  _pre ()
  {
    book_.author ().clear ();
  }

  void book_pimpl::
  isbn (library::isbn isbn)
  {
    book_.isbn (isbn);
  }

  void book_pimpl::
  title (const library::title& title)
  {
    book_.title (title);
  }

  void book_pimpl::
  genre (library::genre genre)
  {
    book_.genre (genre);
  }

  void book_pimpl::
  author (const library::author& author)
  {
    book_.author ().push_back (author);
  }

  void book_pimpl::
  available (bool available)
  {
    book_.available (available);
  }

  void book_pimpl::
  id (const std::string& id)
  {
    book_.id (id);
  }

  book book_pimpl::
  post_book ()
  {
    return book_;
  }

  // catalog_pimpl
  //
  void catalog_pimpl::
  _pre ()
  {
    catalog_.clear ();
  }

  void catalog_pimpl::
  book (const library::book& book)
  {
    catalog_.push_back (book);
  }

  catalog catalog_pimpl::
  post_catalog ()
  {
    return catalog_;
  }
}