Skip to content

Commit dc0dc3e

Browse files
committed
cursor and gridfs documentation
also: * changes to the gridfs api to make it complete
1 parent 2e05df2 commit dc0dc3e

File tree

54 files changed

+1678
-53
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1678
-53
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ mongoc-tail
2929
*.pc
3030
stamp-h1
3131
*.swp
32+
example-client
33+
example-gridfs
3234
repltest1
3335
shardtest1
3436
shardtest2

doc/Makefile.include

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
MAN3 = $(MONGOC_SYMBOLS)
1+
MAN3 = $(top_srcdir)/doc/todo.3 $(MONGOC_SYMBOLS)
22

33
MAN7 = \
44
$(top_srcdir)/doc/mongoc_client.7 \
55
$(top_srcdir)/doc/mongoc_client_pool.7 \
66
$(top_srcdir)/doc/mongoc_collection.7 \
7+
$(top_srcdir)/doc/mongoc_cursor.7 \
78
$(top_srcdir)/doc/mongoc_database.7 \
9+
$(top_srcdir)/doc/mongoc_gridfs.7 \
10+
$(top_srcdir)/doc/mongoc_gridfs_file.7 \
11+
$(top_srcdir)/doc/mongoc_gridfs_file_list.7 \
812
$(top_srcdir)/doc/mongoc_uri.7
913

1014
MAN_DOC = $(MAN1) $(MAN3) $(MAN7)
@@ -35,14 +39,30 @@ SUFFIXES=.html .txt .xml .3 .7
3539
EXAMPLE_DIR = $(abs_top_srcdir)/examples
3640

3741
.txt.html:
38-
asciidoc -d manpage -b xhtml11 -f $(top_srcdir)/doc/asciidoc.conf \
39-
-aexamples=$(EXAMPLE_DIR) -amongoc_version=@PACKAGE_VERSION@ -o$@ $<
42+
if [ -L $< ]; then \
43+
ln -fs `basename \`readlink $<\` .txt`.html $@; \
44+
else \
45+
asciidoc -d manpage -b xhtml11 -f $(top_srcdir)/doc/asciidoc.conf \
46+
-aexamples=$(EXAMPLE_DIR) -amongoc_version=@PACKAGE_VERSION@ -o$@ $<; \
47+
fi
4048
.txt.xml:
41-
asciidoc -d manpage -b docbook -f $(top_srcdir)/doc/asciidoc.conf \
42-
-aexamples=$(EXAMPLE_DIR) -amongoc_version=@PACKAGE_VERSION@ \
43-
-amongoc_manname=$(*F) -o$@ $<
49+
if [ -L $< ]; then \
50+
ln -fs `basename \`readlink $<\` .txt`.xml $@; \
51+
else \
52+
asciidoc -d manpage -b docbook -f $(top_srcdir)/doc/asciidoc.conf \
53+
-aexamples=$(EXAMPLE_DIR) -amongoc_version=@PACKAGE_VERSION@ \
54+
-amongoc_manname=$(*F) -o$@ $<; \
55+
fi
4456
.xml.3:
45-
xmlto man -o $(top_srcdir)/doc $<
57+
if [ -L $< ]; then \
58+
ln -fs `basename \`readlink $<\` .xml`.3 $@; \
59+
else \
60+
xmlto man -o $(top_srcdir)/doc $<; \
61+
fi
4662
.xml.7:
47-
xmlto man -o $(top_srcdir)/doc $<
63+
if [ -L $< ]; then \
64+
ln -fs `basename \`readlink $<\` .xml`.3 $@; \
65+
else \
66+
xmlto man -o $(top_srcdir)/doc $<; \
67+
fi
4868
endif

doc/mongoc_cursor.txt

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
mongoc_cursor(7)
2+
================
3+
4+
5+
NAME
6+
----
7+
mongoc_cursor - MongoDB cursor connection abstraction
8+
9+
10+
SYNOPSIS
11+
--------
12+
13+
[source, c]
14+
---------------
15+
const bson_t *doc;
16+
mongoc_cursor_t * cursor;
17+
18+
cursor = mongoc_collection_find (collection,
19+
MONGOC_QUERY_NONE,
20+
0,
21+
0,
22+
&query,
23+
NULL, /* Fields, NULL for all. */
24+
NULL); /* Read Prefs, NULL for default */
25+
26+
while (mongoc_cursor_next (cursor, &doc)) {
27+
do_something(doc);
28+
}
29+
---------------
30+
31+
32+
DESCRIPTION
33+
-----------
34+
_mongoc_cursor_ provides access to a MongoDB query cursor. It wraps up the
35+
wire protocol negotation required to initiate a query and retreive an unknown
36+
number of documents.
37+
38+
Cursors are lazy, meaning that no network traffic occurs until the first
39+
linkmongoc:mongoc_cursor_next[3].
40+
41+
At that point we can:
42+
43+
* Determine which host we've connected to with
44+
linkmongoc:mongoc_cursor_get_host[3].
45+
* Retreive more records with repeated calls to linkmongoc:mongoc_cursor_next[3]
46+
* Test for more records with linkmongoc:mongoc_cursor_more[3]
47+
* Clone a query to repeat execution at a later point with
48+
linkmongoc:mongoc_cursor_clone[3]
49+
* Test for errors with linkmongoc:mongoc_cursor_error[3]
50+
51+
52+
THREAD SAFETY
53+
-------------
54+
55+
_mongoc_cursor_ is *NOT* thread-safe and should only be used from one thread at
56+
a time.
57+
58+
LIFECYCLE
59+
---------
60+
61+
The bson objects set in linkmongoc:mongoc_cursor_next[3] are ephemeral and good
62+
until the next call. linkmongoc:mongoc_cursor_destroy[3] must be called to
63+
clean up, even in the case of exhausted cursors.
64+
65+
EXAMPLE
66+
-------
67+
68+
The following example connects to a single MongoDB instance and performs a
69+
simple query against it. The resulting documents are printed as 'JSON' to
70+
standard output.
71+
72+
[source,c]
73+
---------------
74+
include::{examples}/example-client.c[]
75+
---------------
76+
77+
78+
SEE ALSO
79+
--------
80+
81+
FUNCTIONS
82+
~~~~~~~~~
83+
84+
linkmongoc:mongoc_cursor_clone[3]
85+
linkmongoc:mongoc_cursor_destroy[3]
86+
linkmongoc:mongoc_cursor_error[3]
87+
linkmongoc:mongoc_cursor_get_host[3]
88+
linkmongoc:mongoc_cursor_more[3]
89+
linkmongoc:mongoc_cursor_next[3]
90+
91+
RELATED
92+
~~~~~~~
93+
94+
linkmongoc:mongoc_client[7]
95+
linkmongoc:mongoc_collection[7]
96+
97+
98+
AUTHORS
99+
-------
100+
101+
This page was written by MongoDB Inc.

doc/mongoc_cursor_clone.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

doc/mongoc_cursor_clone.txt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
mongoc_cursor_clone(3)
2+
======================
3+
4+
5+
NAME
6+
----
7+
mongoc_cursor_clone - clone a mongoc cursor
8+
9+
10+
SYNOPSIS
11+
--------
12+
[source,c]
13+
-----------------------
14+
mongoc_cursor_t *
15+
mongoc_cursor_clone (const mongoc_cursor_t *cursor);
16+
-----------------------
17+
18+
19+
DESCRIPTION
20+
-----------
21+
The _mongoc_cursor_clone()_ function shall create a copy of a
22+
linkmongoc:mongoc_cursor[7].
23+
24+
Clone copies all of the set up behind a cursor. I.e. the query, fields, flags,
25+
etc. It does not copy any run time state.
26+
27+
28+
RETURN VALUE
29+
------------
30+
The _mongoc_cursor_clone()_ function returns a new linkmongoc:mongoc_cursor[7].
31+
32+
ERRORS
33+
------
34+
No errors are defined.
35+
36+
37+
SEE ALSO
38+
--------
39+
linkmongoc:mongoc_cursor[7]
40+
41+
42+
AUTHORS
43+
-------
44+
45+
This page was written by MongoDB Inc.

doc/mongoc_cursor_destroy.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

doc/mongoc_cursor_destroy.txt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
mongoc_cursor_destroy(3)
2+
========================
3+
4+
5+
NAME
6+
----
7+
mongoc_cursor_destroy - destroy a mongoc cursor
8+
9+
10+
SYNOPSIS
11+
--------
12+
[source,c]
13+
-----------------------
14+
void
15+
mongoc_cursor_destroy (mongoc_cursor_t *cursor);
16+
-----------------------
17+
18+
19+
DESCRIPTION
20+
-----------
21+
The _mongoc_cursor_destroy()_ function shall destroy the cursor referenced by
22+
the 'cursor' argument and any resources associated with the cursor.
23+
24+
RETURN VALUE
25+
------------
26+
The _mongoc_cursor_destroy()_ function has no return value.
27+
28+
ERRORS
29+
------
30+
No errors are defined.
31+
32+
33+
SEE ALSO
34+
--------
35+
linkmongoc:mongoc_cursor[7]
36+
37+
38+
AUTHORS
39+
-------
40+
41+
This page was written by MongoDB Inc.

doc/mongoc_cursor_error.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

doc/mongoc_cursor_error.txt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
mongoc_cursor_error(3)
2+
======================
3+
4+
5+
NAME
6+
----
7+
mongoc_cursor_error - get errors on a mongoc cursor
8+
9+
10+
SYNOPSIS
11+
--------
12+
[source,c]
13+
-----------------------
14+
bson_bool_t
15+
mongoc_cursor_error (mongoc_cursor_t *cursor,
16+
bson_error_t *error);
17+
-----------------------
18+
19+
20+
DESCRIPTION
21+
-----------
22+
The _mongoc_cursor_error()_ function shall set 'error' with the value of the
23+
last error on the 'cursor'.
24+
25+
RETURN VALUE
26+
------------
27+
The _mongoc_cursor_error()_ function returns true if there is an error on the
28+
cursor. In the absence of an error, it returns false.
29+
30+
ERRORS
31+
------
32+
No errors are defined.
33+
34+
35+
SEE ALSO
36+
--------
37+
linkmongoc:mongoc_cursor[7]
38+
39+
40+
AUTHORS
41+
-------
42+
43+
This page was written by MongoDB Inc.

doc/mongoc_cursor_get_host.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)