forked from saalweachter/MongoXX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmongoxx.html
More file actions
123 lines (117 loc) · 4.03 KB
/
mongoxx.html
File metadata and controls
123 lines (117 loc) · 4.03 KB
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
<html>
<head>
<title>Mongo++ Documentation</title>
</head>
<body style="margin-right: 10%; margin-left: 10%; text-align: justify;
line-height: 1.2em;">
<h1>Mongo++</h1>
Mongo++ is a C++ library for accessing a Mongo database. It is open
sourced under the MIT license; see the LICENSE file for details.
<hr>
<h2><code>mongoxx::Mapper<T></code></h2>
<code>Mapper<T></code> provides the interface to map between your local
classes and BSON objects. As a user, you will care about the
following methods:
<blockquote>
<dl>
<dt style="text-align: left">
<code>template <typename U> Mapper&
add_field(<nobr>std::string const& name,</nobr> <nobr>U T::*field);</nobr></code>
</dt>
<dd>
All <code>add_field</code> methods are used to add a field of our
target class, <code>T</code>, to the mapper. The field of the offer
will be written to and read from a field named <code>name</code> in
the BSON object.
</dd>
<br/>
<dt style="text-align: left">
<code>template <typename U> Mapper& add_field(<nobr>std::string const&
name,</nobr> <nobr>U (T::*getter)() const,</nobr> <nobr>void (T::*setter)(U));</nobr></code>
</dt>
<dd>
This version of the <code>add_field</code> method is used to add a
field which is accessible through a getter and setter member
function.
</dd>
<br/>
<dt style="text-align: left">
<code>template <typename U> Mapper&
add_field(<nobr>std::string const& name,</nobr> <nobr>U const& (T::*getter)() const,</nobr> <nobr>void (T::*setter)(U const&));</nobr></code>
</dt>
<dd>
This version of the <code>add_field</code> method is used to add a
field which is accessible through a getter and setter member function, and when
the type of the field is a non-primitive type being passed as a
const reference.
</dd>
</dl>
</blockquote>
<h2><code>mongoxx::Table<T></code></h2>
A <code>Table<T></code> is a <code>Mapper<T></code> plus a
collection name (or namespace). Generally, you will just construct a
<code>Table<T></code> and then pass it to other classes'
functions.
<blockquote>
<dl>
<dt style="text-align: left">
<code>Table(<nobr>std::string const& collection,</nobr> <nobr>Mapper<T> const& mapper);</nobr></code>
</dt>
<dd>
Basic constructor.
</dd>
<br/>
<dt style="text-align: left">
<code>Table(std::string const& collection);</code>
</dt>
<dd>
When this constructor is used, you'll need to call the
<code>add_field</code> methods on the Table<T> object.
</dd>
<br/>
<dt style="text-align: left">
<code>template <typename U> Field<T, U> operator[](U
T::*member) const;</code>
</dt>
<dd>
The <code>operator []</code> operator is a convenience function
for accessing the field() function. It allows you to refer to
mapped fields as <code>table[&Class::member]</code> in filters and
update expressions.
</dd>
<br/>
<dt style="text-align: left">
<code>template <typename U> Table& add_field(std::string
const& name, U T::*field);</code>
</dt>
<dd>
Calls the <code>add_field</code> method on the underlying
<code>Mapper<T></code>.
</dd>
<br/>
<dt style="text-align: left">
<code>template <typename U> Table& add_field(<nobr>std::string
const& name</nobr>, <nobr>U (T::*getter)()</nobr>, <nobr>void (T::*setter)(U));</nobr></code>
</dt>
<dd>
Calls the <code>add_field</code> method on the underlying
<code>Mapper<T></code>.
</dd>
</dl>
</blockquote>
<h2><code>mongoxx::Session</code></h2>
Session maintains the database connection and provides the entry
functions to most of the library.
<blockquote>
<dl>
<dt style="text-align: left">
<code>template <typename T> Query<T> query(<nobr>std::string const& collection,</nobr> <nobr>Mapper<T> const* mapper);</nobr></code>
</dt>
<dt style="text-align: left">
<code>template <typename T> Query<T> query(Table<T> const& table);</code>
</dt>
<dd>
</dd>
</dl>
</blockquote>
</body> </html>