Skip to content

Commit 0a61fae

Browse files
committed
Merge branch '3.1-dev'
2 parents 4506b41 + 22f6034 commit 0a61fae

File tree

137 files changed

+5773
-951
lines changed

Some content is hidden

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

137 files changed

+5773
-951
lines changed

.mci.yml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ tasks:
189189
commands:
190190
- func: "install_c_driver"
191191
vars:
192-
MONGOC_VERSION: 1.4.2
192+
MONGOC_VERSION: 1.5.0
193193
- func: "compile"
194194
- func: "test"
195195

@@ -327,22 +327,21 @@ buildvariants:
327327
- name: compile_and_test_with_mongoc_current
328328
- name: compile_and_test_with_mongoc_master
329329

330-
# Doesn't have cmake BUILD-2154
331-
# - name: ubuntu1604-zseries
332-
# display_name: "s390x Ubuntu 16.04"
333-
# batchtime: 1440 # 1 day
334-
# expansions:
335-
# build_type: "Release"
336-
# source: *ubuntu_s390x_source
337-
# tar_options: *linux_tar_options
338-
# compile_concurrency: *linux_compile_concurrency
339-
# cdriver_configure_flags: *linux_cdriver_configure_flags
340-
# cmake_path: *ubuntu_zap_cmake_path
341-
# run_on:
342-
# - ubuntu1604-zseries-small
343-
# tasks:
344-
# - name: compile_and_test_with_mongoc_current
345-
# - name: compile_and_test_with_mongoc_master
330+
- name: ubuntu1604-zseries
331+
display_name: "s390x Ubuntu 16.04"
332+
batchtime: 1440 # 1 day
333+
expansions:
334+
build_type: "Release"
335+
source: *ubuntu_s390x_source
336+
tar_options: *linux_tar_options
337+
compile_concurrency: *linux_compile_concurrency
338+
cdriver_configure_flags: *linux_cdriver_configure_flags
339+
cmake_path: *ubuntu_zap_cmake_path
340+
run_on:
341+
- ubuntu1604-zseries-small
342+
tasks:
343+
- name: compile_and_test_with_mongoc_current
344+
- name: compile_and_test_with_mongoc_master
346345

347346
- name: power8-ubuntu1604
348347
display_name: "ppc64le Ubuntu 16.04"

.travis.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ before_install:
3939
- sudo apt-get update -qq
4040

4141
# Mongo C Driver
42-
# TODO switch master (branch for current 1.3 dev) to r1.3 when released
43-
- git clone -b '1.3.4' --single-branch https://github.com/mongodb/mongo-c-driver.git
42+
- git clone https://github.com/mongodb/mongo-c-driver.git
4443

4544
install:
4645
# GCC
@@ -59,7 +58,14 @@ install:
5958
- sudo apt-get install cmake
6059

6160
# Install Mongo C Driver
62-
- pushd mongo-c-driver; ./autogen.sh --enable-tests=no --enable-examples=no --with-libbson=bundled; make; sudo make install; popd;
61+
- pushd mongo-c-driver
62+
63+
# TODO: Update this to our real minimum for the C++11 driver 3.1 release, once known.
64+
- git checkout 1.5.0
65+
66+
- ./autogen.sh --enable-tests=no --enable-examples=no --with-libbson=bundled; make; sudo make install
67+
68+
- popd
6369

6470
before_script:
6571
- $CC --version

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ set(CMAKE_CXX_EXTENSIONS OFF)
6161
include(GenerateExportHeader)
6262
include(InstallRequiredSystemLibraries)
6363

64+
# Allow the user to decie whether to install the shared libaries. Note that we always build them,
65+
# since otherwise it makes the CMake logic very complex, but setting BUILD_SHARED_LIBS=Off will at
66+
# least disable installing them.
67+
option(BUILD_SHARED_LIBS "Install shared libraries" ON)
68+
6469
# If the user did not customize the install prefix,
6570
# set it to live under build so we don't inadverently pollute /usr/local
6671
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
# MongoDB C++ Driver [![Build Status](https://travis-ci.org/mongodb/mongo-cxx-driver.svg?branch=master)](https://travis-ci.org/mongodb/mongo-cxx-driver)[![Windows Build Status](https://ci.appveyor.com/api/projects/status/w95xuowdjpr0img1/branch/master?svg=true)](https://ci.appveyor.com/project/markbenvenuto/mongo-cxx-driver)
1+
# MongoDB C++ Driver [![Build Status](https://travis-ci.org/mongodb/mongo-cxx-driver.svg?branch=3.1-dev)](https://travis-ci.org/mongodb/mongo-cxx-driver)[![Windows Build Status](https://ci.appveyor.com/api/projects/status/w95xuowdjpr0img1/branch/3.1-dev?svg=true)](https://ci.appveyor.com/project/markbenvenuto/mongo-cxx-driver)
22

33
Welcome to the MongoDB C++ Driver!
44

5-
This branch contains `mongocxx`, the new C++11 driver, and is the recommended
6-
branch for all users.
5+
This branch contains work-in-progress for `mongocxx` version 3.1.
6+
7+
End-users should use a tagged release or the `master` branch instead.
78

89
## Resources
910

appveyor.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ os: Visual Studio 2015
1717
test: off
1818

1919
build_script:
20-
- cmd: git clone -b "1.3.4" --single-branch https://github.com/mongodb/mongo-c-driver.git
20+
- cmd: git clone https://github.com/mongodb/mongo-c-driver.git
2121
- cmd: cd mongo-c-driver
22+
# TODO: Update this to our real minimum for the C++11 driver 3.1 release, once known.
23+
- cmd: git checkout 1.5.0
2224
- cmd: git submodule init
2325
- cmd: git submodule update
2426
- cmd: cd src\libbson

docs/content/mongocxx-v3/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The mongocxx driver builds on top of the MongoDB C driver.
2424

2525
* For mongocxx-3.0.x, we recommend the latest stable version of libmongoc
2626
(currently version 1.4.2 at the time this page was written).
27-
* For mongocxx-3.1.0-beta0 or later, libmongoc 1.5.0-rc6 or later is
27+
* For mongocxx-3.1.0-beta0 or later, libmongoc 1.5.0 or later is
2828
required.
2929

3030
Unless you know that your package manager offers a high-enough version, you

docs/content/mongocxx-v3/working-with-bson.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,22 @@ if (store_ele) {
223223
```
224224

225225
This feature is shown in more detail in [this example](https://github.com/mongodb/mongo-cxx-driver/blob/master/examples/bsoncxx/getting_values.cpp) and [this example](https://github.com/mongodb/mongo-cxx-driver/blob/master/examples/bsoncxx/view_and_value.cpp).
226+
227+
### BSON Types
228+
229+
The [BSON specification](http://bsonspec.org/spec.html) provides a list
230+
of supported types. These are represented in C++ using the
231+
[b_xxx](https://mongodb.github.io/mongo-cxx-driver/api/current/classes.html#letter_B)
232+
type wrappers.
233+
234+
Some BSON types don't necessarily have a native representation to wrap and
235+
are implemented via special classes.
236+
237+
#### Decimal128
238+
239+
The `bsoncxx::decimal128` class represents a 128-bit IEEE 754-2008 decimal
240+
floating point value. We expect users to convert these to and from
241+
strings, but provide access to the low and high 64-bit values if users need
242+
to convert to a native decimal128 type.
243+
244+
You can see how to work with `bsoncxx::decimal128` in [this example](https://github.com/mongodb/mongo-cxx-driver/blob/master/examples/bsoncxx/decimal128.cpp).

examples/bsoncxx/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ set(BSONCXX_EXAMPLES
2525
builder_basic.cpp
2626
builder_stream.cpp
2727
builder_stream_customization.cpp
28+
decimal128.cpp
2829
getting_values.cpp
2930
view_and_value.cpp
3031
)

examples/bsoncxx/decimal128.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Copyright 2015 MongoDB Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include <cstdlib>
16+
#include <iostream>
17+
18+
#include <bsoncxx/builder/stream/document.hpp>
19+
#include <bsoncxx/decimal128.hpp>
20+
#include <bsoncxx/exception/exception.hpp>
21+
#include <bsoncxx/types.hpp>
22+
23+
using namespace bsoncxx;
24+
25+
int main(int, char**) {
26+
// Convert a string to BSON Decimal128.
27+
decimal128 d128;
28+
try {
29+
d128 = decimal128{"1.234E+3456"};
30+
} catch (const bsoncxx::exception& e) {
31+
// The example won't fail, but in general, arbitrary strings
32+
// might not convert properly.
33+
return EXIT_FAILURE;
34+
}
35+
36+
// Add it to a BSON document.
37+
builder::stream::document build_doc;
38+
build_doc << "counter" << d128;
39+
auto doc = document::value{build_doc.extract()};
40+
41+
// Extract a BSON Decimal128 from a document view.
42+
auto view = doc.view();
43+
auto d128copy = view["counter"].get_decimal128().value;
44+
45+
// Convert it back to a string.
46+
std::cout << "Counter is " << d128copy.to_string() << std::endl;
47+
48+
return EXIT_SUCCESS;
49+
}

src/bsoncxx/CMakeLists.txt

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ project(BSONCXX)
1717
# Update these as needed.
1818
# TODO: read from file
1919
set(BSONCXX_VERSION_MAJOR 3)
20-
set(BSONCXX_VERSION_MINOR 0)
21-
set(BSONCXX_VERSION_PATCH 4)
22-
set(BSONCXX_VERSION_EXTRA "-pre")
20+
set(BSONCXX_VERSION_MINOR 1)
21+
set(BSONCXX_VERSION_PATCH 0)
22+
set(BSONCXX_VERSION_EXTRA "-rc0-pre")
2323
set(BSONCXX_ABI_VERSION _noabi)
2424

2525
set(BSONCXX_POLY_USE_MNMLSTC_DEFAULT ON)
@@ -62,7 +62,7 @@ set(BSONCXX_VERSION ${BSONCXX_VERSION_MAJOR}.${BSONCXX_VERSION_MINOR}.${BSONCXX_
6262
set(BSONCXX_INLINE_NAMESPACE "v${BSONCXX_ABI_VERSION}")
6363
set(BSONCXX_HEADER_INSTALL_DIR "include/bsoncxx/${BSONCXX_INLINE_NAMESPACE}" CACHE INTERNAL "")
6464

65-
set(LIBBSON_REQUIRED_VERSION 1.3.4)
65+
set(LIBBSON_REQUIRED_VERSION 1.5.0)
6666
set(LIBBSON_REQUIRED_ABI_VERSION 1.0)
6767
find_package(LibBSON ${LIBBSON_REQUIRED_VERSION} REQUIRED)
6868

@@ -74,6 +74,7 @@ set(bsoncxx_sources
7474
array/value.cpp
7575
array/view.cpp
7676
builder/core.cpp
77+
decimal128.cpp
7778
document/element.cpp
7879
document/value.cpp
7980
document/view.cpp
@@ -167,12 +168,14 @@ install(FILES
167168
COMPONENT dev
168169
)
169170

170-
install(TARGETS
171-
bsoncxx
172-
RUNTIME DESTINATION bin COMPONENT runtime
173-
LIBRARY DESTINATION lib COMPONENT runtime
174-
ARCHIVE DESTINATION lib COMPONENT dev
175-
)
171+
if (BUILD_SHARED_LIBS)
172+
install(TARGETS
173+
bsoncxx
174+
RUNTIME DESTINATION bin COMPONENT runtime
175+
LIBRARY DESTINATION lib COMPONENT runtime
176+
ARCHIVE DESTINATION lib COMPONENT dev
177+
)
178+
endif()
176179

177180
install(TARGETS
178181
bsoncxx_static

0 commit comments

Comments
 (0)