summaryrefslogtreecommitdiff
path: root/odb-examples/container/person.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'odb-examples/container/person.hxx')
-rw-r--r--odb-examples/container/person.hxx99
1 files changed, 99 insertions, 0 deletions
diff --git a/odb-examples/container/person.hxx b/odb-examples/container/person.hxx
new file mode 100644
index 0000000..31b90a5
--- /dev/null
+++ b/odb-examples/container/person.hxx
@@ -0,0 +1,99 @@
+// file : container/person.hxx
+// copyright : not copyrighted - public domain
+
+#ifndef PERSON_HXX
+#define PERSON_HXX
+
+#include <set>
+#include <map>
+#include <vector>
+#include <string>
+
+#include <odb/core.hxx>
+
+typedef std::vector<std::string> names;
+typedef std::set<std::string> emails;
+typedef std::map<unsigned short, float> age_weight_map;
+
+#pragma db object
+class person
+{
+public:
+ person (const std::string& first, const std::string& last)
+ : first_ (first), last_ (last)
+ {
+ }
+
+ const std::string&
+ first () const
+ {
+ return first_;
+ }
+
+ const std::string&
+ last () const
+ {
+ return last_;
+ }
+
+ // Nicknames.
+ //
+ const names&
+ nicknames () const
+ {
+ return nicknames_;
+ }
+
+ names&
+ nicknames ()
+ {
+ return nicknames_;
+ }
+
+ // Emails.
+ //
+ typedef ::emails emails_type;
+
+ const emails_type&
+ emails () const
+ {
+ return emails_;
+ }
+
+ emails_type&
+ emails ()
+ {
+ return emails_;
+ }
+
+ // Age-to-weight map.
+ //
+ const age_weight_map&
+ age_weight () const
+ {
+ return age_weight_;
+ }
+
+ age_weight_map&
+ age_weight ()
+ {
+ return age_weight_;
+ }
+
+private:
+ friend class odb::access;
+
+ person () {}
+
+ #pragma db id auto
+ unsigned long id_;
+
+ std::string first_;
+ std::string last_;
+
+ names nicknames_;
+ emails_type emails_;
+ age_weight_map age_weight_;
+};
+
+#endif // PERSON_HXX