aboutsummaryrefslogtreecommitdiff
path: root/examples/cxx/serializer/library/library-simpl-tiein.cxx
blob: 258195ba8f80f934017443a2d1febef0499ad196 (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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
// file      : examples/cxx/serializer/library/library-simpl-tiein.cxx
// copyright : not copyrighted - public domain

#include "library-simpl-tiein.hxx"

namespace library
{
  using namespace xml_schema;

  // isbn_simpl
  //
  isbn_simpl::
  isbn_simpl ()
      : isbn_sskel (&base_impl_)
  {
  }

  void isbn_simpl::
  pre (isbn n)
  {
    base_impl_.pre (n);
  }

  // title_simpl
  //
  title_simpl::
  title_simpl ()
      : title_sskel (&base_impl_)
  {
  }

  void title_simpl::
  pre (const title& t)
  {
    base_impl_.pre (t);
    title_ = &t;
  }

  bool title_simpl::
  lang_present ()
  {
    return !title_->lang ().empty ();
  }

  std::string title_simpl::
  lang ()
  {
    return title_->lang ();
  }

  // genre_simpl
  //
  genre_simpl::
  genre_simpl ()
      : genre_sskel (&base_impl_)
  {
  }

  const char* genre_strings[] =
  {
    "romance",
    "fiction",
    "horror",
    "history",
    "philosophy"
  };

  void genre_simpl::
  pre (genre g)
  {
    base_impl_.pre (genre_strings[g]);
  }

  // person_simpl
  //
  void person_simpl::
  pre (const person& p)
  {
    person_ = &p;
  }

  std::string person_simpl::
  name ()
  {
    return person_->name ();
  }

  std::string person_simpl::
  born ()
  {
    return person_->born ();
  }

  bool person_simpl::
  died_present ()
  {
    return !person_->died ().empty ();
  }

  std::string person_simpl::
  died ()
  {
    return person_->died ();
  }

  // author_simpl
  //
  author_simpl::
  author_simpl ()
      : author_sskel (&base_impl_)
  {
  }

  void author_simpl::
  pre (const author& a)
  {
    base_impl_.pre (a);
    author_ = &a;
  }

  bool author_simpl::
  recommends_present ()
  {
    return !author_->recommends ().empty ();
  }

  std::string author_simpl::
  recommends ()
  {
    return author_->recommends ();
  }

  // book_simpl
  //

  void book_simpl::
  pre (const book& b)
  {
    book_ = &b;
    ai_ = b.author ().begin ();
  }

  library::isbn book_simpl::
  isbn ()
  {
    return book_->isbn ();
  }

  const library::title& book_simpl::
  title ()
  {
    return book_->title ();
  }


  library::genre book_simpl::
  genre ()
  {
    return book_->genre ();
  }

  bool book_simpl::
  author_next ()
  {
    return ai_ != book_->author ().end ();
  }

  const library::author& book_simpl::
  author ()
  {
    return *ai_++;
  }

  bool book_simpl::
  available ()
  {
    return book_->available ();
  }

  std::string book_simpl::
  id ()
  {
    return book_->id ();
  }

  // catalog_simpl
  //
  void catalog_simpl::
  pre (const catalog& c)
  {
    catalog_ = &c;
    ci_ = c.begin ();
  }

  bool catalog_simpl::
  book_next ()
  {
    return ci_ != catalog_->end ();
  }

  const library::book& catalog_simpl::
  book ()
  {
    return *ci_++;
  }
}