├── .gitignore ├── CMakeLists.txt ├── COPYRIGHT ├── Changes ├── INSTALL ├── META.json ├── README.md ├── pgbson ├── CMakeLists.txt ├── FindPostgres.cmake ├── mongo-cxx-driver-v2.4 │ ├── LICENSE.txt │ ├── SConstruct │ ├── buildscripts │ │ └── make_archive.py │ └── src │ │ ├── SConscript.client │ │ ├── mongo │ │ ├── base │ │ │ ├── configuration_variable_manager.cpp │ │ │ ├── configuration_variable_manager.h │ │ │ ├── counter.h │ │ │ ├── disallow_copying.h │ │ │ ├── error_codes.cpp │ │ │ ├── error_codes.err │ │ │ ├── error_codes.h │ │ │ ├── generate_error_codes.py │ │ │ ├── global_initializer.cpp │ │ │ ├── global_initializer.h │ │ │ ├── global_initializer_registerer.cpp │ │ │ ├── global_initializer_registerer.h │ │ │ ├── init.cpp │ │ │ ├── init.h │ │ │ ├── initializer.cpp │ │ │ ├── initializer.h │ │ │ ├── initializer_context.cpp │ │ │ ├── initializer_context.h │ │ │ ├── initializer_dependency_graph.cpp │ │ │ ├── initializer_dependency_graph.h │ │ │ ├── initializer_function.h │ │ │ ├── make_string_vector.cpp │ │ │ ├── make_string_vector.h │ │ │ ├── owned_pointer_map.h │ │ │ ├── owned_pointer_vector.h │ │ │ ├── parse_number.cpp │ │ │ ├── parse_number.h │ │ │ ├── status.cpp │ │ │ ├── status.h │ │ │ ├── string_data-inl.h │ │ │ ├── string_data.cpp │ │ │ └── string_data.h │ │ ├── bson │ │ │ ├── bson-inl.h │ │ │ ├── bson.h │ │ │ ├── bson_builder_base.h │ │ │ ├── bson_db.h │ │ │ ├── bson_field.h │ │ │ ├── bson_validate.cpp │ │ │ ├── bson_validate.h │ │ │ ├── bsondemo │ │ │ │ └── bsondemo.cpp │ │ │ ├── bsonelement.h │ │ │ ├── bsonmisc.h │ │ │ ├── bsonobj.h │ │ │ ├── bsonobjbuilder.h │ │ │ ├── bsonobjiterator.h │ │ │ ├── bsontypes.h │ │ │ ├── inline_decls.h │ │ │ ├── oid.cpp │ │ │ ├── oid.h │ │ │ ├── ordering.h │ │ │ └── util │ │ │ │ ├── atomic_int.h │ │ │ │ ├── bson_extract.cpp │ │ │ │ ├── bson_extract.h │ │ │ │ ├── builder.h │ │ │ │ └── misc.h │ │ ├── buildinfo.cpp │ │ ├── client │ │ │ ├── authlevel.h │ │ │ ├── clientAndShell.cpp │ │ │ ├── clientOnly-private.h │ │ │ ├── clientOnly.cpp │ │ │ ├── connection_factory.cpp │ │ │ ├── connpool.cpp │ │ │ ├── connpool.h │ │ │ ├── constants.h │ │ │ ├── dbclient.cpp │ │ │ ├── dbclient.h │ │ │ ├── dbclient_rs.cpp │ │ │ ├── dbclient_rs.h │ │ │ ├── dbclientcursor.cpp │ │ │ ├── dbclientcursor.h │ │ │ ├── dbclientinterface.h │ │ │ ├── dbclientmockcursor.h │ │ │ ├── distlock.h │ │ │ ├── examples │ │ │ │ ├── authTest.cpp │ │ │ │ ├── clientTest.cpp │ │ │ │ ├── first.cpp │ │ │ │ ├── httpClientTest.cpp │ │ │ │ ├── rs.cpp │ │ │ │ ├── second.cpp │ │ │ │ ├── tutorial.cpp │ │ │ │ └── whereExample.cpp │ │ │ ├── gridfs.cpp │ │ │ ├── gridfs.h │ │ │ ├── model.cpp │ │ │ ├── model.h │ │ │ ├── parallel.h │ │ │ ├── redef_macros.h │ │ │ ├── sasl_client_authenticate.cpp │ │ │ ├── sasl_client_authenticate.h │ │ │ ├── sasl_client_authenticate_impl.cpp │ │ │ ├── sasl_client_session.cpp │ │ │ ├── sasl_client_session.h │ │ │ ├── syncclusterconnection.cpp │ │ │ ├── syncclusterconnection.h │ │ │ └── undef_macros.h │ │ ├── db │ │ │ ├── auth │ │ │ │ ├── action_set.h │ │ │ │ ├── action_type.h │ │ │ │ ├── action_types.txt │ │ │ │ ├── auth_external_state.h │ │ │ │ ├── auth_external_state_d.h │ │ │ │ ├── auth_external_state_mock.h │ │ │ │ ├── auth_external_state_s.h │ │ │ │ ├── auth_external_state_server_common.h │ │ │ │ ├── auth_index_d.h │ │ │ │ ├── authentication_session.h │ │ │ │ ├── authorization_manager.h │ │ │ │ ├── generate_action_types.py │ │ │ │ ├── mongo_authentication_session.h │ │ │ │ ├── principal.h │ │ │ │ ├── principal_name.h │ │ │ │ ├── principal_set.h │ │ │ │ ├── privilege.h │ │ │ │ ├── privilege_set.h │ │ │ │ └── security_key.h │ │ │ ├── background.h │ │ │ ├── btree.h │ │ │ ├── btree_stats.h │ │ │ ├── btreebuilder.h │ │ │ ├── btreecursor.h │ │ │ ├── btreeposition.h │ │ │ ├── cc_by_loc.h │ │ │ ├── client.h │ │ │ ├── client_basic.h │ │ │ ├── clientcursor.h │ │ │ ├── cloner.h │ │ │ ├── cmdline.h │ │ │ ├── collection.h │ │ │ ├── commands.h │ │ │ ├── curop-inl.h │ │ │ ├── curop.h │ │ │ ├── cursor.h │ │ │ ├── d_concurrency.h │ │ │ ├── d_globals.h │ │ │ ├── database.h │ │ │ ├── databaseholder.h │ │ │ ├── db.h │ │ │ ├── dbhelpers.h │ │ │ ├── dbmessage.cpp │ │ │ ├── dbmessage.h │ │ │ ├── dbwebserver.h │ │ │ ├── diskloc.h │ │ │ ├── dur.h │ │ │ ├── dur_commitjob.h │ │ │ ├── dur_journal.h │ │ │ ├── dur_journalformat.h │ │ │ ├── dur_journalimpl.h │ │ │ ├── dur_recover.h │ │ │ ├── dur_stats.h │ │ │ ├── durop.h │ │ │ ├── explain.h │ │ │ ├── extsort.h │ │ │ ├── field_ref.h │ │ │ ├── filever.h │ │ │ ├── hasher.h │ │ │ ├── hashindex.h │ │ │ ├── index.h │ │ │ ├── index_insertion_continuation.h │ │ │ ├── index_rebuilder.h │ │ │ ├── index_set.h │ │ │ ├── index_update.h │ │ │ ├── indexkey.h │ │ │ ├── initialize_server_global_state.h │ │ │ ├── instance.h │ │ │ ├── interrupt_status.h │ │ │ ├── interrupt_status_mongod.h │ │ │ ├── intervalbtreecursor.h │ │ │ ├── introspect.h │ │ │ ├── jsobj.cpp │ │ │ ├── jsobj.h │ │ │ ├── jsobjmanipulator.h │ │ │ ├── json.cpp │ │ │ ├── json.h │ │ │ ├── key.h │ │ │ ├── keypattern.h │ │ │ ├── kill_current_op.h │ │ │ ├── lasterror.cpp │ │ │ ├── lasterror.h │ │ │ ├── lockstat.h │ │ │ ├── lockstate.h │ │ │ ├── matcher.h │ │ │ ├── memconcept.h │ │ │ ├── minilex.h │ │ │ ├── module.h │ │ │ ├── mongommf.h │ │ │ ├── namespace-inl.h │ │ │ ├── namespace.cpp │ │ │ ├── namespace.h │ │ │ ├── namespace_details-inl.h │ │ │ ├── namespace_details.h │ │ │ ├── namespacestring.h │ │ │ ├── oplog.h │ │ │ ├── oplogreader.h │ │ │ ├── ops │ │ │ │ ├── count.h │ │ │ │ ├── delete.h │ │ │ │ ├── modifier_base.h │ │ │ │ ├── query.h │ │ │ │ ├── update.h │ │ │ │ └── update_internal.h │ │ │ ├── pagefault.h │ │ │ ├── pdfile.h │ │ │ ├── pdfile_private.h │ │ │ ├── pdfile_version.h │ │ │ ├── prefetch.h │ │ │ ├── projection.h │ │ │ ├── queryoptimizer.h │ │ │ ├── queryoptimizercursor.h │ │ │ ├── queryoptimizercursorimpl.h │ │ │ ├── querypattern.h │ │ │ ├── queryutil-inl.h │ │ │ ├── queryutil.h │ │ │ ├── record.h │ │ │ ├── repl.h │ │ │ ├── repl │ │ │ │ ├── bgsync.h │ │ │ │ ├── connections.h │ │ │ │ ├── health.h │ │ │ │ ├── multicmd.h │ │ │ │ ├── rs.h │ │ │ │ ├── rs_config.h │ │ │ │ ├── rs_exception.h │ │ │ │ ├── rs_member.h │ │ │ │ ├── rs_optime.h │ │ │ │ └── rs_sync.h │ │ │ ├── repl_block.h │ │ │ ├── replutil.h │ │ │ ├── resource.h │ │ │ ├── restapi.h │ │ │ ├── scanandorder.h │ │ │ ├── server_parameters.h │ │ │ ├── server_parameters_inline.h │ │ │ ├── sort_phase_one.h │ │ │ ├── stats │ │ │ │ ├── counters.h │ │ │ │ ├── fine_clock.h │ │ │ │ ├── service_stats.h │ │ │ │ ├── snapshots.h │ │ │ │ ├── timer_stats.h │ │ │ │ └── top.h │ │ │ ├── taskqueue.h │ │ │ └── ttl.h │ │ ├── pch.cpp │ │ ├── pch.h │ │ ├── platform │ │ │ ├── atomic_intrinsics.h │ │ │ ├── atomic_intrinsics_gcc.h │ │ │ ├── atomic_intrinsics_win32.h │ │ │ ├── atomic_word.h │ │ │ ├── basic.h │ │ │ ├── bits.h │ │ │ ├── compiler.h │ │ │ ├── compiler_gcc.h │ │ │ ├── compiler_msvc.h │ │ │ ├── cstdint.h │ │ │ ├── float_utils.h │ │ │ ├── random.cpp │ │ │ ├── random.h │ │ │ ├── strtoll.h │ │ │ ├── unordered_map.h │ │ │ ├── unordered_set.h │ │ │ └── windows_basic.h │ │ ├── s │ │ │ ├── balance.h │ │ │ ├── balancer_policy.h │ │ │ ├── chunk.h │ │ │ ├── chunk_diff.h │ │ │ ├── chunk_diff.hpp │ │ │ ├── chunk_version.h │ │ │ ├── client_info.h │ │ │ ├── cluster_client_internal.h │ │ │ ├── collection_manager.h │ │ │ ├── config.h │ │ │ ├── config_upgrade.h │ │ │ ├── config_upgrade_helpers.h │ │ │ ├── cursors.h │ │ │ ├── d_chunk_manager.h │ │ │ ├── d_logic.h │ │ │ ├── d_writeback.h │ │ │ ├── field_parser-inl.h │ │ │ ├── field_parser.h │ │ │ ├── grid.h │ │ │ ├── interrupt_status_mongos.h │ │ │ ├── metadata_loader.h │ │ │ ├── mongo_version_range.h │ │ │ ├── request.h │ │ │ ├── server.h │ │ │ ├── shard.h │ │ │ ├── shardkey.h │ │ │ ├── stale_exception.h │ │ │ ├── strategy.h │ │ │ ├── type_changelog.h │ │ │ ├── type_chunk.h │ │ │ ├── type_collection.h │ │ │ ├── type_config_version.h │ │ │ ├── type_database.h │ │ │ ├── type_lockpings.h │ │ │ ├── type_locks.h │ │ │ ├── type_mongos.h │ │ │ ├── type_settings.h │ │ │ ├── type_shard.h │ │ │ ├── type_tags.h │ │ │ ├── version_manager.h │ │ │ └── writeback_listener.h │ │ ├── scripting │ │ │ ├── bench.h │ │ │ ├── bson_template_evaluator.h │ │ │ ├── engine.h │ │ │ ├── engine_spidermonkey.h │ │ │ ├── engine_spidermonkey_internal.h │ │ │ ├── engine_v8.h │ │ │ ├── v8_db.h │ │ │ ├── v8_deadline_monitor.h │ │ │ ├── v8_profiler.h │ │ │ └── v8_utils.h │ │ ├── server.h │ │ ├── shell │ │ │ ├── linenoise.h │ │ │ ├── linenoise_utf8.h │ │ │ ├── mk_wcwidth.h │ │ │ ├── shell_utils.h │ │ │ ├── shell_utils_extended.h │ │ │ └── shell_utils_launcher.h │ │ ├── targetver.h │ │ └── util │ │ │ ├── admin_access.h │ │ │ ├── alignedbuilder.h │ │ │ ├── allocator.h │ │ │ ├── array.h │ │ │ ├── assert_util.cpp │ │ │ ├── assert_util.h │ │ │ ├── background.cpp │ │ │ ├── background.h │ │ │ ├── base64.cpp │ │ │ ├── base64.h │ │ │ ├── bson_util.h │ │ │ ├── bufreader.h │ │ │ ├── checksum.h │ │ │ ├── compress.h │ │ │ ├── concurrency │ │ │ ├── list.h │ │ │ ├── mapsf.h │ │ │ ├── msg.h │ │ │ ├── mutex.h │ │ │ ├── mutexdebugger.cpp │ │ │ ├── mutexdebugger.h │ │ │ ├── mvar.h │ │ │ ├── qlock.h │ │ │ ├── race.h │ │ │ ├── rwlock.h │ │ │ ├── rwlockimpl.cpp │ │ │ ├── rwlockimpl.h │ │ │ ├── shared_mutex_win.hpp │ │ │ ├── simplerwlock.h │ │ │ ├── spin_lock.cpp │ │ │ ├── spin_lock.h │ │ │ ├── synchronization.cpp │ │ │ ├── synchronization.h │ │ │ ├── task.cpp │ │ │ ├── task.h │ │ │ ├── thread_pool.cpp │ │ │ ├── thread_pool.h │ │ │ ├── threadlocal.h │ │ │ ├── ticketholder.h │ │ │ └── value.h │ │ │ ├── debug_util.cpp │ │ │ ├── debug_util.h │ │ │ ├── descriptive_stats-inl.h │ │ │ ├── descriptive_stats.h │ │ │ ├── elapsed_tracker.h │ │ │ ├── embedded_builder.h │ │ │ ├── exception_filter_win32.h │ │ │ ├── exit_code.h │ │ │ ├── fail_point.cpp │ │ │ ├── fail_point.h │ │ │ ├── fail_point_registry.cpp │ │ │ ├── fail_point_registry.h │ │ │ ├── fail_point_service.cpp │ │ │ ├── fail_point_service.h │ │ │ ├── file.cpp │ │ │ ├── file.h │ │ │ ├── file_allocator.cpp │ │ │ ├── file_allocator.h │ │ │ ├── goodies.h │ │ │ ├── hashtab.h │ │ │ ├── heapcheck.h │ │ │ ├── hex.h │ │ │ ├── histogram.cpp │ │ │ ├── histogram.h │ │ │ ├── intrusive_counter.cpp │ │ │ ├── intrusive_counter.h │ │ │ ├── log.cpp │ │ │ ├── log.h │ │ │ ├── logfile.h │ │ │ ├── lruishmap.h │ │ │ ├── map_util.h │ │ │ ├── md5.cpp │ │ │ ├── md5.h │ │ │ ├── md5.hpp │ │ │ ├── md5main.cpp │ │ │ ├── mmap.h │ │ │ ├── mongoutils │ │ │ ├── checksum.h │ │ │ ├── hash.h │ │ │ ├── html.h │ │ │ └── str.h │ │ │ ├── moveablebuffer.h │ │ │ ├── net │ │ │ ├── hostandport.h │ │ │ ├── httpclient.cpp │ │ │ ├── httpclient.h │ │ │ ├── listen.cpp │ │ │ ├── listen.h │ │ │ ├── message.cpp │ │ │ ├── message.h │ │ │ ├── message_port.cpp │ │ │ ├── message_port.h │ │ │ ├── message_server.h │ │ │ ├── miniwebserver.h │ │ │ ├── sock.cpp │ │ │ ├── sock.h │ │ │ ├── ssl_manager.cpp │ │ │ └── ssl_manager.h │ │ │ ├── ntservice.h │ │ │ ├── optime.h │ │ │ ├── password.cpp │ │ │ ├── password.h │ │ │ ├── paths.h │ │ │ ├── processinfo.cpp │ │ │ ├── processinfo.h │ │ │ ├── processinfo_linux2.cpp │ │ │ ├── progress_meter.h │ │ │ ├── queue.h │ │ │ ├── ramlog.cpp │ │ │ ├── ramlog.h │ │ │ ├── safe_num.h │ │ │ ├── scopeguard.h │ │ │ ├── sequence_util.h │ │ │ ├── signal_handlers.cpp │ │ │ ├── signal_handlers.h │ │ │ ├── stack_introspect.h │ │ │ ├── stacktrace.cpp │ │ │ ├── stacktrace.h │ │ │ ├── startup_test.h │ │ │ ├── string_map.h │ │ │ ├── string_map_internal.h │ │ │ ├── string_writer.h │ │ │ ├── stringutils.cpp │ │ │ ├── stringutils.h │ │ │ ├── systeminfo.h │ │ │ ├── text.cpp │ │ │ ├── text.h │ │ │ ├── time_support.cpp │ │ │ ├── time_support.h │ │ │ ├── timer-generic-inl.h │ │ │ ├── timer-inl.h │ │ │ ├── timer-posixclock-inl.h │ │ │ ├── timer-win32-inl.h │ │ │ ├── timer.cpp │ │ │ ├── timer.h │ │ │ ├── touch_pages.h │ │ │ ├── trace.cpp │ │ │ ├── trace.h │ │ │ ├── unordered_fast_key_table.h │ │ │ ├── unordered_fast_key_table_internal.h │ │ │ ├── util.cpp │ │ │ ├── version.cpp │ │ │ ├── version.h │ │ │ └── winutil.h │ │ └── third_party │ │ └── murmurhash3 │ │ ├── MurmurHash3.cpp │ │ └── MurmurHash3.h ├── pgbson--1.0.sql ├── pgbson.control ├── pgbson_exports.cpp ├── pgbson_internal.cpp └── pgbson_internal.hpp └── test ├── CMakeLists.txt ├── test.sh └── test.sql /.gitignore: -------------------------------------------------------------------------------- 1 | CMakeLists.txt.user* 2 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(postgresbson) 2 | cmake_minimum_required(VERSION 2.8) 3 | set(CMAKE_BUILD_TYPE Release) 4 | 5 | add_subdirectory(pgbson) 6 | add_subdirectory(test) 7 | -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Maciej Gajewski 2 | 3 | Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, 4 | provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies. 5 | 6 | IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, 7 | ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 8 | 9 | THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 10 | THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE AUTHOR HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 11 | 12 | --- 13 | 14 | Included MongoDB driver source is authored by 10Gen Inc. and available under the Apache license. 15 | 16 | -------------------------------------------------------------------------------- /Changes: -------------------------------------------------------------------------------- 1 | Revision history 2 | 3 | 0.5 - 21-11-2013 4 | 5 | All development to date. 6 | 7 | 1.0 - 8-12-2013 8 | 9 | * Small fixes to build system: FindPostgres.cmake created, Postgres location cached. 10 | * PGXN meta info included (David E. Wheeler) 11 | * This file created 12 | 13 | 1.0.1 - 12-1213 14 | 15 | * Compilation problems with Postgres 9.3 fixed (issue 3) 16 | 17 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Requires: 2 | cmake-2.8 3 | pg_config in path 4 | C++ compiler 5 | 6 | git clone https://github.com/maciekgajewski/postgresbson.git 7 | mkdir postgresbson-build 8 | cd postgresbson-build 9 | cmake ../postgresbson 10 | make 11 | make install # may require sudo 12 | make test 13 | -------------------------------------------------------------------------------- /META.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pgbson", 3 | "abstract": "BSON support for PostgreSQL", 4 | "description": "This PostgreSQL extension brings BSON data type, together with functions to create, inspect and manipulate BSON objects.", 5 | "version": "1.0.1", 6 | "maintainer": "Maciej Gajewski ", 7 | "license": "postgresql", 8 | "provides": { 9 | "pgbson": { 10 | "abstract": "BSON support for PostgreSQL", 11 | "file": "pgbson/pgbson_exports.cpp", 12 | "docfile": "README.md", 13 | "version": "1.0.1" 14 | } 15 | }, 16 | "prereqs": { 17 | "runtime": { 18 | "requires": { 19 | "PostgreSQL": "9.2.0" 20 | } 21 | } 22 | }, 23 | "resources": { 24 | "bugtracker": { 25 | "web": "https://github.com/maciekgajewski/postgresbson/issues/" 26 | }, 27 | "repository": { 28 | "url": "https://github.com/maciekgajewski/postgresbson.git", 29 | "web": "https://github.com/maciekgajewski/postgresbson/", 30 | "type": "git" 31 | } 32 | }, 33 | "no_index": { 34 | "directory": [ "pgbson/mongo-cxx-driver-v2.4" ] 35 | }, 36 | "generated_by": "David E. Wheeler", 37 | "meta-spec": { 38 | "version": "1.0.0", 39 | "url": "http://pgxn.org/meta/spec.txt" 40 | }, 41 | "tags": [ 42 | "json", 43 | "bson", 44 | "data type", 45 | "mongodb" 46 | ] 47 | } 48 | -------------------------------------------------------------------------------- /pgbson/FindPostgres.cmake: -------------------------------------------------------------------------------- 1 | #find postgres 2 | # variables set: PG_INCLUDEDIR, PG_LIBDIR, PG_EXTENSIONDIR 3 | 4 | if(NOT Postgres_INCLUDEDIR OR NOT Postgres_LIBDIR OR NOT Postgres_SHAREDIR) 5 | 6 | message(STATUS "Looking for PostgreSQL...") 7 | 8 | execute_process( 9 | COMMAND pg_config --includedir-server 10 | OUTPUT_VARIABLE OUT_Postgres_INCLUDEDIR OUTPUT_STRIP_TRAILING_WHITESPACE 11 | ) 12 | 13 | if(NOT OUT_Postgres_INCLUDEDIR) 14 | set(Postgres_FOUND FALSE) 15 | message(FATAL_ERROR "pg_config unavailable. Make sure it is in your path") 16 | else() 17 | set(Postgres_FOUND TRUE) 18 | endif() 19 | 20 | execute_process( 21 | COMMAND pg_config --libdir 22 | OUTPUT_VARIABLE OUT_Postgres_LIBDIR OUTPUT_STRIP_TRAILING_WHITESPACE 23 | ) 24 | 25 | execute_process( 26 | COMMAND pg_config --sharedir 27 | OUTPUT_VARIABLE OUT_Postgres_SHAREDIR OUTPUT_STRIP_TRAILING_WHITESPACE 28 | ) 29 | 30 | set(Postgres_INCLUDEDIR ${OUT_Postgres_INCLUDEDIR} CACHE PATH "Path to PostgreSQL server includes") 31 | set(Postgres_LIBDIR ${OUT_Postgres_LIBDIR} CACHE PATH "Path to PostgreSQL library") 32 | set(Postgres_SHAREDIR ${OUT_Postgres_SHAREDIR} CACHE PATH "Path to PostgreSQL shared objects") 33 | 34 | else() 35 | message(STATUS "PostgreSQL location loaded from cache") 36 | set(Postgres_FOUND TRUE) 37 | endif() 38 | 39 | if(Postgres_FOUND) 40 | message(STATUS "PostgreSQL found: includedir-server=${Postgres_INCLUDEDIR}, libdir=${Postgres_LIBDIR}, sharedir=${Postgres_SHAREDIR}") 41 | endif() 42 | 43 | set(Postgres_EXTENSIONDIR "${Postgres_SHAREDIR}/extension") 44 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/base/counter.h: -------------------------------------------------------------------------------- 1 | // counter.h 2 | 3 | /** 4 | * Copyright (C) 2008-2012 10gen Inc. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License, version 3, 8 | * as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "mongo/platform/atomic_word.h" 22 | #include "mongo/platform/cstdint.h" 23 | 24 | namespace mongo { 25 | /** 26 | * A 64bit (atomic) counter. 27 | * 28 | * The constructor allows setting the start value, and increment([int]) is used to change it. 29 | * 30 | * The value can be returned using get() or the (long long) function operator. 31 | */ 32 | class Counter64 { 33 | public: 34 | 35 | /** Atomically increment. */ 36 | void increment( uint64_t n = 1 ) { _counter.addAndFetch(n); } 37 | 38 | /** Atomically decrement. */ 39 | void decrement( uint64_t n = 1 ) { _counter.subtractAndFetch(n); } 40 | 41 | /** Return the current value */ 42 | long long get() const { return _counter.load(); } 43 | 44 | operator long long() const { return get(); } 45 | private: 46 | AtomicInt64 _counter; 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/base/disallow_copying.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2012 10gen 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 | 16 | #pragma once 17 | 18 | /** 19 | * Instruct the compiler not to create default copy constructor and assignment operator 20 | * for class "CLASS". Must be the _first_ or _last_ line of the class declaration. Prefer 21 | * to use it as the first line. 22 | * 23 | * Usage: 24 | * class Foo { 25 | * MONGO_DISALLOW_COPYING(Foo); 26 | * public: 27 | * ... 28 | * }; 29 | */ 30 | #define MONGO_DISALLOW_COPYING(CLASS) \ 31 | private: \ 32 | CLASS(const CLASS&); \ 33 | CLASS& operator=(const CLASS&) 34 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/base/error_codes.err: -------------------------------------------------------------------------------- 1 | # -*- python-mode -*- 2 | 3 | error_code("OK", 0) 4 | error_code("InternalError", 1) 5 | error_code("BadValue", 2) 6 | error_code("DuplicateKey", 3) 7 | error_code("NoSuchKey", 4) 8 | error_code("GraphContainsCycle", 5) 9 | error_code("HostUnreachable", 6) 10 | error_code("HostNotFound", 7) 11 | error_code("UnknownError", 8) 12 | error_code("FailedToParse", 9) 13 | error_code("CannotMutateObject", 10) 14 | error_code("UserNotFound", 11) 15 | error_code("UnsupportedFormat", 12) 16 | error_code("Unauthorized", 13) 17 | error_code("TypeMismatch", 14) 18 | error_code("Overflow", 15) 19 | error_code("InvalidLength", 16) 20 | error_code("ProtocolError", 17) 21 | error_code("AuthenticationFailed", 18) 22 | error_code("CannotReuseObject", 19) 23 | error_code("IllegalOperation", 20) 24 | error_code("EmptyArrayOperation", 21) 25 | error_code("InvalidBSON", 22) 26 | error_code("AlreadyInitialized", 23) 27 | error_code("LockTimeout", 24) 28 | error_code("RemoteValidationError", 25) 29 | 30 | error_class("NetworkError", ["HostUnreachable", "HostNotFound"]) 31 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/base/global_initializer.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2012 10gen 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 | 16 | #include "mongo/base/global_initializer.h" 17 | 18 | #include "mongo/base/initializer.h" 19 | 20 | namespace mongo { 21 | 22 | Initializer& getGlobalInitializer() { 23 | static Initializer theGlobalInitializer; 24 | return theGlobalInitializer; 25 | } 26 | 27 | namespace { 28 | 29 | // Make sure that getGlobalInitializer() is called at least once before main(), and so at least 30 | // once in a single-threaded context. Otherwise, static initialization inside 31 | // getGlobalInitializer() won't be thread-safe. 32 | Initializer* _theGlobalInitializer = &getGlobalInitializer(); 33 | 34 | } // namespace 35 | 36 | } // namespace mongo 37 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/base/global_initializer.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2012 10gen 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 | 16 | #pragma once 17 | 18 | namespace mongo { 19 | class Initializer; 20 | 21 | /** 22 | * Get the process-global initializer object. 23 | * 24 | * See mongo/base/initializer.h and mongo/base/init.h for information about process 25 | * initialization in mongo applications. 26 | */ 27 | Initializer& getGlobalInitializer(); 28 | 29 | } // namespace mongo 30 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/base/global_initializer_registerer.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2012 10gen 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 | 16 | #include "mongo/base/global_initializer_registerer.h" 17 | 18 | #include 19 | #include 20 | 21 | #include "mongo/base/global_initializer.h" 22 | #include "mongo/base/initializer.h" 23 | 24 | namespace mongo { 25 | 26 | GlobalInitializerRegisterer::GlobalInitializerRegisterer( 27 | const std::string& name, 28 | const InitializerFunction& fn, 29 | const std::vector& prerequisites, 30 | const std::vector& dependents) { 31 | 32 | Status status = getGlobalInitializer().getInitializerDependencyGraph().addInitializer( 33 | name, fn, prerequisites, dependents); 34 | 35 | 36 | if (Status::OK() != status) { 37 | std::cerr << "Attempt to add global initializer failed, status: " 38 | << status << std::endl; 39 | ::abort(); 40 | } 41 | } 42 | 43 | } // namespace mongo 44 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/base/global_initializer_registerer.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2012 10gen 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 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | #include "mongo/base/disallow_copying.h" 22 | #include "mongo/base/initializer_function.h" 23 | #include "mongo/base/status.h" 24 | 25 | namespace mongo { 26 | 27 | /** 28 | * Type representing the act of registering a process-global intialization function. 29 | * 30 | * Create a module-global instance of this type to register a new initializer, to be run by a 31 | * call to a variant of mongo::runGlobalInitializers(). See mongo/base/initializer.h, 32 | * mongo/base/init.h and mongo/base/initializer_dependency_graph.h for details. 33 | */ 34 | class GlobalInitializerRegisterer { 35 | MONGO_DISALLOW_COPYING(GlobalInitializerRegisterer); 36 | 37 | public: 38 | GlobalInitializerRegisterer(const std::string& name, 39 | const InitializerFunction& fn, 40 | const std::vector& prerequisites, 41 | const std::vector& dependents); 42 | }; 43 | 44 | } // namespace mongo 45 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/base/init.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2012 10gen 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 | 16 | #include "mongo/base/init.h" 17 | 18 | MONGO_INITIALIZER_GROUP(default, MONGO_NO_PREREQUISITES, MONGO_NO_DEPENDENTS) 19 | 20 | MONGO_INITIALIZER_GROUP(globalVariableConfigurationStarted, MONGO_NO_PREREQUISITES, MONGO_NO_DEPENDENTS) 21 | MONGO_INITIALIZER_GROUP(globalVariablesDeclared, ("globalVariableConfigurationStarted"), MONGO_NO_DEPENDENTS) 22 | MONGO_INITIALIZER_GROUP(globalVariablesSet, ("globalVariablesDeclared"), MONGO_NO_DEPENDENTS) 23 | MONGO_INITIALIZER_GROUP(globalVariablesConfigured, ("globalVariablesDeclared"), ("default")) 24 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/base/initializer_context.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2012 10gen 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 | 16 | #include "mongo/base/initializer_context.h" 17 | 18 | namespace mongo { 19 | 20 | InitializerContext::InitializerContext(const ArgumentVector& args, 21 | const EnvironmentMap& env, 22 | const ConfigurationVariableManager* configVariables) 23 | : _args(args), _env(env), _configVariables(configVariables) {} 24 | 25 | } // namespace mongo 26 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/base/initializer_context.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2012 10gen 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 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "mongo/base/configuration_variable_manager.h" 23 | #include "mongo/base/disallow_copying.h" 24 | 25 | namespace mongo { 26 | 27 | /** 28 | * Context of an initialization process. Passed as a parameter to initialization functions. 29 | * 30 | * See mongo/base/initializer.h and mongo/base/initializer_dependency_graph.h for more details. 31 | */ 32 | class InitializerContext { 33 | MONGO_DISALLOW_COPYING(InitializerContext); 34 | 35 | public: 36 | typedef std::vector ArgumentVector; 37 | typedef std::map EnvironmentMap; 38 | 39 | InitializerContext(const ArgumentVector& args, 40 | const EnvironmentMap& env, 41 | const ConfigurationVariableManager* configVariables); 42 | 43 | const ArgumentVector& args() const { return _args; } 44 | const EnvironmentMap& env() const { return _env; } 45 | const ConfigurationVariableManager* configurationVariables() { return _configVariables; } 46 | 47 | private: 48 | ArgumentVector _args; 49 | EnvironmentMap _env; 50 | const ConfigurationVariableManager* _configVariables; 51 | }; 52 | 53 | } // namespace mongo 54 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/base/initializer_function.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2012 10gen 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 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #include "mongo/base/status.h" 21 | 22 | namespace mongo { 23 | 24 | class InitializerContext; 25 | 26 | /** 27 | * An InitializerFunction implements the behavior of an initializer operation. 28 | * 29 | * On successful execution, an InitializerFunction returns Status::OK(). It may 30 | * inspect and mutate the supplied InitializerContext. 31 | */ 32 | typedef boost::function InitializerFunction; 33 | 34 | } // namespace mongo 35 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/base/make_string_vector.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2012 10gen 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 | 16 | #include "mongo/base/make_string_vector.h" 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | namespace mongo { 23 | 24 | std::vector _makeStringVector(int ignored, ...) { 25 | va_list ap; 26 | va_start(ap, ignored); 27 | const char* arg = va_arg(ap, const char *); 28 | if (arg) { 29 | std::cerr << "Internal error!\n"; 30 | std::abort(); 31 | } 32 | std::vector result; 33 | while ((arg = va_arg(ap, const char *))) 34 | result.push_back(arg); 35 | va_end(ap); 36 | return result; 37 | } 38 | 39 | } // namespace mongo 40 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/base/make_string_vector.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2012 10gen 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 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | /** 22 | * Utility macro to construct a std::vector from a sequence of C-style 23 | * strings. 24 | * 25 | * Usage: MONGO_MAKE_STRING_VECTOR("a", "b", "c") returns a vector containing 26 | * std::strings "a", "b", "c", in that order. 27 | */ 28 | #define MONGO_MAKE_STRING_VECTOR(...) ::mongo::_makeStringVector(0, NULL, ##__VA_ARGS__, NULL) 29 | 30 | namespace mongo { 31 | 32 | /** 33 | * Create a vector of strings from varargs of C-style strings. 34 | * 35 | * WARNING: Only intended for use by MONGO_MAKE_STRING_VECTOR macro, defined above. Aborts 36 | * ungracefully if you misuse it, so stick to the macro. 37 | * 38 | * The first parameter is ignored in all circumstances. The second parameter must be NULL, as 39 | * must be the last parameter. The third through penultimate parameters should be const char* 40 | * C-style strings. 41 | * 42 | * Returns a vector of std::strings. 43 | */ 44 | std::vector _makeStringVector(int ignored, ...); 45 | 46 | } // namespace mongo 47 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/base/owned_pointer_map.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2012 10gen 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 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #include "mongo/base/disallow_copying.h" 21 | 22 | namespace mongo { 23 | 24 | /** 25 | * An std::map wrapper that deletes pointers within a vector on destruction. The objects 26 | * referenced by the vector's pointers are 'owned' by an object of this class. 27 | * NOTE that an OwnedPointerMap wraps an std::map. 28 | */ 29 | template 30 | class OwnedPointerMap { 31 | MONGO_DISALLOW_COPYING(OwnedPointerMap); 32 | 33 | public: 34 | OwnedPointerMap(); 35 | ~OwnedPointerMap(); 36 | 37 | /** Access the map. */ 38 | const std::map& map() { return _map; } 39 | std::map& mutableMap() { return _map; } 40 | 41 | void clear(); 42 | 43 | private: 44 | std::map _map; 45 | }; 46 | 47 | template 48 | OwnedPointerMap::OwnedPointerMap() { 49 | } 50 | 51 | template 52 | OwnedPointerMap::~OwnedPointerMap() { 53 | clear(); 54 | } 55 | 56 | template 57 | void OwnedPointerMap::clear() { 58 | for( typename std::map::iterator i = _map.begin(); i != _map.end(); ++i ) { 59 | delete i->second; 60 | } 61 | _map.clear(); 62 | } 63 | 64 | } // namespace mongo 65 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/base/owned_pointer_vector.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2012 10gen 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 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #include "mongo/base/disallow_copying.h" 21 | 22 | namespace mongo { 23 | 24 | /** 25 | * An std::vector wrapper that deletes pointers within a vector on destruction. The objects 26 | * referenced by the vector's pointers are 'owned' by an object of this class. 27 | * NOTE that an OwnedPointerVector wraps an std::vector. 28 | */ 29 | template 30 | class OwnedPointerVector { 31 | MONGO_DISALLOW_COPYING(OwnedPointerVector); 32 | 33 | public: 34 | OwnedPointerVector(); 35 | ~OwnedPointerVector(); 36 | 37 | /** Access the vector. */ 38 | const std::vector& vector() { return _vector; } 39 | std::vector& mutableVector() { return _vector; } 40 | 41 | void clear(); 42 | 43 | private: 44 | std::vector _vector; 45 | }; 46 | 47 | template 48 | OwnedPointerVector::OwnedPointerVector() { 49 | } 50 | 51 | template 52 | OwnedPointerVector::~OwnedPointerVector() { 53 | clear(); 54 | } 55 | 56 | template 57 | void OwnedPointerVector::clear() { 58 | for( typename std::vector::iterator i = _vector.begin(); i != _vector.end(); ++i ) { 59 | delete *i; 60 | } 61 | _vector.clear(); 62 | } 63 | 64 | } // namespace mongo 65 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/base/string_data.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2012 10gen 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 | 16 | #include "mongo/base/string_data.h" 17 | 18 | #include 19 | #include 20 | 21 | namespace mongo { 22 | 23 | std::ostream& operator<<(std::ostream& stream, const StringData& value) { 24 | return stream.write(value.rawData(), value.size()); 25 | } 26 | 27 | size_t StringData::Hasher::operator() (const StringData& str) const { 28 | unsigned out; 29 | MurmurHash3_x86_32(str.rawData(), str.size(), 0, &out); 30 | return out; 31 | } 32 | 33 | } // namespace mongo 34 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/bson/bson_validate.h: -------------------------------------------------------------------------------- 1 | // bson_Validate.h 2 | 3 | /* Copyright 2012 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #pragma once 19 | 20 | #include "mongo/base/status.h" 21 | #include "mongo/base/string_data.h" 22 | #include "mongo/bson/bsontypes.h" 23 | #include "mongo/platform/cstdint.h" 24 | 25 | namespace mongo { 26 | 27 | /** 28 | * @param buf - bson data 29 | * @param maxLength - maxLength of buffer 30 | * this is NOT the bson size, but how far we know the buffer is valid 31 | */ 32 | Status validateBSON( const char* buf, uint64_t maxLength ); 33 | 34 | } 35 | 36 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/bson/inline_decls.h: -------------------------------------------------------------------------------- 1 | // inline_decls.h 2 | 3 | /* Copyright 2010 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #pragma once 19 | 20 | #if defined(__GNUC__) 21 | 22 | #define NOINLINE_DECL __attribute__((noinline)) 23 | #define PACKED_DECL __attribute__((packed)) 24 | 25 | #elif defined(_MSC_VER) 26 | 27 | #define NOINLINE_DECL __declspec(noinline) 28 | #define PACKED_DECL 29 | 30 | #else 31 | 32 | #define NOINLINE_DECL 33 | #define PACKED_DECL 34 | 35 | #endif 36 | 37 | namespace mongo { 38 | 39 | /* Note: do not clutter code with these -- ONLY use in hot spots / significant loops. */ 40 | 41 | #if !defined(__GNUC__) 42 | 43 | // branch prediction. indicate we expect to be true 44 | # define MONGO_likely(x) ((bool)(x)) 45 | 46 | // branch prediction. indicate we expect to be false 47 | # define MONGO_unlikely(x) ((bool)(x)) 48 | 49 | # if defined(_WIN32) 50 | // prefetch data from memory 51 | inline void prefetch(const void *p) { 52 | #if defined(_MM_HINT_T0) 53 | _mm_prefetch((char *) p, _MM_HINT_T0); 54 | #endif 55 | } 56 | #else 57 | inline void prefetch(void *p) { } 58 | #endif 59 | 60 | #else 61 | 62 | # define MONGO_likely(x) ( __builtin_expect((bool)(x), 1) ) 63 | # define MONGO_unlikely(x) ( __builtin_expect((bool)(x), 0) ) 64 | 65 | inline void prefetch(void *p) { 66 | __builtin_prefetch(p); 67 | } 68 | 69 | #endif 70 | 71 | } 72 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/buildinfo.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #include "mongo/util/version.h" 6 | 7 | namespace mongo { 8 | const char * gitVersion() { return "a6462d21ea9487d061eba788333003711793411f"; } 9 | const char * compiledJSEngine() { return "V8"; } 10 | const char * allocator() { return "tcmalloc"; } 11 | const char * loaderFlags() { return "-fPIC -pthread -rdynamic"; } 12 | const char * compilerFlags() { return "-Wnon-virtual-dtor -Woverloaded-virtual -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -Werror -pipe -fno-builtin-memcmp -O3"; } 13 | std::string sysInfo() { return "Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=" BOOST_LIB_VERSION ; } 14 | } // namespace mongo 15 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/client/authlevel.h: -------------------------------------------------------------------------------- 1 | // mongo/db/authlevel.h 2 | 3 | /* Copyright 2012 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | namespace mongo { 23 | 24 | /* 25 | * for a particular db 26 | * levels 27 | * 0 : none 28 | * 1 : read 29 | * 2 : write 30 | */ 31 | struct Auth { 32 | 33 | enum Level { NONE = 0 , 34 | READ = 1 , 35 | WRITE = 2 }; 36 | 37 | Auth() : level( NONE ) {} 38 | 39 | Level level; 40 | std::string user; 41 | }; 42 | } // namespace mongo 43 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/client/clientOnly-private.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2012 10gen 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 | 16 | #pragma once 17 | namespace mongo { 18 | namespace shell_utils { 19 | extern mongo::mutex &mongoProgramOutputMutex; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/client/clientOnly.cpp: -------------------------------------------------------------------------------- 1 | // clientOnly.cpp 2 | 3 | /* Copyright 2009 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include "mongo/util/net/hostandport.h" 19 | #include "mongo/util/startup_test.h" 20 | 21 | namespace mongo { 22 | 23 | StartupTest::StartupTest() {} 24 | StartupTest::~StartupTest() {} 25 | 26 | } 27 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/client/constants.h: -------------------------------------------------------------------------------- 1 | // constants.h 2 | 3 | /* Copyright 2012 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #pragma once 19 | 20 | namespace mongo { 21 | 22 | /* query results include a 32 result flag word consisting of these bits */ 23 | enum ResultFlagType { 24 | /* returned, with zero results, when getMore is called but the cursor id 25 | is not valid at the server. */ 26 | ResultFlag_CursorNotFound = 1, 27 | 28 | /* { $err : ... } is being returned */ 29 | ResultFlag_ErrSet = 2, 30 | 31 | /* Have to update config from the server, usually $err is also set */ 32 | ResultFlag_ShardConfigStale = 4, 33 | 34 | /* for backward compatibility: this let's us know the server supports 35 | the QueryOption_AwaitData option. if it doesn't, a repl slave client should sleep 36 | a little between getMore's. 37 | */ 38 | ResultFlag_AwaitCapable = 8 39 | }; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/client/dbclient.h: -------------------------------------------------------------------------------- 1 | /** @file dbclient.h 2 | 3 | Include this file when writing client C++ applications, to get access to the 4 | mongod C++ driver. 5 | */ 6 | 7 | /* Copyright 2009 10gen Inc. 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #pragma once 23 | 24 | #ifdef MONGO_EXPOSE_MACROS 25 | #error dbclient.h is for C++ driver consumer use only 26 | #endif 27 | 28 | #include "mongo/client/redef_macros.h" 29 | 30 | #include "mongo/pch.h" 31 | 32 | #include "mongo/client/connpool.h" 33 | #include "mongo/client/dbclient_rs.h" 34 | #include "mongo/client/dbclientcursor.h" 35 | #include "mongo/client/dbclientinterface.h" 36 | #include "mongo/client/gridfs.h" 37 | #include "mongo/client/model.h" 38 | #include "mongo/client/sasl_client_authenticate.h" 39 | #include "mongo/client/syncclusterconnection.h" 40 | 41 | #include "mongo/client/undef_macros.h" 42 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/client/dbclientmockcursor.h: -------------------------------------------------------------------------------- 1 | //@file dbclientmockcursor.h 2 | 3 | /* Copyright 2010 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #pragma once 19 | 20 | #include "dbclientcursor.h" 21 | 22 | namespace mongo { 23 | 24 | class DBClientMockCursor : public DBClientCursorInterface { 25 | public: 26 | DBClientMockCursor( const BSONArray& mockCollection ) : _iter( mockCollection ) {} 27 | virtual ~DBClientMockCursor() {} 28 | 29 | bool more() { return _iter.more(); } 30 | BSONObj next() { return _iter.next().Obj(); } 31 | 32 | private: 33 | BSONObjIterator _iter; 34 | 35 | // non-copyable , non-assignable 36 | DBClientMockCursor( const DBClientMockCursor& ); 37 | DBClientMockCursor& operator=( const DBClientMockCursor& ); 38 | }; 39 | 40 | } // namespace mongo 41 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/client/examples/authTest.cpp: -------------------------------------------------------------------------------- 1 | // authTest.cpp 2 | 3 | /* Copyright 2009 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "mongo/client/dbclient.h" 22 | 23 | using namespace mongo; 24 | 25 | int main( int argc, const char **argv ) { 26 | 27 | const char *port = "27017"; 28 | if ( argc != 1 ) { 29 | if ( argc != 3 ) { 30 | std::cout << "need to pass port as second param" << endl; 31 | return EXIT_FAILURE; 32 | } 33 | port = argv[ 2 ]; 34 | } 35 | 36 | DBClientConnection conn; 37 | std::string errmsg; 38 | if ( ! conn.connect( string( "127.0.0.1:" ) + port , errmsg ) ) { 39 | cout << "couldn't connect: " << errmsg << endl; 40 | return EXIT_FAILURE; 41 | } 42 | 43 | // clean up old data from any previous tests 44 | conn.remove( "test.system.users" , BSONObj() ); 45 | 46 | conn.insert( "test.system.users" , BSON( "user" << "eliot" << "pwd" << conn.createPasswordDigest( "eliot" , "bar" ) ) ); 47 | 48 | errmsg.clear(); 49 | bool ok = conn.auth( "test" , "eliot" , "bar" , errmsg ); 50 | if ( ! ok ) 51 | cout << errmsg << endl; 52 | MONGO_verify( ok ); 53 | 54 | MONGO_verify( ! conn.auth( "test" , "eliot" , "bars" , errmsg ) ); 55 | return EXIT_SUCCESS; 56 | } 57 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/client/examples/httpClientTest.cpp: -------------------------------------------------------------------------------- 1 | // httpClientTest.cpp 2 | 3 | /* Copyright 2009 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include 19 | 20 | #include "mongo/base/init.h" 21 | #include "mongo/client/dbclient.h" 22 | #include "util/net/httpclient.h" 23 | 24 | using namespace mongo; 25 | 26 | void play( string url ) { 27 | cout << "[" << url << "]" << endl; 28 | 29 | HttpClient c; 30 | HttpClient::Result r; 31 | MONGO_verify( c.get( url , &r ) == 200 ); 32 | 33 | HttpClient::Headers h = r.getHeaders(); 34 | MONGO_verify( h["Content-Type"].find( "text/html" ) == 0 ); 35 | 36 | cout << "\tHeaders" << endl; 37 | for ( HttpClient::Headers::iterator i = h.begin() ; i != h.end(); ++i ) { 38 | cout << "\t\t" << i->first << "\t" << i->second << endl; 39 | } 40 | 41 | } 42 | 43 | int main( int argc, const char **argv, char **envp) { 44 | 45 | #ifdef MONGO_SSL 46 | cmdLine.sslOnNormalPorts = true; 47 | runGlobalInitializersOrDie(argc, argv, envp); 48 | #endif 49 | 50 | int port = 27017; 51 | if ( argc != 1 ) { 52 | if ( argc != 3 ) 53 | throw -12; 54 | port = atoi( argv[ 2 ] ); 55 | } 56 | port += 1000; 57 | 58 | play( str::stream() << "http://localhost:" << port << "/" ); 59 | 60 | #ifdef MONGO_SSL 61 | play( "https://www.10gen.com/" ); 62 | #endif 63 | 64 | } 65 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/client/examples/second.cpp: -------------------------------------------------------------------------------- 1 | // second.cpp 2 | 3 | /* Copyright 2009 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include 19 | 20 | #include "mongo/client/dbclient.h" 21 | 22 | using namespace std; 23 | using namespace mongo; 24 | 25 | int main( int argc, const char **argv ) { 26 | 27 | const char *port = "27017"; 28 | if ( argc != 1 ) { 29 | if ( argc != 3 ) { 30 | cout << "need to pass port as second param" << endl; 31 | return EXIT_FAILURE; 32 | } 33 | port = argv[ 2 ]; 34 | } 35 | 36 | scoped_ptr connPtr( ScopedDbConnection::getScopedDbConnection( 37 | string( "127.0.0.1:" ) + port ) ); 38 | ScopedDbConnection& conn = *connPtr; 39 | 40 | const char * ns = "test.second"; 41 | 42 | conn->remove( ns , BSONObj() ); 43 | 44 | conn->insert( ns , BSON( "name" << "eliot" << "num" << 17 ) ); 45 | conn->insert( ns , BSON( "name" << "sara" << "num" << 24 ) ); 46 | 47 | std::auto_ptr cursor = conn->query( ns , BSONObj() ); 48 | cout << "using cursor" << endl; 49 | while ( cursor->more() ) { 50 | BSONObj obj = cursor->next(); 51 | cout << "\t" << obj.jsonString() << endl; 52 | } 53 | 54 | conn->ensureIndex( ns , BSON( "name" << 1 << "num" << -1 ) ); 55 | 56 | conn.done(); 57 | } 58 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/client/examples/whereExample.cpp: -------------------------------------------------------------------------------- 1 | // @file whereExample.cpp 2 | // @see http://dochub.mongodb.org/core/serversidecodeexecution 3 | 4 | /* Copyright 2009 10gen Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include 20 | 21 | #include "mongo/client/dbclient.h" 22 | 23 | using namespace std; 24 | using namespace mongo; 25 | 26 | int main( int argc, const char **argv ) { 27 | 28 | const char *port = "27017"; 29 | if ( argc != 1 ) { 30 | if ( argc != 3 ) 31 | throw -12; 32 | port = argv[ 2 ]; 33 | } 34 | 35 | DBClientConnection conn; 36 | string errmsg; 37 | if ( ! conn.connect( string( "127.0.0.1:" ) + port , errmsg ) ) { 38 | cout << "couldn't connect : " << errmsg << endl; 39 | throw -11; 40 | } 41 | 42 | const char * ns = "test.where"; 43 | 44 | conn.remove( ns , BSONObj() ); 45 | 46 | conn.insert( ns , BSON( "name" << "eliot" << "num" << 17 ) ); 47 | conn.insert( ns , BSON( "name" << "sara" << "num" << 24 ) ); 48 | 49 | auto_ptr cursor = conn.query( ns , BSONObj() ); 50 | 51 | while ( cursor->more() ) { 52 | BSONObj obj = cursor->next(); 53 | cout << "\t" << obj.jsonString() << endl; 54 | } 55 | 56 | cout << "now using $where" << endl; 57 | 58 | Query q = Query("{}").where("this.name == name" , BSON( "name" << "sara" )); 59 | 60 | cursor = conn.query( ns , q ); 61 | 62 | int num = 0; 63 | while ( cursor->more() ) { 64 | BSONObj obj = cursor->next(); 65 | cout << "\t" << obj.jsonString() << endl; 66 | num++; 67 | } 68 | MONGO_verify( num == 1 ); 69 | } 70 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/client/model.h: -------------------------------------------------------------------------------- 1 | /** @file model.h */ 2 | 3 | /* Copyright 2009 10gen 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #pragma once 19 | 20 | #include "mongo/bson/bsonelement.h" 21 | #include "mongo/bson/bsonobj.h" 22 | 23 | namespace mongo { 24 | 25 | /** Model is a base class for defining objects which are serializable to the Mongo 26 | database via the database driver. 27 | 28 | Definition 29 | Your serializable class should inherit from Model and implement the abstract methods 30 | below. 31 | 32 | Loading 33 | To load, first construct an (empty) object. Then call load(). Do not load an object 34 | more than once. 35 | */ 36 | class Model { 37 | public: 38 | Model() { } 39 | virtual ~Model() { } 40 | 41 | virtual const char * getNS() = 0; 42 | virtual void serialize(BSONObjBuilder& to) = 0; 43 | virtual void unserialize(const BSONObj& from) = 0; 44 | virtual BSONObj toObject(); 45 | virtual void append( const char * name , BSONObjBuilder& b ); 46 | 47 | virtual string modelServer() = 0; 48 | 49 | /** Load a single object. 50 | @return true if successful. 51 | */ 52 | virtual bool load(BSONObj& query); 53 | virtual void save( bool safe=false ); 54 | virtual void remove( bool safe=false ); 55 | 56 | protected: 57 | BSONObj _id; 58 | }; 59 | 60 | } // namespace mongo 61 | 62 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/client/undef_macros.h: -------------------------------------------------------------------------------- 1 | /** @file undef_macros.h remove mongo implementation macros after using */ 2 | 3 | /* Copyright 2009 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // If you define a new global un-prefixed macro, please add it here and in redef_macros 19 | 20 | // #pragma once // this file is intended to be processed multiple times 21 | 22 | #ifdef MONGO_MACROS_PUSHED 23 | 24 | // util/allocator.h 25 | #ifdef MONGO_MALLOC 26 | #undef malloc 27 | #pragma pop_macro("malloc") 28 | #undef realloc 29 | #pragma pop_macro("realloc") 30 | #endif 31 | 32 | // util/assert_util.h 33 | #undef dassert 34 | #pragma pop_macro("dassert") 35 | #undef wassert 36 | #pragma pop_macro("wassert") 37 | #undef massert 38 | #pragma pop_macro("massert") 39 | #undef uassert 40 | #pragma pop_macro("uassert") 41 | #undef uassertStatusOK 42 | #pragma pop_macro("uassertStatusOK") 43 | #undef verify 44 | #pragma pop_macro("verify") 45 | #undef DESTRUCTOR_GUARD 46 | #pragma pop_macro("DESTRUCTOR_GUARD") 47 | 48 | // util/goodies.h 49 | #undef PRINT 50 | #pragma pop_macro("PRINT") 51 | #undef PRINTFL 52 | #pragma pop_macro("PRINTFL") 53 | 54 | // util/debug_util.h 55 | #undef DEV 56 | #pragma pop_macro("DEV") 57 | #undef DEBUGGING 58 | #pragma pop_macro("DEBUGGING") 59 | #undef SOMETIMES 60 | #pragma pop_macro("SOMETIMES") 61 | #undef OCCASIONALLY 62 | #pragma pop_macro("OCCASIONALLY") 63 | #undef RARELY 64 | #pragma pop_macro("RARELY") 65 | #undef ONCE 66 | #pragma pop_macro("ONCE") 67 | 68 | // util/log.h 69 | #undef LOG 70 | #pragma pop_macro("LOG") 71 | 72 | #undef MONGO_MACROS_PUSHED 73 | #endif 74 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/auth/auth_external_state_d.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "mongo/base/disallow_copying.h" 20 | #include "mongo/base/status.h" 21 | #include "mongo/db/auth/auth_external_state_server_common.h" 22 | 23 | namespace mongo { 24 | 25 | /** 26 | * The implementation of AuthExternalState functionality for mongod. 27 | */ 28 | class AuthExternalStateMongod : public AuthExternalStateServerCommon { 29 | MONGO_DISALLOW_COPYING(AuthExternalStateMongod); 30 | 31 | public: 32 | AuthExternalStateMongod(); 33 | virtual ~AuthExternalStateMongod(); 34 | 35 | virtual bool shouldIgnoreAuthChecks() const; 36 | 37 | virtual void startRequest(); 38 | 39 | protected: 40 | virtual bool _findUser(const string& usersNamespace, 41 | const BSONObj& query, 42 | BSONObj* result) const; 43 | }; 44 | 45 | } // namespace mongo 46 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/auth/auth_external_state_mock.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "mongo/base/disallow_copying.h" 20 | #include "mongo/base/status.h" 21 | #include "mongo/db/auth/auth_external_state.h" 22 | 23 | namespace mongo { 24 | 25 | /** 26 | * Mock of the AuthExternalState class used only for testing. 27 | */ 28 | class AuthExternalStateMock : public AuthExternalState { 29 | MONGO_DISALLOW_COPYING(AuthExternalStateMock); 30 | 31 | public: 32 | AuthExternalStateMock() : _returnValue(false) {} 33 | 34 | virtual bool shouldIgnoreAuthChecks() const { 35 | return _returnValue; 36 | } 37 | 38 | void setReturnValueForShouldIgnoreAuthChecks(bool returnValue) { 39 | _returnValue = returnValue; 40 | } 41 | 42 | virtual bool _findUser(const std::string& usersNamespace, 43 | const BSONObj& query, 44 | BSONObj* result) const { 45 | return false; 46 | } 47 | 48 | virtual void startRequest() {} 49 | 50 | private: 51 | bool _returnValue; 52 | }; 53 | 54 | } // namespace mongo 55 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/auth/auth_external_state_s.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "mongo/base/disallow_copying.h" 20 | #include "mongo/base/status.h" 21 | #include "mongo/db/auth/auth_external_state_server_common.h" 22 | 23 | namespace mongo { 24 | 25 | /** 26 | * The implementation of AuthExternalState functionality for mongos. 27 | */ 28 | class AuthExternalStateMongos : public AuthExternalStateServerCommon { 29 | MONGO_DISALLOW_COPYING(AuthExternalStateMongos); 30 | 31 | public: 32 | AuthExternalStateMongos(); 33 | virtual ~AuthExternalStateMongos(); 34 | 35 | virtual void startRequest(); 36 | 37 | protected: 38 | virtual bool _findUser(const string& usersNamespace, 39 | const BSONObj& query, 40 | BSONObj* result) const; 41 | }; 42 | 43 | } // namespace mongo 44 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/auth/auth_external_state_server_common.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "mongo/base/disallow_copying.h" 20 | #include "mongo/base/status.h" 21 | #include "mongo/db/auth/auth_external_state.h" 22 | 23 | namespace mongo { 24 | 25 | /** 26 | * The implementation of AuthExternalState functionality common to mongod and mongos. 27 | */ 28 | class AuthExternalStateServerCommon : public AuthExternalState { 29 | MONGO_DISALLOW_COPYING(AuthExternalStateServerCommon); 30 | 31 | public: 32 | virtual ~AuthExternalStateServerCommon(); 33 | 34 | virtual bool shouldIgnoreAuthChecks() const; 35 | 36 | protected: 37 | AuthExternalStateServerCommon(); 38 | 39 | // Checks whether or not localhost connections should be given full access and stores the 40 | // result in _allowLocalhost. Currently localhost connections are only given full access 41 | // if there are no users in the admin database. 42 | virtual void _checkShouldAllowLocalhost(); 43 | 44 | private: 45 | 46 | bool _allowLocalhost; 47 | 48 | }; 49 | 50 | } // namespace mongo 51 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/auth/auth_index_d.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "mongo/base/string_data.h" 20 | #include "mongo/db/namespacestring.h" 21 | 22 | namespace mongo { 23 | namespace authindex { 24 | 25 | /** 26 | * Ensures that exactly the appropriate indexes are present on system collections supporting 27 | * authentication and authorization in database "dbname". 28 | * 29 | * It is appropriate to call this function on new or existing databases, though it is primarily 30 | * intended for use on existing databases. Under no circumstances may it be called on databases 31 | * with running operations. 32 | */ 33 | void configureSystemIndexes(const StringData& dbname); 34 | 35 | /** 36 | * Creates the appropriate indexes on _new_ system collections supporting authentication and 37 | * authorization. 38 | */ 39 | void createSystemIndexes(const NamespaceString& ns); 40 | 41 | } // namespace authindex 42 | } // namespace mongo 43 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/auth/authentication_session.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2012 10gen 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 | 16 | #pragma once 17 | 18 | #include "mongo/base/disallow_copying.h" 19 | 20 | namespace mongo { 21 | 22 | /** 23 | * Abstract type representing an ongoing authentication session. 24 | * 25 | * An example subclass is MongoAuthenticationSession. 26 | */ 27 | class AuthenticationSession { 28 | MONGO_DISALLOW_COPYING(AuthenticationSession); 29 | public: 30 | enum SessionType { 31 | SESSION_TYPE_MONGO, // The mongo-specific challenge-response authentication mechanism. 32 | SESSION_TYPE_SASL // SASL authentication mechanism. 33 | }; 34 | 35 | virtual ~AuthenticationSession() {} 36 | 37 | /** 38 | * Return an identifer of the type of session, so that a caller can safely cast it and 39 | * extract the type-specific data stored within. 40 | */ 41 | SessionType getType() const { return _sessionType; } 42 | 43 | protected: 44 | explicit AuthenticationSession(SessionType sessionType) : _sessionType(sessionType) {} 45 | 46 | private: 47 | const SessionType _sessionType; 48 | }; 49 | 50 | } // namespace mongo 51 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/auth/mongo_authentication_session.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2012 10gen 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 | 16 | #pragma once 17 | 18 | #include "mongo/db/auth/authentication_session.h" 19 | 20 | namespace mongo { 21 | 22 | typedef unsigned long long nonce64; 23 | 24 | /** 25 | * Authentication session data for a nonce-challenge-response authentication of the 26 | * type used in the Mongo nonce-authenticate protocol. 27 | * 28 | * The only session data is the nonce sent to the client. 29 | */ 30 | class MongoAuthenticationSession : public AuthenticationSession { 31 | MONGO_DISALLOW_COPYING(MongoAuthenticationSession); 32 | public: 33 | explicit MongoAuthenticationSession(nonce64 nonce); 34 | virtual ~MongoAuthenticationSession(); 35 | 36 | nonce64 getNonce() const { return _nonce; } 37 | 38 | private: 39 | const nonce64 _nonce; 40 | }; 41 | 42 | } // namespace mongo 43 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/auth/privilege.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2012 10gen 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 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #include "mongo/db/auth/action_set.h" 21 | #include "mongo/db/auth/action_type.h" 22 | #include "mongo/db/auth/principal.h" 23 | 24 | namespace mongo { 25 | 26 | /** 27 | * A representation of the permission to perform a set of actions on a specific resource. 28 | */ 29 | class Privilege { 30 | public: 31 | 32 | Privilege(const std::string& resource, const ActionType& action); 33 | Privilege(const std::string& resource, const ActionSet& actions); 34 | ~Privilege() {} 35 | 36 | const std::string& getResource() const { return _resource; } 37 | 38 | const ActionSet& getActions() const { return _actions; } 39 | 40 | // Checks if the given action is present in the Privilege. 41 | bool includesAction(const ActionType& action) const; 42 | // Checks if the given actions are present in the Privilege. 43 | bool includesActions(const ActionSet& actions) const; 44 | 45 | private: 46 | 47 | std::string _resource; 48 | ActionSet _actions; // bitmask of actions this privilege grants 49 | }; 50 | 51 | } // namespace mongo 52 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/auth/security_key.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2009 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | namespace mongo { 22 | 23 | /** 24 | * This method checks the validity of filename as a security key, hashes its 25 | * contents, and stores it in the internalSecurity variable. Prints an 26 | * error message to the logs if there's an error. 27 | * @param filename the file containing the key 28 | * @return if the key was successfully stored 29 | */ 30 | bool setUpSecurityKey(const std::string& filename); 31 | 32 | } // namespace mongo 33 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/background.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | /* background.h 18 | 19 | Concurrency coordination for administrative operations. 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "mongo/db/namespacestring.h" 25 | 26 | namespace mongo { 27 | 28 | /* these are administrative operations / jobs 29 | for a namespace running in the background, and that only one 30 | at a time per namespace is permitted, and that if in progress, 31 | you aren't allowed to do other NamespaceDetails major manipulations 32 | (such as dropping ns or db) even in the foreground and must 33 | instead uassert. 34 | 35 | It's assumed this is not for super-high RPS things, so we don't do 36 | anything special in the implementation here to be fast. 37 | */ 38 | class BackgroundOperation : public boost::noncopyable { 39 | public: 40 | static bool inProgForDb(const char *db); 41 | static bool inProgForNs(const char *ns); 42 | static void assertNoBgOpInProgForDb(const char *db); 43 | static void assertNoBgOpInProgForNs(const char *ns); 44 | static void dump(stringstream&); 45 | 46 | /* check for in progress before instantiating */ 47 | BackgroundOperation(const char *ns); 48 | 49 | virtual ~BackgroundOperation(); 50 | 51 | private: 52 | NamespaceString _ns; 53 | static map dbsInProg; 54 | static set nsInProg; 55 | static SimpleMutex m; 56 | }; 57 | 58 | } // namespace mongo 59 | 60 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/collection.h: -------------------------------------------------------------------------------- 1 | // @file collection.h 2 | 3 | /** 4 | * Copyright (C) 2012 10gen Inc. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License, version 3, 8 | * as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "namespace.h" 22 | 23 | namespace mongo { 24 | 25 | class Collection { 26 | public: 27 | NamespaceDetails * const d; 28 | NamespaceDetailsTransient * const nsd; 29 | }; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/curop-inl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "curop.h" 18 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/d_globals.h: -------------------------------------------------------------------------------- 1 | // @file d_globals.h 2 | 3 | /** 4 | * Copyright (C) 2012 10gen Inc. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License, version 3, 8 | * as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | // 20 | // these are global variables used in mongod ("d"). also used in test binary as that is effectively a variation on mongod code. 21 | // that is, these are not in mongos. 22 | // 23 | 24 | #pragma once 25 | 26 | namespace mongo { 27 | 28 | class RWLockRecursive; 29 | class ClientCursorMonitor; 30 | 31 | struct DGlobals : boost::noncopyable { 32 | DGlobals(); 33 | 34 | // these are intentionally never deleted: 35 | ClientCursorMonitor& clientCursorMonitor; 36 | 37 | }; 38 | 39 | extern DGlobals d; 40 | 41 | }; 42 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/filever.h: -------------------------------------------------------------------------------- 1 | /* filever.h */ 2 | 3 | /** 4 | * Copyright (C) 2008 10gen Inc. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License, version 3, 8 | * as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | namespace mongo { 22 | 23 | inline void checkDataFileVersion(NamespaceDetails& d) { 24 | } 25 | 26 | inline void checkIndexFileVersion(NamespaceDetails& d) { 27 | } 28 | 29 | } 30 | 31 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/index_rebuilder.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "mongo/db/namespace_details.h" 20 | 21 | namespace mongo { 22 | 23 | class IndexRebuilder { 24 | public: 25 | IndexRebuilder(); 26 | 27 | std::string name() const; 28 | void run(); 29 | 30 | private: 31 | /** 32 | * Check each collection in a database to see if it has any in-progress index builds that 33 | * need to be retried. If so, calls retryIndexBuild. 34 | */ 35 | void checkDB(const std::string& dbname, bool* firstTime); 36 | 37 | /** 38 | * Actually retry an index build on a given namespace. 39 | * @param dbName the name of the database for accessing db.system.indexes 40 | * @param nsd the namespace details of the namespace building the index 41 | * @param index the offset into nsd's index array of the partially-built index 42 | */ 43 | void retryIndexBuild(const std::string& dbName, NamespaceDetails* nsd, const int index); 44 | }; 45 | 46 | extern IndexRebuilder indexRebuilder; 47 | } 48 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/index_set.h: -------------------------------------------------------------------------------- 1 | // index_set.h 2 | 3 | /** 4 | * Copyright (C) 2013 10gen Inc. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License, version 3, 8 | * as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | #include "mongo/base/string_data.h" 24 | 25 | namespace mongo { 26 | 27 | /** 28 | * a.$ -> a 29 | * @return true if out is set and we made a change 30 | */ 31 | bool getCanonicalIndexField( const StringData& fullName, std::string* out ); 32 | 33 | class IndexPathSet { 34 | public: 35 | void addPath( const StringData& path ); 36 | 37 | void clear(); 38 | 39 | bool mightBeIndexed( const StringData& path ) const; 40 | 41 | private: 42 | 43 | bool _startsWith( const StringData& a, const StringData& b ) const; 44 | 45 | std::set _canonical; 46 | }; 47 | 48 | } 49 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/initialize_server_global_state.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2008 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | namespace mongo { 20 | 21 | /** 22 | * Perform initialization activity common across all mongo server types. 23 | * 24 | * Set up logging, daemonize the process, configure SSL, etc. 25 | * 26 | * If isMongodShutdownSpecialCase, perform this processing knowing that 27 | * we're only bringing this process up to kill another mongod. 28 | * 29 | * TODO: Untie the knot that requires the isMongodShutdownSpecialCase parameter. 30 | */ 31 | bool initializeServerGlobalState(bool isMongodShutdownSpecialCase = false); 32 | 33 | void setupCoreSignals(); 34 | 35 | } // namespace mongo 36 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/interrupt_status_mongod.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "mongo/pch.h" 20 | #include "db/interrupt_status.h" 21 | 22 | namespace mongo { 23 | 24 | class InterruptStatusMongod : 25 | public InterruptStatus, 26 | boost::noncopyable { 27 | public: 28 | // virtuals from InterruptStatus 29 | virtual void checkForInterrupt(); 30 | virtual const char *checkForInterruptNoAssert(); 31 | 32 | /* 33 | Static singleton instance. 34 | */ 35 | static InterruptStatusMongod status; 36 | 37 | private: 38 | InterruptStatusMongod(); 39 | }; 40 | 41 | }; 42 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/introspect.h: -------------------------------------------------------------------------------- 1 | // introspect.h 2 | // system management stuff. 3 | 4 | /** 5 | * Copyright (C) 2008 10gen Inc. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License, version 3, 9 | * as published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "mongo/pch.h" 23 | #include "jsobj.h" 24 | #include "pdfile.h" 25 | 26 | namespace mongo { 27 | 28 | /* --- profiling -------------------------------------------- 29 | do when database->profile is set 30 | */ 31 | 32 | void profile(const Client& c, int op, CurOp& currentOp); 33 | 34 | /** 35 | * Get (or create) the profile collection 36 | * 37 | * @param db Database in which to create the profile collection 38 | * @param force Always create the collection if it does not exist 39 | * @return NamespaceDetails for the newly created collection, or NULL on error 40 | **/ 41 | NamespaceDetails* getOrCreateProfileCollection(Database *db, bool force = false, string* errmsg = NULL); 42 | 43 | } // namespace mongo 44 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/jsobj.h: -------------------------------------------------------------------------------- 1 | /** @file jsobj.h 2 | BSON classes 3 | */ 4 | 5 | /* Copyright 2009 10gen Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | /** 21 | BSONObj and its helpers 22 | 23 | "BSON" stands for "binary JSON" -- ie a binary way to represent objects that would be 24 | represented in JSON (plus a few extensions useful for databases & other languages). 25 | 26 | http://www.bsonspec.org/ 27 | */ 28 | 29 | #pragma once 30 | 31 | #include "mongo/pch.h" 32 | #include "../bson/util/builder.h" 33 | #include "../util/optime.h" 34 | #include "../bson/bsontypes.h" 35 | #include "../bson/oid.h" 36 | #include "../bson/bsonelement.h" 37 | #include "../bson/bsonobj.h" 38 | #include "../bson/bsonmisc.h" 39 | #include "../bson/bsonobjbuilder.h" 40 | #include "../bson/bsonobjiterator.h" 41 | #include "../bson/bson-inl.h" 42 | #include "../bson/ordering.h" 43 | #include "mongo/base/string_data.h" 44 | #include "../bson/bson_db.h" 45 | 46 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/lockstat.h: -------------------------------------------------------------------------------- 1 | // lockstat.h 2 | 3 | /** 4 | * Copyright (C) 2008 10gen Inc. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License, version 3, 8 | * as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | 20 | #pragma once 21 | 22 | #include "util/timer.h" 23 | #include "mongo/platform/atomic_word.h" 24 | 25 | namespace mongo { 26 | 27 | class BSONObj; 28 | 29 | class LockStat { 30 | enum { N = 4 }; 31 | public: 32 | void recordAcquireTimeMicros( char type , long long micros ); 33 | void recordLockTimeMicros( char type , long long micros ); 34 | 35 | void reset(); 36 | 37 | BSONObj report() const; 38 | void report( StringBuilder& builder ) const; 39 | 40 | long long getTimeLocked( char type ) const { return timeLocked[mapNo(type)].load(); } 41 | private: 42 | static void _append( BSONObjBuilder& builder, const AtomicInt64* data ); 43 | 44 | // RWrw 45 | // in micros 46 | AtomicInt64 timeAcquiring[N]; 47 | AtomicInt64 timeLocked[N]; 48 | 49 | static unsigned mapNo(char type); 50 | static char nameFor(unsigned offset); 51 | }; 52 | 53 | } 54 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/namespace.cpp: -------------------------------------------------------------------------------- 1 | // namespace.cpp 2 | 3 | /** 4 | * Copyright (C) 2008 10gen Inc. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License, version 3, 8 | * as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "pch.h" 20 | 21 | #include "mongo/db/namespace.h" 22 | 23 | #include 24 | 25 | #include "mongo/db/namespacestring.h" 26 | 27 | namespace mongo { 28 | namespace { 29 | BOOST_STATIC_ASSERT( sizeof(Namespace) == 128 ); 30 | BOOST_STATIC_ASSERT( Namespace::MaxNsLen == MaxDatabaseNameLen ); 31 | } // namespace 32 | } // namespace mongo 33 | 34 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/ops/count.h: -------------------------------------------------------------------------------- 1 | // count.h 2 | 3 | /** 4 | * Copyright (C) 2008 10gen Inc. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License, version 3, 8 | * as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "../jsobj.h" 20 | #include "../diskloc.h" 21 | 22 | namespace mongo { 23 | 24 | /** 25 | * { count: "collectionname"[, query: ] } 26 | * @return -1 on ns does not exist error and other errors, 0 on other errors, otherwise the match count. 27 | */ 28 | long long runCount(const char *ns, const BSONObj& cmd, string& err, int& errCode ); 29 | 30 | } // namespace mongo 31 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/ops/delete.h: -------------------------------------------------------------------------------- 1 | // delete.h 2 | 3 | /** 4 | * Copyright (C) 2008 10gen Inc. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License, version 3, 8 | * as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "mongo/pch.h" 22 | #include "../jsobj.h" 23 | #include "../clientcursor.h" 24 | 25 | namespace mongo { 26 | 27 | class RemoveSaver; 28 | 29 | // If justOne is true, deletedId is set to the id of the deleted object. 30 | long long deleteObjects(const char *ns, BSONObj pattern, bool justOne, bool logop = false, bool god=false, RemoveSaver * rs=0); 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/pdfile_private.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2008 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | // This file contains declarations that should not be considered part of pdfile's 18 | // public interface, but are currently accessed by other modules within mongod. 19 | 20 | #pragma once 21 | namespace mongo { 22 | extern bool inDBRepair; 23 | } 24 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/pdfile_version.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2013 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | namespace mongo { 20 | 21 | // pdfile versions 22 | const int PDFILE_VERSION = 4; 23 | const int PDFILE_VERSION_MINOR_22_AND_OLDER = 5; 24 | const int PDFILE_VERSION_MINOR_24_AND_NEWER = 6; 25 | 26 | // For backward compatibility with versions before 2.4.0 all new DBs start 27 | // with PDFILE_VERSION_MINOR_22_AND_OLDER and are converted when the first 28 | // index using a new plugin is created. See the logic in 29 | // prepareToBuildIndex() and upgradeMinorVersionOrAssert() for details 30 | 31 | } // namespace mongo 32 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/prefetch.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2008 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | #pragma once 17 | 18 | #include "mongo/db/jsobj.h" 19 | #include "mongo/db/diskloc.h" 20 | 21 | namespace mongo { 22 | class NamespaceDetails; 23 | // page in both index and data pages for an op from the oplog 24 | void prefetchPagesForReplicatedOp(const BSONObj& op); 25 | 26 | // page in pages needed for all index lookups on a given object 27 | void prefetchIndexPages(NamespaceDetails *nsd, const BSONObj& obj); 28 | 29 | // page in the data pages for a record associated with an object 30 | void prefetchRecordPages(const char *ns, const BSONObj& obj); 31 | } 32 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/record.h: -------------------------------------------------------------------------------- 1 | // database.h 2 | 3 | /** 4 | * Copyright (C) 2008 10gen Inc. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License, version 3, 8 | * as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "mongo/bson/bsonobjbuilder.h" 22 | #include "mongo/platform/atomic_word.h" 23 | 24 | namespace mongo { 25 | 26 | struct RecordStats { 27 | void record( BSONObjBuilder& b ); 28 | 29 | AtomicInt64 accessesNotInMemory; 30 | AtomicInt64 pageFaultExceptionsThrown; 31 | }; 32 | 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/repl/rs_exception.h: -------------------------------------------------------------------------------- 1 | // @file rs_exception.h 2 | 3 | /** 4 | * Copyright (C) 2012 10gen Inc. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License, version 3, 8 | * as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | namespace mongo { 22 | 23 | class VoteException : public std::exception { 24 | public: 25 | const char * what() const throw () { return "VoteException"; } 26 | }; 27 | 28 | class RetryAfterSleepException : public std::exception { 29 | public: 30 | const char * what() const throw () { return "RetryAfterSleepException"; } 31 | }; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/repl/rs_optime.h: -------------------------------------------------------------------------------- 1 | // @file rs_optime.h 2 | 3 | /* 4 | * Copyright (C) 2010 10gen Inc. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License, version 3, 8 | * as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "../../util/optime.h" 22 | 23 | namespace mongo { 24 | 25 | const char rsoplog[] = "local.oplog.rs"; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/repl_block.h: -------------------------------------------------------------------------------- 1 | // repl_block.h - blocking on writes for replication 2 | 3 | /** 4 | * Copyright (C) 2008 10gen Inc. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License, version 3, 8 | * as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "mongo/pch.h" 22 | #include "client.h" 23 | #include "curop.h" 24 | 25 | /** 26 | local.slaves - current location for all slaves 27 | 28 | */ 29 | namespace mongo { 30 | 31 | void updateSlaveLocation( CurOp& curop, const char * oplog_ns , OpTime lastOp ); 32 | 33 | /** @return true if op has made it to w servers */ 34 | bool opReplicatedEnough( OpTime op , int w ); 35 | bool opReplicatedEnough( OpTime op , BSONElement w ); 36 | 37 | bool waitForReplication( OpTime op , int w , int maxSecondsToWait ); 38 | 39 | std::vector getHostsWrittenTo(OpTime& op); 40 | 41 | void resetSlaveCache(); 42 | unsigned getSlaveCount(); 43 | } 44 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/resource.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | //{{NO_DEPENDENCIES}} 18 | // Microsoft Visual C++ generated include file. 19 | // Used by db.rc 20 | // 21 | #define IDI_ICON2 102 22 | 23 | // Next default values for new objects 24 | // 25 | #ifdef APSTUDIO_INVOKED 26 | #ifndef APSTUDIO_READONLY_SYMBOLS 27 | #define _APS_NEXT_RESOURCE_VALUE 104 28 | #define _APS_NEXT_COMMAND_VALUE 40001 29 | #define _APS_NEXT_CONTROL_VALUE 1001 30 | #define _APS_NEXT_SYMED_VALUE 101 31 | #endif 32 | #endif 33 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/restapi.h: -------------------------------------------------------------------------------- 1 | /** @file restapi.h 2 | */ 3 | 4 | /** 5 | * Copyright (C) 2010 10gen Inc. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License, version 3, 9 | * as published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "../util/admin_access.h" 23 | 24 | namespace mongo { 25 | 26 | class RestAdminAccess : public AdminAccess { 27 | public: 28 | virtual ~RestAdminAccess() { } 29 | 30 | virtual bool haveAdminUsers() const; 31 | virtual BSONObj getAdminUser( const string& username ) const; 32 | }; 33 | 34 | } // namespace mongo 35 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/sort_phase_one.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2008 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "mongo/db/extsort.h" 20 | 21 | namespace mongo { 22 | 23 | /** for bottom up fastbuildindex (where we presort keys) */ 24 | struct SortPhaseOne { 25 | SortPhaseOne() { 26 | n = 0; 27 | nkeys = 0; 28 | multi = false; 29 | } 30 | shared_ptr sorter; 31 | unsigned long long n; // # of records 32 | unsigned long long nkeys; 33 | bool multi; // multikey index 34 | 35 | void addKeys(const IndexSpec& spec, const BSONObj& o, DiskLoc loc, bool mayInterrupt) { 36 | BSONObjSet keys; 37 | spec.getKeys(o, keys); 38 | int k = 0; 39 | for ( BSONObjSet::iterator i=keys.begin(); i != keys.end(); i++ ) { 40 | if( ++k == 2 ) { 41 | multi = true; 42 | } 43 | sorter->add(*i, loc, mayInterrupt); 44 | nkeys++; 45 | } 46 | n++; 47 | } 48 | }; 49 | 50 | } 51 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/stats/service_stats.h: -------------------------------------------------------------------------------- 1 | // service_stats.h 2 | 3 | /** 4 | * Copyright (C) 2010 10gen Inc. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License, version 3, 8 | * as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef DB_STATS_SERVICE_STATS_HEADER 20 | #define DB_STATS_SERVICE_STATS_HEADER 21 | 22 | #include 23 | 24 | #include "../../util/concurrency/spin_lock.h" 25 | 26 | namespace mongo { 27 | 28 | using std::string; 29 | 30 | class Histogram; 31 | 32 | /** 33 | * ServiceStats keeps track of the time a request/response message 34 | * took inside a service as well as the size of the response 35 | * generated. 36 | */ 37 | class ServiceStats { 38 | public: 39 | ServiceStats(); 40 | ~ServiceStats(); 41 | 42 | /** 43 | * Record the 'duration' in microseconds a request/response 44 | * message took and the size in bytes of the generated 45 | * response. 46 | */ 47 | void logResponse( uint64_t duration, uint64_t bytes ); 48 | 49 | /** 50 | * Render the histogram as string that can be used inside an 51 | * HTML doc. 52 | */ 53 | string toHTML() const; 54 | 55 | private: 56 | SpinLock _spinLock; // protects state below 57 | Histogram* _timeHistogram; 58 | Histogram* _spaceHistogram; 59 | 60 | ServiceStats( const ServiceStats& ); 61 | ServiceStats operator=( const ServiceStats& ); 62 | }; 63 | 64 | } // namespace mongo 65 | 66 | #endif // DB_STATS_SERVICE_STATS_HEADER 67 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/db/ttl.h: -------------------------------------------------------------------------------- 1 | // ttl.h 2 | 3 | /** 4 | * Copyright (C) 2008 10gen Inc. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License, version 3, 8 | * as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | namespace mongo { 22 | void startTTLBackgroundJob(); 23 | } 24 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp : helper for using precompiled headers 2 | 3 | /* Copyright 2009 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include "pch.h" 19 | 20 | #if defined( __MSVC__ ) 21 | // should probably check VS version here 22 | #elif defined( __GNUC__ ) 23 | 24 | #if __GNUC__ < 4 25 | #error gcc < 4 not supported 26 | #endif 27 | 28 | #else 29 | // unknown compiler 30 | #endif 31 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/platform/atomic_intrinsics.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2012 10gen 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 | 16 | /** 17 | * WARNING(schwerin): Use with extreme caution. Prefer the AtomicWord<> types from atomic_word.h. 18 | * 19 | * The atomic_intrinsics module provides low-level atomic operations for manipulating memory. 20 | * Implementations are platform specific, so this file describes the interface and includes 21 | * the appropriate os/compiler-specific headers. 22 | * 23 | * For supported word types, the atomic_intrinsics headers provide implementations of template 24 | * classes of the following form: 25 | * 26 | * template class AtomicIntrinsics { 27 | * static T load(volatile const T* value); 28 | * static T store(volatile T* dest, T newValue); 29 | * static T compareAndSwap(volatile T* dest, T expected, T newValue); 30 | * static T swap(volatile T* dest, T newValue); 31 | * static T fetchAndAdd(volatile T* dest, T increment); 32 | * }; 33 | * 34 | * All of the functions assume that the volatile T pointers are naturally aligned, and may not 35 | * operate as expected, if they are not so aligned. 36 | * 37 | * The behavior of the functions is analogous to the same-named member functions of the AtomicWord 38 | * template type in atomic_word.h. 39 | */ 40 | 41 | #pragma once 42 | 43 | #if defined(_WIN32) 44 | #include "mongo/platform/atomic_intrinsics_win32.h" 45 | #elif defined(__GNUC__) 46 | #include "mongo/platform/atomic_intrinsics_gcc.h" 47 | #else 48 | #error "Unsupported os/compiler family" 49 | #endif 50 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/platform/basic.h: -------------------------------------------------------------------------------- 1 | // basic.h 2 | 3 | /* 4 | * Copyright 2010 10gen Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #pragma once 20 | 21 | #ifdef _WIN32 22 | #include "windows_basic.h" 23 | #endif 24 | 25 | #if defined(__linux__) 26 | 27 | #include 28 | 29 | // glibc's optimized versions are better than g++ builtins 30 | # define __builtin_strcmp strcmp 31 | # define __builtin_strlen strlen 32 | # define __builtin_memchr memchr 33 | # define __builtin_memcmp memcmp 34 | # define __builtin_memcpy memcpy 35 | # define __builtin_memset memset 36 | # define __builtin_memmove memmove 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/platform/bits.h: -------------------------------------------------------------------------------- 1 | // bits.h 2 | 3 | /* Copyright 2012 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #pragma once 19 | 20 | // figure out if we're on a 64 or 32 bit system 21 | 22 | #if defined(__x86_64__) || defined(__amd64__) || defined(_WIN64) 23 | #define MONGO_PLATFORM_64 24 | #elif defined(__i386__) || defined(_WIN32) 25 | #define MONGO_PLATFORM_32 26 | #else 27 | #error "unknown platform" 28 | #endif 29 | 30 | namespace mongo { 31 | // defined here so can test on linux 32 | inline int mongo_firstBitSet( unsigned long long v ) { 33 | if ( v == 0 ) 34 | return 0; 35 | 36 | for ( int i = 0; i<8; i++ ) { 37 | unsigned long long x = ( v >> ( 8 * i ) ) & 0xFF; 38 | if ( x == 0 ) 39 | continue; 40 | 41 | for ( int j = 0; j < 8; j++ ) { 42 | if ( ( x >> j ) & 0x1 ) 43 | return ( i * 8 ) + j + 1; 44 | } 45 | } 46 | 47 | return 0; 48 | } 49 | } 50 | 51 | 52 | #if defined(__linux__) 53 | #define firstBitSet ffsll 54 | #define MONGO_SYSTEM_FFS 1 55 | #elif defined(__MACH__) && defined(MONGO_PLATFORM_64) 56 | #define firstBitSet ffsl 57 | #define MONGO_SYSTEM_FFS 1 58 | #else 59 | #define firstBitSet mongo::mongo_firstBitSet 60 | #endif 61 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/platform/compiler.h: -------------------------------------------------------------------------------- 1 | // @file mongo/platform/compiler.h 2 | 3 | /* 4 | * Copyright 2012 10gen Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #pragma once 20 | 21 | /** 22 | * Include "mongo/platform/compiler.h" to get compiler-specific macro definitions and utilities. 23 | */ 24 | 25 | #if defined(_MSC_VER) 26 | #include "mongo/platform/compiler_msvc.h" 27 | #elif defined(__GNUC__) 28 | #include "mongo/platform/compiler_gcc.h" 29 | #else 30 | #error "Unsupported compiler family" 31 | #endif 32 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/platform/cstdint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 10gen Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | /** 20 | * Include "mongo/platform/cstdint.h" to get the C++11 cstdint types in namespace mongo. 21 | */ 22 | 23 | #if defined(_MSC_VER) 24 | #include 25 | #define _MONGO_STDINT_NAMESPACE std 26 | #elif defined(__GNUC__) 27 | #include 28 | #define _MONGO_STDINT_NAMESPACE 29 | #else 30 | #error "Unsupported compiler family" 31 | #endif 32 | 33 | namespace mongo { 34 | using _MONGO_STDINT_NAMESPACE::int8_t; 35 | using _MONGO_STDINT_NAMESPACE::int16_t; 36 | using _MONGO_STDINT_NAMESPACE::int32_t; 37 | using _MONGO_STDINT_NAMESPACE::int64_t; 38 | using _MONGO_STDINT_NAMESPACE::intptr_t; 39 | 40 | using _MONGO_STDINT_NAMESPACE::uint8_t; 41 | using _MONGO_STDINT_NAMESPACE::uint16_t; 42 | using _MONGO_STDINT_NAMESPACE::uint32_t; 43 | using _MONGO_STDINT_NAMESPACE::uint64_t; 44 | using _MONGO_STDINT_NAMESPACE::uintptr_t; 45 | } // namespace mongo 46 | 47 | #undef _MONGO_STDINT_NAMESPACE 48 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/platform/float_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 10gen Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | namespace mongo { 20 | 21 | inline bool isNaN(double d) { 22 | return d != d; 23 | } 24 | 25 | inline bool isInf(double d, int* sign = 0) { 26 | volatile double tmp = d; 27 | 28 | if ((tmp == d) && ((tmp - d) != 0.0)) { 29 | if ( sign ) { 30 | *sign = (d < 0.0 ? -1 : 1); 31 | } 32 | return true; 33 | } 34 | 35 | if ( sign ) { 36 | *sign = 0; 37 | } 38 | 39 | return false; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/platform/random.h: -------------------------------------------------------------------------------- 1 | // random.h 2 | 3 | /* Copyright 2012 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #pragma once 19 | 20 | #include "mongo/platform/cstdint.h" 21 | 22 | namespace mongo { 23 | 24 | /** 25 | * Uses http://en.wikipedia.org/wiki/Xorshift 26 | */ 27 | class PseudoRandom { 28 | public: 29 | PseudoRandom( int32_t seed ); 30 | 31 | PseudoRandom( uint32_t seed ); 32 | 33 | PseudoRandom( int64_t seed ); 34 | 35 | int32_t nextInt32(); 36 | 37 | int64_t nextInt64(); 38 | 39 | /** 40 | * @return a number between 0 and max 41 | */ 42 | int32_t nextInt32( int32_t max ) { return nextInt32() % max; } 43 | 44 | private: 45 | int32_t _x; 46 | int32_t _y; 47 | int32_t _z; 48 | int32_t _w; 49 | }; 50 | 51 | /** 52 | * More secure random numbers 53 | * Suitable for nonce/crypto 54 | * Slower than PseudoRandom, so only use when really need 55 | */ 56 | class SecureRandom { 57 | public: 58 | virtual ~SecureRandom(); 59 | 60 | virtual int64_t nextInt64() = 0; 61 | 62 | static SecureRandom* create(); 63 | }; 64 | 65 | } 66 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/platform/strtoll.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | #ifdef _WIN32 22 | static inline long long strtoll(const char* nptr, char** endptr, int base) { 23 | return _strtoi64(nptr, endptr, base); 24 | } 25 | 26 | static inline unsigned long long strtoull(const char* nptr, char** endptr, int base) { 27 | return _strtoui64(nptr, endptr, base); 28 | } 29 | #endif // defined(_WIN32) 30 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/platform/unordered_map.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2012 10gen 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 | 16 | #pragma once 17 | 18 | // NOTE(acm): Before gcc-4.7, __cplusplus is always defined to be 1, 19 | // so we can't reliably detect C++11 support by exclusively checking 20 | // the value of __cplusplus. 21 | #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) 22 | 23 | #include 24 | 25 | namespace mongo { 26 | 27 | using std::unordered_map; 28 | 29 | } // namespace mongo 30 | 31 | #elif defined(_MSC_VER) && _MSC_VER >= 1500 32 | 33 | #include 34 | 35 | namespace mongo { 36 | 37 | #if _MSC_VER >= 1600 /* Visual Studio 2010+ */ 38 | using std::unordered_map; 39 | #else 40 | using std::tr1::unordered_map; 41 | #endif 42 | 43 | } // namespace mongo 44 | 45 | #elif defined(__GNUC__) 46 | 47 | #include 48 | 49 | namespace mongo { 50 | 51 | using std::tr1::unordered_map; 52 | 53 | } // namespace mongo 54 | 55 | #else 56 | #error "Compiler's standard library does not provide a C++ unordered_map implementation." 57 | #endif 58 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/platform/unordered_set.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2012 10gen 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 | 16 | #pragma once 17 | 18 | // NOTE(acm): Before gcc-4.7, __cplusplus is always defined to be 1, 19 | // so we can't reliably detect C++11 support by exclusively checking 20 | // the value of __cplusplus. 21 | #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) 22 | 23 | #include 24 | 25 | namespace mongo { 26 | 27 | using std::unordered_set; 28 | 29 | } // namespace mongo 30 | 31 | #elif defined(_MSC_VER) && _MSC_VER >= 1500 32 | 33 | #include 34 | 35 | namespace mongo { 36 | 37 | #if _MSC_VER >= 1600 /* Visual Studio 2010+ */ 38 | using std::unordered_set; 39 | #else 40 | using std::tr1::unordered_set; 41 | #endif 42 | 43 | } // namespace mongo 44 | 45 | #elif defined(__GNUC__) 46 | 47 | #include 48 | 49 | namespace mongo { 50 | 51 | using std::tr1::unordered_set; 52 | 53 | } // namespace mongo 54 | 55 | #else 56 | #error "Compiler's standard library does not provide a C++ unordered_set implementation." 57 | #endif 58 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/platform/windows_basic.h: -------------------------------------------------------------------------------- 1 | // windows_basic.h 2 | 3 | /* 4 | * Copyright 2010 10gen Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #pragma once 20 | 21 | #if defined(_WIN32) 22 | // for rand_s() usage: 23 | # define _CRT_RAND_S 24 | # ifndef NOMINMAX 25 | # define NOMINMAX 26 | # endif 27 | // tell windows.h not to include a bunch of headers we don't need: 28 | # define WIN32_LEAN_AND_MEAN 29 | # include "mongo/targetver.h" 30 | 31 | # include //this must be included before the first windows.h include 32 | # include 33 | # include 34 | # include 35 | #endif 36 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/s/interrupt_status_mongos.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "mongo/pch.h" 20 | #include "db/interrupt_status.h" 21 | 22 | namespace mongo { 23 | 24 | class InterruptStatusMongos : 25 | public InterruptStatus, 26 | boost::noncopyable { 27 | public: 28 | // virtuals from InterruptStatus 29 | virtual void checkForInterrupt(); 30 | virtual const char *checkForInterruptNoAssert(); 31 | 32 | /* 33 | Static singleton instance. 34 | */ 35 | static InterruptStatusMongos status; 36 | 37 | private: 38 | InterruptStatusMongos(); 39 | }; 40 | 41 | }; 42 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/s/mongo_version_range.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | #include "mongo/base/string_data.h" 23 | #include "mongo/db/jsobj.h" 24 | 25 | namespace mongo { 26 | 27 | /** 28 | * The MongoVersionRange represents a min/max of MongoDB versions, useful for 29 | * excluding/including particular versions. 30 | * 31 | * The ranges may be single-version, in which case maxVersion == "", where only exact prefix 32 | * matches are included in the range. Alternately, the range may have a min and max version 33 | * and include any version with a prefix of the min and max version as well as all versions 34 | * between the two. 35 | */ 36 | struct MongoVersionRange { 37 | 38 | static bool parseBSONArray(const BSONArray& arr, 39 | std::vector* excludes, 40 | std::string* errMsg); 41 | 42 | static BSONArray toBSONArray(const std::vector& ranges); 43 | 44 | bool parseBSONElement(const BSONElement& el, std::string* errMsg); 45 | 46 | void toBSONElement(BSONArrayBuilder* barr) const; 47 | 48 | bool isInRange(const StringData& version) const; 49 | 50 | std::string minVersion; 51 | std::string maxVersion; 52 | }; 53 | 54 | bool isInMongoVersionRanges(const StringData& version, 55 | const std::vector& ranges); 56 | } 57 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/s/server.h: -------------------------------------------------------------------------------- 1 | // server.h 2 | 3 | /** 4 | * Copyright (C) 2008 10gen Inc. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License, version 3, 8 | * as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | #include "../util/net/message.h" 21 | #include "../db/jsobj.h" 22 | 23 | namespace mongo { 24 | 25 | extern OID serverID; 26 | 27 | // from request.cpp 28 | void processRequest(Message& m, MessagingPort& p); 29 | } 30 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/s/version_manager.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2008 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "mongo/db/jsobj.h" 20 | 21 | namespace mongo { 22 | 23 | class ShardConnection; 24 | class DBClientBase; 25 | 26 | class VersionManager { 27 | public: 28 | VersionManager(){}; 29 | 30 | bool isVersionableCB( DBClientBase* ); 31 | bool initShardVersionCB( DBClientBase*, BSONObj& ); 32 | bool forceRemoteCheckShardVersionCB( const string& ); 33 | bool checkShardVersionCB( DBClientBase*, const string&, bool, int ); 34 | bool checkShardVersionCB( ShardConnection*, bool, int ); 35 | void resetShardVersionCB( DBClientBase* ); 36 | 37 | }; 38 | 39 | extern VersionManager versionManager; 40 | 41 | } // namespace mongo 42 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/scripting/v8_profiler.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 10gen 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 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "mongo/base/string_data.h" 23 | #include "mongo/db/jsobj.h" 24 | 25 | namespace mongo { 26 | 27 | /** Collect CPU Profiling data from v8. */ 28 | class V8CpuProfiler { 29 | public: 30 | /** Start the CPU profiler */ 31 | void start(const StringData name); 32 | 33 | /** Stop the CPU profiler */ 34 | void stop(const StringData name); 35 | 36 | /** Get the current cpu profile */ 37 | const BSONArray fetch(const StringData name); 38 | private: 39 | void traverseDepthFirst(const v8::CpuProfileNode* cpuProfileNode, 40 | BSONArrayBuilder& arrayBuilder); 41 | 42 | typedef std::map CpuProfileMap; 43 | CpuProfileMap _cpuProfiles; 44 | }; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/server.h: -------------------------------------------------------------------------------- 1 | //server.h 2 | 3 | /** 4 | * Copyright (C) 2012 10gen Inc. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License, version 3, 8 | * as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /** 20 | This file contains includes commonly needed in the server files (mongod, mongos, test). It is *NOT* included in the C++ client; i.e. 21 | this is a very good place for global-ish things that you don't need to be in the client lib. 22 | 23 | Over time we should move more here, and more out of pch.h. And get rid of pch.h at some point. 24 | */ 25 | 26 | #pragma once 27 | 28 | #if !defined(MONGO_EXPOSE_MACROS) 29 | # error this file is for mongo server programs not client lib 30 | #endif 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | #include "bson/inline_decls.h" 37 | 38 | //using namespace std; 39 | //using namespace bson; 40 | 41 | /* Note: do not clutter code with these -- ONLY use in hot spots / significant loops. */ 42 | 43 | // branch prediction. indicate we expect to be true 44 | #define likely MONGO_likely 45 | 46 | // branch prediction. indicate we expect to be false 47 | #define unlikely MONGO_unlikely 48 | 49 | // prefetch data from memory 50 | //#define PREFETCH MONGOPREFETCH 51 | 52 | // logs at most once per secs 53 | #define LOGATMOST(secs) static time_t __last = 0; time_t __now=time(0); if(__last+secs>__now) {} else if ( ( __last = __now ) > 0 ) log() 54 | 55 | // log but not too fast. this is rather simplistic we can do something fancier later 56 | #define LOGSOME LOGATMOST(20) 57 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/shell/shell_utils_extended.h: -------------------------------------------------------------------------------- 1 | // mongo/shell/shell_utils_extended.h 2 | /* 3 | * Copyright 2010 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | 19 | #pragma once 20 | 21 | namespace mongo { 22 | 23 | class Scope; 24 | 25 | namespace shell_utils { 26 | void installShellUtilsExtended( Scope& scope ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/targetver.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2008 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | #ifdef _WIN32 19 | #ifndef _WIN32_WINNT 20 | #if defined _WIN64 21 | // For 64 bit Windows we require at least Windows Vista or Windows Server 2008. 22 | #define _WIN32_WINNT 0x0600 23 | #else 24 | // For 32 bit Windows we allow Windows XP as well. See platform/atomic_intrinsics_win32.h for 25 | // an example of where this makes a difference. 26 | #define _WIN32_WINNT 0x0502 27 | #endif 28 | #endif 29 | #endif 30 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/admin_access.h: -------------------------------------------------------------------------------- 1 | /** @file admin_access.h 2 | */ 3 | 4 | /** 5 | * Copyright (C) 2010 10gen Inc. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License, version 3, 9 | * as published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #pragma once 21 | 22 | namespace mongo { 23 | 24 | /* 25 | * An AdminAccess is an interface class used to determine if certain users have 26 | * privileges to a given resource. 27 | * 28 | */ 29 | class AdminAccess { 30 | public: 31 | virtual ~AdminAccess() { } 32 | 33 | /** @return if there are any priviledge users. This should not 34 | * block for long and throw if can't get a lock if needed. 35 | */ 36 | virtual bool haveAdminUsers() const = 0; 37 | 38 | /** @return privileged user with this name. This should not block 39 | * for long and throw if can't get a lock if needed 40 | */ 41 | virtual BSONObj getAdminUser( const string& username ) const = 0; 42 | }; 43 | 44 | class NoAdminAccess : public AdminAccess { 45 | public: 46 | virtual ~NoAdminAccess() { } 47 | 48 | virtual bool haveAdminUsers() const { return false; } 49 | virtual BSONObj getAdminUser( const string& username ) const { return BSONObj(); } 50 | }; 51 | 52 | } // namespace mongo 53 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/allocator.h: -------------------------------------------------------------------------------- 1 | // allocator.h 2 | 3 | /* Copyright 2009 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #pragma once 19 | 20 | #include "mongo/util/signal_handlers.h" 21 | 22 | // we need the "real" malloc here 23 | #include "mongo/client/undef_macros.h" 24 | 25 | namespace mongo { 26 | 27 | inline void * ourmalloc(size_t size) { 28 | void *x = malloc(size); 29 | if ( x == 0 ) printStackAndExit(0); 30 | return x; 31 | } 32 | 33 | inline void * ourrealloc(void *ptr, size_t size) { 34 | void *x = realloc(ptr, size); 35 | if ( x == 0 ) printStackAndExit(0); 36 | return x; 37 | } 38 | 39 | #define MONGO_malloc mongo::ourmalloc 40 | #define MONGO_realloc mongo::ourrealloc 41 | 42 | // this redefines 'malloc' to 'MONGO_malloc', etc 43 | #include "mongo/client/redef_macros.h" 44 | 45 | } // namespace mongo 46 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/bson_util.h: -------------------------------------------------------------------------------- 1 | // bson_util.h 2 | 3 | /* Copyright 2009 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #pragma once 19 | 20 | #include "mongo/pch.h" 21 | 22 | namespace mongo { 23 | 24 | template 25 | void bsonArrToNumVector(BSONElement el, vector& results){ 26 | 27 | if(el.type() == Array){ 28 | 29 | vector elements = el.Array(); 30 | 31 | for(vector::iterator i = elements.begin(); i != elements.end(); ++i){ 32 | results.push_back( (T) (*i).Number() ); 33 | } 34 | } 35 | else if(el.isNumber()){ 36 | results.push_back( (T) el.Number() ); 37 | } 38 | 39 | } 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/checksum.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "mongo/pch.h" 20 | 21 | namespace mongo { 22 | /** a simple, rather dumb, but very fast checksum. see perftests.cpp for unit tests. */ 23 | struct Checksum { 24 | union { 25 | unsigned char bytes[16]; 26 | unsigned long long words[2]; 27 | }; 28 | 29 | // if you change this you must bump dur::CurrentVersion 30 | void gen(const void *buf, unsigned len) { 31 | wassert( ((size_t)buf) % 8 == 0 ); // performance warning 32 | unsigned n = len / 8 / 2; 33 | const unsigned long long *p = (const unsigned long long *) buf; 34 | unsigned long long a = 0; 35 | for( unsigned i = 0; i < n; i++ ) { 36 | a += (*p ^ i); 37 | p++; 38 | } 39 | unsigned long long b = 0; 40 | for( unsigned i = 0; i < n; i++ ) { 41 | b += (*p ^ i); 42 | p++; 43 | } 44 | unsigned long long c = 0; 45 | for( unsigned i = n * 2 * 8; i < len; i++ ) { // 0-7 bytes left 46 | c = (c << 8) | ((const char *)buf)[i]; 47 | } 48 | words[0] = a ^ len; 49 | words[1] = b ^ c; 50 | } 51 | 52 | bool operator==(const Checksum& rhs) const { return words[0]==rhs.words[0] && words[1]==rhs.words[1]; } 53 | bool operator!=(const Checksum& rhs) const { return words[0]!=rhs.words[0] || words[1]!=rhs.words[1]; } 54 | }; 55 | } 56 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/compress.h: -------------------------------------------------------------------------------- 1 | // @file compress.h 2 | 3 | /** 4 | * Copyright (C) 2012 10gen Inc. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License, version 3, 8 | * as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | namespace mongo { 24 | 25 | size_t compress(const char* input, size_t input_length, std::string* output); 26 | 27 | bool uncompress(const char* compressed, size_t compressed_length, std::string* uncompressed); 28 | 29 | size_t maxCompressedLength(size_t source_len); 30 | void rawCompress(const char* input, 31 | size_t input_length, 32 | char* compressed, 33 | size_t* compressed_length); 34 | 35 | } 36 | 37 | 38 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/concurrency/msg.h: -------------------------------------------------------------------------------- 1 | // @file msg.h - interthread message passing 2 | 3 | /** 4 | * Copyright (C) 2008 10gen Inc. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License, version 3, 8 | * as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful,b 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | #include 24 | #include "task.h" 25 | 26 | namespace mongo { 27 | 28 | namespace task { 29 | 30 | typedef boost::function lam; 31 | 32 | /** typical usage is: task::fork( new Server("threadname") ); */ 33 | class Server : public Task { 34 | public: 35 | /** send a message to the port */ 36 | void send(lam); 37 | 38 | Server(const std::string& name) : m("server"), _name(name), rq(false) { } 39 | virtual ~Server() { } 40 | 41 | /** send message but block until function completes */ 42 | void call(const lam&); 43 | 44 | void requeue() { rq = true; } 45 | 46 | protected: 47 | /* REMINDER : for use in mongod, you will want to have this call Client::initThread(). */ 48 | virtual void starting() { } 49 | 50 | private: 51 | virtual bool initClient() { return true; } 52 | virtual string name() const { return _name; } 53 | void doWork(); 54 | deque d; 55 | mongo::mutex m; 56 | boost::condition c; 57 | string _name; 58 | bool rq; 59 | }; 60 | 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/concurrency/simplerwlock.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "mongo/base/string_data.h" 20 | #include "mongo/bson/util/atomic_int.h" 21 | 22 | namespace mongo { 23 | 24 | /** separated out as later the implementation of this may be different than RWLock, 25 | depending on OS, as there is no upgrade etc. facility herein. 26 | */ 27 | class SimpleRWLock : boost::noncopyable { 28 | #if defined(_WIN32) && defined(MONGO_USE_SRW_ON_WINDOWS) 29 | SRWLOCK _lock; 30 | #else 31 | RWLockBase m; 32 | #endif 33 | #if defined(_WIN32) && defined(_DEBUG) 34 | AtomicUInt shares; 35 | ThreadLocalValue s; 36 | unsigned tid; 37 | #endif 38 | public: 39 | const string name; 40 | SimpleRWLock(const StringData& name = "" ); 41 | void lock(); 42 | void unlock(); 43 | void lock_shared(); 44 | void unlock_shared(); 45 | class Shared : boost::noncopyable { 46 | SimpleRWLock& _r; 47 | public: 48 | Shared(SimpleRWLock& rwlock) : _r(rwlock) {_r.lock_shared(); } 49 | ~Shared() { _r.unlock_shared(); } 50 | }; 51 | class Exclusive : boost::noncopyable { 52 | SimpleRWLock& _r; 53 | public: 54 | Exclusive(SimpleRWLock& rwlock) : _r(rwlock) {_r.lock(); } 55 | ~Exclusive() { _r.unlock(); } 56 | }; 57 | }; 58 | 59 | } 60 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/debug_util.h: -------------------------------------------------------------------------------- 1 | // debug_util.h 2 | 3 | /* Copyright 2009 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #pragma once 19 | 20 | 21 | namespace mongo { 22 | 23 | #if defined(_DEBUG) 24 | enum {DEBUG_BUILD = 1}; 25 | const bool debug=true; 26 | #else 27 | enum {DEBUG_BUILD = 0}; 28 | const bool debug=false; 29 | #endif 30 | 31 | #define MONGO_DEV if( DEBUG_BUILD ) 32 | #define DEV MONGO_DEV 33 | 34 | #define MONGO_DEBUGGING if( 0 ) 35 | #define DEBUGGING MONGO_DEBUGGING 36 | 37 | // The following declare one unique counter per enclosing function. 38 | // NOTE The implementation double-increments on a match, but we don't really care. 39 | #define MONGO_SOMETIMES( occasion, howOften ) for( static unsigned occasion = 0; ++occasion % howOften == 0; ) 40 | #define SOMETIMES MONGO_SOMETIMES 41 | 42 | #define MONGO_OCCASIONALLY SOMETIMES( occasionally, 16 ) 43 | #define OCCASIONALLY MONGO_OCCASIONALLY 44 | 45 | #define MONGO_RARELY SOMETIMES( rarely, 128 ) 46 | #define RARELY MONGO_RARELY 47 | 48 | #define MONGO_ONCE for( static bool undone = true; undone; undone = false ) 49 | #define ONCE MONGO_ONCE 50 | 51 | #if defined(_WIN32) 52 | inline int strcasecmp(const char* s1, const char* s2) {return _stricmp(s1, s2);} 53 | #endif 54 | 55 | // Sets SIGTRAP handler to launch GDB 56 | // Noop unless on *NIX and compiled with _DEBUG 57 | void setupSIGTRAPforGDB(); 58 | 59 | extern int tlogLevel; 60 | void mongo_breakpoint(); 61 | inline void breakpoint() { 62 | if ( tlogLevel < 0 ) 63 | return; 64 | mongo_breakpoint(); 65 | } 66 | } // namespace mongo 67 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/elapsed_tracker.h: -------------------------------------------------------------------------------- 1 | // @file elapsed_tracker.h 2 | 3 | /** 4 | * Copyright (C) 2009 10gen Inc. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License, version 3, 8 | * as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "mongo/platform/cstdint.h" 22 | 23 | namespace mongo { 24 | 25 | /** Keep track of elapsed time. After a set amount of time, tells you to do something. */ 26 | class ElapsedTracker { 27 | public: 28 | ElapsedTracker( int32_t hitsBetweenMarks, int32_t msBetweenMarks ); 29 | 30 | /** 31 | * Call this for every iteration. 32 | * @return true if one of the triggers has gone off. 33 | */ 34 | bool intervalHasElapsed(); 35 | 36 | void resetLastTime(); 37 | 38 | private: 39 | const int32_t _hitsBetweenMarks; 40 | const int32_t _msBetweenMarks; 41 | 42 | uint64_t _pings; 43 | 44 | int64_t _last; 45 | }; 46 | 47 | } // namespace mongo 48 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/exception_filter_win32.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | namespace mongo { 20 | 21 | void setWindowsUnhandledExceptionFilter(); 22 | 23 | } // namespace mongo 24 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/exit_code.h: -------------------------------------------------------------------------------- 1 | /** @file mongo/util/exit_code.h 2 | * 3 | * Mongo exit codes. 4 | */ 5 | 6 | /* Copyright 2009 10gen Inc. 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | #pragma once 22 | 23 | namespace mongo { 24 | 25 | enum ExitCode { 26 | EXIT_CLEAN = 0 , 27 | EXIT_BADOPTIONS = 2 , 28 | EXIT_REPLICATION_ERROR = 3 , 29 | EXIT_NEED_UPGRADE = 4 , 30 | EXIT_SHARDING_ERROR = 5 , 31 | EXIT_KILL = 12 , 32 | EXIT_ABRUPT = 14 , 33 | EXIT_NTSERVICE_ERROR = 20 , 34 | EXIT_JAVA = 21 , 35 | EXIT_OOM_MALLOC = 42 , 36 | EXIT_OOM_REALLOC = 43 , 37 | EXIT_FS = 45 , 38 | EXIT_CLOCK_SKEW = 47 , 39 | EXIT_NET_ERROR = 48 , 40 | EXIT_WINDOWS_SERVICE_STOP = 49 , 41 | EXIT_POSSIBLE_CORRUPTION = 60 , // this means we detected a possible corruption situation, like a buf overflow 42 | EXIT_UNCAUGHT = 100 , // top level exception that wasn't caught 43 | EXIT_TEST = 101 44 | }; 45 | 46 | } // namespace mongo 47 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/fail_point_registry.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "mongo/util/fail_point_registry.h" 18 | 19 | #include "mongo/db/commands.h" 20 | #include "mongo/util/map_util.h" 21 | #include "mongo/util/mongoutils/str.h" 22 | 23 | using mongoutils::str::stream; 24 | 25 | namespace mongo { 26 | FailPointRegistry::FailPointRegistry(): _frozen(false) { 27 | } 28 | 29 | Status FailPointRegistry::addFailPoint(const string& name, 30 | FailPoint* failPoint) { 31 | if (_frozen) { 32 | return Status(ErrorCodes::CannotMutateObject, "Registry is already frozen"); 33 | } 34 | 35 | if (_fpMap.count(name) > 0) { 36 | return Status(ErrorCodes::DuplicateKey, 37 | stream() << "Fail point already registered: " << name); 38 | } 39 | 40 | _fpMap.insert(make_pair(name, failPoint)); 41 | return Status::OK(); 42 | } 43 | 44 | FailPoint* FailPointRegistry::getFailPoint(const string& name) const { 45 | return mapFindWithDefault(_fpMap, name, reinterpret_cast(NULL)); 46 | } 47 | 48 | void FailPointRegistry::freeze() { 49 | _frozen = true; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/fail_point_registry.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | /** 18 | * Should NOT be included by other header files. Include only in source files. 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "mongo/base/status.h" 24 | #include "mongo/platform/unordered_map.h" 25 | #include "mongo/util/fail_point.h" 26 | 27 | namespace mongo { 28 | /** 29 | * Class for storing FailPoint instances. 30 | */ 31 | class FailPointRegistry { 32 | public: 33 | FailPointRegistry(); 34 | 35 | /** 36 | * Adds a new fail point to this registry. Duplicate names are not allowed. 37 | * 38 | * @return the status code under these circumstances: 39 | * OK - if successful. 40 | * DuplicateKey - if the given name already exists in this registry. 41 | * CannotMutateObject - if this registry is already frozen. 42 | */ 43 | Status addFailPoint(const std::string& name, FailPoint* failPoint); 44 | 45 | /** 46 | * @return the fail point object registered. Returns NULL if it was not registered. 47 | */ 48 | FailPoint* getFailPoint(const std::string& name) const; 49 | 50 | /** 51 | * Freezes this registry from being modified. 52 | */ 53 | void freeze(); 54 | 55 | private: 56 | bool _frozen; 57 | unordered_map _fpMap; 58 | }; 59 | } 60 | 61 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/fail_point_service.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "mongo/util/fail_point_service.h" 18 | 19 | namespace mongo { 20 | MONGO_FP_DECLARE(dummy); // used by jstests/libs/fail_point.js 21 | 22 | scoped_ptr _fpRegistry(NULL); 23 | 24 | MONGO_INITIALIZER(FailPointRegistry)(InitializerContext* context) { 25 | _fpRegistry.reset(new FailPointRegistry()); 26 | return Status::OK(); 27 | } 28 | 29 | MONGO_INITIALIZER_GENERAL(AllFailPointsRegistered, (), ())(InitializerContext* context) { 30 | _fpRegistry->freeze(); 31 | return Status::OK(); 32 | } 33 | 34 | FailPointRegistry* getGlobalFailPointRegistry() { 35 | return _fpRegistry.get(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/fail_point_service.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | /** 18 | * Should NOT be included by other header files. Include only in source files. 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "mongo/base/init.h" 24 | #include "mongo/util/fail_point_registry.h" 25 | 26 | namespace mongo { 27 | /** 28 | * @return the global fail point registry. 29 | */ 30 | FailPointRegistry* getGlobalFailPointRegistry(); 31 | 32 | /** 33 | * Convenience macro for declaring a fail point. Must be used in global scope and 34 | * never in a block with limited scope (ie, inside functions, loops, etc.) 35 | */ 36 | #define MONGO_FP_DECLARE(fp) FailPoint fp; \ 37 | MONGO_INITIALIZER_GENERAL(fp, ("FailPointRegistry"), ("AllFailPointsRegistered")) \ 38 | (::mongo::InitializerContext* context) { \ 39 | return getGlobalFailPointRegistry()->addFailPoint(#fp, &fp); \ 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/file.h: -------------------------------------------------------------------------------- 1 | // file.h cross platform basic file class. supports 64 bit offsets and such. 2 | 3 | /* Copyright 2009 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | #include 22 | 23 | #include "mongo/platform/basic.h" 24 | #include "mongo/platform/cstdint.h" 25 | 26 | namespace mongo { 27 | 28 | typedef uint64_t fileofs; 29 | 30 | // NOTE: not thread-safe. (at least the windows implementation isn't) 31 | 32 | class File { 33 | 34 | public: 35 | File(); 36 | ~File(); 37 | 38 | bool bad() const { return _bad; } 39 | void fsync() const; 40 | bool is_open() const; 41 | fileofs len(); 42 | void open(const char* filename, bool readOnly = false, bool direct = false); 43 | void read(fileofs o, char* data, unsigned len); 44 | void truncate(fileofs size); 45 | void write(fileofs o, const char* data, unsigned len); 46 | 47 | static boost::intmax_t freeSpace(const std::string& path); 48 | 49 | private: 50 | bool _bad; 51 | #ifdef _WIN32 52 | HANDLE _handle; 53 | #else 54 | int _fd; 55 | #endif 56 | std::string _name; 57 | 58 | }; 59 | 60 | } 61 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/heapcheck.h: -------------------------------------------------------------------------------- 1 | // @file heapcheck.h 2 | 3 | /** 4 | * Copyright (C) 2010 10gen Inc. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License, version 3, 8 | * as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #if defined(HEAP_CHECKING) 22 | 23 | #include 24 | 25 | #define IGNORE_OBJECT( a ) HeapLeakChecker::IgnoreObject( a ) 26 | #define UNIGNORE_OBJECT( a ) HeapLeakChecker::UnIgnoreObject( a ) 27 | 28 | #else 29 | 30 | #define IGNORE_OBJECT( a ) 31 | #define UNIGNORE_OBJECT( a ) 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/intrusive_counter.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include "pch.h" 18 | #include "mongo/util/intrusive_counter.h" 19 | #include "mongo/util/mongoutils/str.h" 20 | 21 | namespace mongo { 22 | using namespace mongoutils; 23 | 24 | intrusive_ptr RCString::create(StringData s) { 25 | const size_t sizeWithNUL = s.size() + 1; 26 | const size_t bytesNeeded = sizeof(RCString) + sizeWithNUL; 27 | uassert(16493, str::stream() << "Tried to create string longer than " 28 | << (BSONObjMaxUserSize/1024/1024) << "MB", 29 | bytesNeeded < static_cast(BSONObjMaxUserSize)); 30 | 31 | intrusive_ptr ptr = new (bytesNeeded) RCString(); // uses custom operator new 32 | 33 | ptr->_size = s.size(); 34 | char* stringStart = reinterpret_cast(ptr.get()) + sizeof(RCString); 35 | s.copyTo(stringStart, true); 36 | 37 | return ptr; 38 | } 39 | 40 | void IntrusiveCounterUnsigned::addRef() const { 41 | ++counter; 42 | } 43 | 44 | void IntrusiveCounterUnsigned::release() const { 45 | if (!--counter) 46 | delete this; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/logfile.h: -------------------------------------------------------------------------------- 1 | // @file logfile.h simple file log writing / journaling 2 | 3 | /** 4 | * Copyright (C) 2010 10gen Inc. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License, version 3, 8 | * as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | namespace mongo { 22 | 23 | class LogFile { 24 | public: 25 | /** create the file and open. must not already exist. 26 | throws UserAssertion on i/o error 27 | */ 28 | LogFile(const std::string& name, bool readwrite = false); 29 | 30 | /** closes */ 31 | ~LogFile(); 32 | 33 | /** append to file. does not return until sync'd. uses direct i/o when possible. 34 | throws UserAssertion on an i/o error 35 | note direct i/o may have alignment requirements 36 | */ 37 | void synchronousAppend(const void *buf, size_t len); 38 | 39 | /** write at specified offset. must be aligned. noreturn until physically written. thread safe */ 40 | void writeAt(unsigned long long offset, const void *_bug, size_t _len); 41 | 42 | void readAt(unsigned long long offset, void *_buf, size_t _len); 43 | 44 | const string _name; 45 | 46 | void truncate(); // Removes extra data after current position 47 | 48 | private: 49 | #if defined(_WIN32) 50 | typedef HANDLE fd_type; 51 | #else 52 | typedef int fd_type; 53 | #endif 54 | fd_type _fd; 55 | bool _direct; // are we using direct I/O 56 | }; 57 | 58 | } 59 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/map_util.h: -------------------------------------------------------------------------------- 1 | // "mongo/util/map_util.h" 2 | 3 | /* Copyright 2012 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #pragma once 19 | 20 | namespace mongo { 21 | 22 | /* 23 | * If "myMap" contains "key", returns "myMap[key]". Otherwise, returns "defaultValue." 24 | */ 25 | template 26 | V mapFindWithDefault(const M& myMap, const K& key, const V& defaultValue) { 27 | typename M::const_iterator it = myMap.find(key); 28 | if(it == myMap.end()) 29 | return defaultValue; 30 | return it->second; 31 | } 32 | 33 | } // end namespace 34 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/md5.hpp: -------------------------------------------------------------------------------- 1 | // md5.hpp 2 | 3 | /* Copyright 2009 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #pragma once 19 | 20 | #include "md5.h" 21 | 22 | namespace mongo { 23 | 24 | typedef unsigned char md5digest[16]; 25 | 26 | inline void md5(const void *buf, int nbytes, md5digest digest) { 27 | md5_state_t st; 28 | md5_init(&st); 29 | md5_append(&st, (const md5_byte_t *) buf, nbytes); 30 | md5_finish(&st, digest); 31 | } 32 | 33 | inline void md5(const char *str, md5digest digest) { 34 | md5(str, strlen(str), digest); 35 | } 36 | 37 | inline std::string digestToString( md5digest digest ){ 38 | static const char * letters = "0123456789abcdef"; 39 | stringstream ss; 40 | for ( int i=0; i<16; i++){ 41 | unsigned char c = digest[i]; 42 | ss << letters[ ( c >> 4 ) & 0xf ] << letters[ c & 0xf ]; 43 | } 44 | return ss.str(); 45 | } 46 | 47 | inline std::string md5simpledigest( const void* buf, int nbytes){ 48 | md5digest d; 49 | md5( buf, nbytes , d ); 50 | return digestToString( d ); 51 | } 52 | 53 | inline std::string md5simpledigest( const std::string& s ){ 54 | return md5simpledigest(s.data(), s.size()); 55 | } 56 | 57 | 58 | } // namespace mongo 59 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/mongoutils/checksum.h: -------------------------------------------------------------------------------- 1 | /** @file checksum.h */ 2 | 3 | /* Copyright 2009 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #pragma once 19 | 20 | namespace mongoutils { 21 | 22 | /** 23 | * this is a silly temporary implementation 24 | */ 25 | inline int checksum( const char* x , int size ) { 26 | int ck = 0; 27 | for ( int i=0; i Headers; 29 | 30 | class Result { 31 | public: 32 | Result() {} 33 | 34 | const string& getEntireResponse() const { 35 | return _entireResponse; 36 | } 37 | 38 | Headers getHeaders() const { 39 | return _headers; 40 | } 41 | 42 | const string& getBody() const { 43 | return _body; 44 | } 45 | 46 | private: 47 | 48 | void _init( int code , string entire ); 49 | 50 | int _code; 51 | string _entireResponse; 52 | 53 | Headers _headers; 54 | string _body; 55 | 56 | friend class HttpClient; 57 | }; 58 | 59 | /** 60 | * @return response code 61 | */ 62 | int get( const std::string& url , Result * result = 0 ); 63 | 64 | /** 65 | * @return response code 66 | */ 67 | int post( const std::string& url , const std::string& body , Result * result = 0 ); 68 | 69 | private: 70 | int _go( const char * command , string url , const char * body , Result * result ); 71 | 72 | #ifdef MONGO_SSL 73 | void _checkSSLManager(); 74 | 75 | scoped_ptr _sslManager; 76 | #endif 77 | }; 78 | } 79 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/net/message.cpp: -------------------------------------------------------------------------------- 1 | // message.cpp 2 | 3 | /* Copyright 2009 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include "pch.h" 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include "message.h" 25 | #include "message_port.h" 26 | #include "listen.h" 27 | 28 | #include "../goodies.h" 29 | 30 | 31 | namespace mongo { 32 | 33 | void Message::send( MessagingPort &p, const char *context ) { 34 | if ( empty() ) { 35 | return; 36 | } 37 | if ( _buf != 0 ) { 38 | p.send( (char*)_buf, _buf->len, context ); 39 | } 40 | else { 41 | p.send( _data, context ); 42 | } 43 | } 44 | 45 | MSGID NextMsgId; 46 | 47 | /*struct MsgStart { 48 | MsgStart() { 49 | NextMsgId = (((unsigned) time(0)) << 16) ^ curTimeMillis(); 50 | verify(MsgDataHeaderSize == 16); 51 | } 52 | } msgstart;*/ 53 | 54 | MSGID nextMessageId() { 55 | MSGID msgid = NextMsgId++; 56 | return msgid; 57 | } 58 | 59 | bool doesOpGetAResponse( int op ) { 60 | return op == dbQuery || op == dbGetMore; 61 | } 62 | 63 | 64 | } // namespace mongo 65 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/net/message_server.h: -------------------------------------------------------------------------------- 1 | // message_server.h 2 | 3 | /* Copyright 2009 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /* 19 | abstract database server 20 | async io core, worker thread system 21 | */ 22 | 23 | #pragma once 24 | 25 | #include "mongo/pch.h" 26 | 27 | namespace mongo { 28 | 29 | struct LastError; 30 | 31 | class MessageHandler { 32 | public: 33 | virtual ~MessageHandler() {} 34 | 35 | /** 36 | * called once when a socket is connected 37 | */ 38 | virtual void connected( AbstractMessagingPort* p ) = 0; 39 | 40 | /** 41 | * called every time a message comes in 42 | * handler is responsible for responding to client 43 | */ 44 | virtual void process( Message& m , AbstractMessagingPort* p , LastError * err ) = 0; 45 | 46 | /** 47 | * called once when a socket is disconnected 48 | */ 49 | virtual void disconnected( AbstractMessagingPort* p ) = 0; 50 | }; 51 | 52 | class MessageServer { 53 | public: 54 | struct Options { 55 | int port; // port to bind to 56 | string ipList; // addresses to bind to 57 | 58 | Options() : port(0), ipList("") {} 59 | }; 60 | 61 | virtual ~MessageServer() {} 62 | virtual void run() = 0; 63 | virtual void setAsTimeTracker() = 0; 64 | }; 65 | 66 | // TODO use a factory here to decide between port and asio variations 67 | MessageServer * createServer( const MessageServer::Options& opts , MessageHandler * handler ); 68 | } 69 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/net/miniwebserver.h: -------------------------------------------------------------------------------- 1 | // miniwebserver.h 2 | 3 | /* Copyright 2009 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #pragma once 19 | 20 | #include "mongo/pch.h" 21 | #include "message.h" 22 | #include "message_port.h" 23 | #include "listen.h" 24 | #include "../../db/jsobj.h" 25 | 26 | namespace mongo { 27 | 28 | class MiniWebServer : public Listener { 29 | public: 30 | MiniWebServer(const string& name, const string &ip, int _port); 31 | virtual ~MiniWebServer() {} 32 | 33 | virtual void doRequest( 34 | const char *rq, // the full request 35 | string url, 36 | // set these and return them: 37 | string& responseMsg, 38 | int& responseCode, 39 | vector& headers, // if completely empty, content-type: text/html will be added 40 | const SockAddr &from 41 | ) = 0; 42 | 43 | // --- static helpers ---- 44 | 45 | static void parseParams( BSONObj & params , string query ); 46 | 47 | static string parseURL( const char * buf ); 48 | static string parseMethod( const char * headers ); 49 | static string getHeader( const char * headers , const std::string& name ); 50 | static const char *body( const char *buf ); 51 | 52 | static string urlDecode(const char* s); 53 | static string urlDecode(const std::string& s) {return urlDecode(s.c_str());} 54 | 55 | private: 56 | void accepted(boost::shared_ptr psocket, long long connectionId ); 57 | static bool fullReceive( const char *buf ); 58 | }; 59 | 60 | } // namespace mongo 61 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/password.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 10gen Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | #pragma once 19 | 20 | #include 21 | #include 22 | 23 | namespace mongo { 24 | 25 | struct PasswordValue : public boost::program_options::typed_value { 26 | 27 | PasswordValue( std::string* val ) 28 | : boost::program_options::typed_value( val ) { } 29 | 30 | unsigned min_tokens() const { 31 | return 0; 32 | } 33 | 34 | unsigned max_tokens() const { 35 | return 1; 36 | } 37 | 38 | bool is_required() const { 39 | return false; 40 | } 41 | 42 | void xparse( boost::any& value_store, 43 | const std::vector& new_tokens ) const { 44 | if ( !value_store.empty() ) 45 | #if BOOST_VERSION >= 104200 46 | boost::throw_exception( boost::program_options::validation_error( boost::program_options::validation_error::multiple_values_not_allowed ) ); 47 | #else 48 | boost::throw_exception( boost::program_options::validation_error( "multiple values not allowed" ) ); 49 | #endif 50 | else if ( !new_tokens.empty() ) 51 | boost::program_options::typed_value::xparse 52 | (value_store, new_tokens); 53 | else 54 | value_store = std::string(); 55 | } 56 | 57 | }; 58 | 59 | std::string askPassword(); 60 | 61 | } 62 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/processinfo.cpp: -------------------------------------------------------------------------------- 1 | // processinfo.cpp 2 | 3 | /* Copyright 2009 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include "mongo/pch.h" 19 | 20 | #include "mongo/base/init.h" 21 | #include "mongo/util/processinfo.h" 22 | 23 | #include 24 | #include 25 | 26 | using namespace std; 27 | 28 | namespace mongo { 29 | 30 | class PidFileWiper { 31 | public: 32 | ~PidFileWiper() { 33 | ofstream out( path.c_str() , ios_base::out ); 34 | out.close(); 35 | } 36 | 37 | void write( const string& p ) { 38 | path = p; 39 | ofstream out( path.c_str() , ios_base::out ); 40 | out << getpid() << endl; 41 | out.close(); 42 | } 43 | 44 | string path; 45 | } pidFileWiper; 46 | 47 | void writePidFile( const string& path ) { 48 | pidFileWiper.write( path ); 49 | } 50 | 51 | ProcessInfo::SystemInfo* ProcessInfo::systemInfo = NULL; 52 | 53 | void ProcessInfo::initializeSystemInfo() { 54 | if (systemInfo == NULL) { 55 | systemInfo = new SystemInfo(); 56 | } 57 | } 58 | 59 | MONGO_INITIALIZER(SystemInfo)(InitializerContext* context) { 60 | ProcessInfo::initializeSystemInfo(); 61 | return Status::OK(); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/sequence_util.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 10gen 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 | 16 | /** 17 | * This file declares utility methods for operating on sequence containers, such as vectors, lists 18 | * and deques. 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | namespace mongo { 26 | 27 | /* 28 | * Returns true if "container" contains "value". 29 | */ 30 | template 31 | bool sequenceContains(const C& container, typename C::const_reference value) { 32 | using std::find; 33 | return find(container.begin(), container.end(), value) != container.end(); 34 | } 35 | 36 | } // namespace mongo 37 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/signal_handlers.h: -------------------------------------------------------------------------------- 1 | // signal_handlers.h 2 | 3 | /** 4 | * Copyright (C) 2010 10gen Inc. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License, version 3, 8 | * as published by the Free Software Foundation. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | namespace mongo { 22 | 23 | /** 24 | * Obtains the log file handler and writes the current thread's stack trace to 25 | * it. This call issues an exit(). The function can safely be called from within a 26 | * signal handler. 27 | * 28 | * @param signal that this hadler is called for 29 | */ 30 | void printStackAndExit( int signalNum ); 31 | 32 | } // namespace mongo 33 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/stack_introspect.h: -------------------------------------------------------------------------------- 1 | // stack_introspect.h 2 | 3 | /* Copyright 2010 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #pragma once 19 | 20 | namespace mongo { 21 | 22 | /** 23 | * checks up call tree 24 | * if any method on top of me is a constructor, return true 25 | * may do internal caching 26 | * probably slow, use with care 27 | * if not implemented for a platform, returns false 28 | */ 29 | bool inConstructorChain( bool printOffending=false ); 30 | 31 | /** 32 | * @return if supported on platform, compile options may still prevent it from working 33 | */ 34 | bool inConstructorChainSupported(); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/stacktrace.h: -------------------------------------------------------------------------------- 1 | // Copyright 2009. 10gen, Inc. 2 | 3 | /** 4 | * Tools for working with in-process stack traces. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | #include "mongo/platform/basic.h" 12 | 13 | namespace mongo { 14 | 15 | // Print stack trace information to "os", default to std::cout. 16 | void printStackTrace(std::ostream &os=std::cout); 17 | 18 | #if defined(_WIN32) 19 | // Print stack trace (using a specified stack context) to "os", default to std::cout. 20 | void printWindowsStackTrace(CONTEXT &context, std::ostream &os=std::cout); 21 | 22 | // Print error message from C runtime followed by stack trace 23 | int crtDebugCallback(int, char* originalMessage, int*); 24 | #endif 25 | 26 | } // namespace mongo 27 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/startup_test.h: -------------------------------------------------------------------------------- 1 | // mongo/util/startup_test.h 2 | 3 | /* Copyright 2009 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | namespace mongo { 23 | 24 | /* The idea here is to let all initialization of global variables (classes inheriting from StartupTest) 25 | complete before we run the tests -- otherwise order of initilization being arbitrary may mess 26 | us up. The app's main() function should call runTests(). 27 | 28 | To define a unit test, inherit from this and implement run. instantiate one object for the new class 29 | as a global. 30 | 31 | These tests are ran on *every* startup of mongod, so they have to be very lightweight. But it is a 32 | good quick check for a bad build. 33 | */ 34 | class StartupTest { 35 | public: 36 | static void runTests(); 37 | 38 | static bool testsInProgress() { return running; } 39 | 40 | protected: 41 | StartupTest(); 42 | virtual ~StartupTest(); 43 | 44 | private: 45 | static std::vector *tests; 46 | static bool running; 47 | 48 | static void registerTest(StartupTest *t); 49 | 50 | // assert if fails 51 | virtual void run() = 0; 52 | 53 | }; 54 | 55 | 56 | } // namespace mongo 57 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/string_map.h: -------------------------------------------------------------------------------- 1 | // string_map.h 2 | 3 | /* Copyright 2012 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #pragma once 19 | 20 | #include "mongo/base/string_data.h" 21 | #include "mongo/util/unordered_fast_key_table.h" 22 | 23 | namespace mongo { 24 | 25 | struct StringMapDefaultHash { 26 | size_t operator()( const StringData& k ) const; 27 | }; 28 | 29 | struct StringMapDefaultEqual { 30 | bool operator()( const StringData& a, const StringData& b ) const { 31 | return a == b; 32 | } 33 | }; 34 | 35 | struct StringMapDefaultConvertor { 36 | StringData operator()( const std::string& s ) const { 37 | return StringData( s ); 38 | } 39 | }; 40 | 41 | struct StringMapDefaultConvertorOther { 42 | string operator()( const StringData& s ) const { 43 | return s.toString(); 44 | } 45 | }; 46 | 47 | template< typename V > 48 | class StringMap : public UnorderedFastKeyTable< StringData, // K_L 49 | std::string, // K_S 50 | V, // V 51 | StringMapDefaultHash, 52 | StringMapDefaultEqual, 53 | StringMapDefaultConvertor, 54 | StringMapDefaultConvertorOther > { 55 | }; 56 | } 57 | 58 | #include "mongo/util/string_map_internal.h" 59 | 60 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/string_map_internal.h: -------------------------------------------------------------------------------- 1 | // string_map_internal.h 2 | 3 | 4 | /* Copyright 2012 10gen Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace mongo { 20 | 21 | inline size_t StringMapDefaultHash::operator()( const StringData& key ) const { 22 | size_t mx = key.size(); 23 | size_t hash = 7; 24 | for ( size_t i = 0; i < mx; i++ ) { 25 | hash += ( 517 * static_cast(key[i]) ); 26 | hash *= 13; 27 | } 28 | if ( hash == 0 ) 29 | hash = -1; 30 | return hash; 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/string_writer.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 (c) 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "mongo/pch.h" 20 | 21 | namespace mongo { 22 | 23 | class StringWriter { 24 | public: 25 | virtual ~StringWriter() {}; 26 | virtual void writeString(stringstream &ss) const = 0; 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/systeminfo.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 (c) 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | namespace mongo { 22 | 23 | class SystemInfo { 24 | public: 25 | /* 26 | Get the amount of physical memory available on the host. 27 | 28 | This should only be used for "advisory" purposes, and not as a hard 29 | value, because this could be deceptive on virtual hosts, and because 30 | this will return zero on platforms that do not support it. 31 | 32 | @returns amount of physical memory, or zero 33 | */ 34 | static size_t getPhysicalRam(); 35 | 36 | private: 37 | // don't instantiate this class 38 | SystemInfo(); // no implementation 39 | }; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/timer-generic-inl.h: -------------------------------------------------------------------------------- 1 | // @file mongo/util/timer-generic-inl.h 2 | 3 | /* Copyright 2010 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * Inline function implementations for the "generic" implementation of the 20 | * Timer class. This implementation often has pretty poor resolution, but is available 21 | * on all supported platforms. 22 | * 23 | * This file should only be included through timer-inl.h, which selects the 24 | * particular implementation based on target platform. 25 | */ 26 | 27 | #pragma once 28 | 29 | #define MONGO_TIMER_IMPL_GENERIC 30 | 31 | #include "mongo/util/time_support.h" 32 | 33 | namespace mongo { 34 | 35 | unsigned long long Timer::now() const { return curTimeMicros64(); } 36 | 37 | } // namespace mongo 38 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/timer-inl.h: -------------------------------------------------------------------------------- 1 | // @file mongo/util/timer-inl.h 2 | 3 | /* Copyright 2010 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * Inline function implementations for the Timer class. This file simply selects 20 | * the platform-appropriate inline functions to include. 21 | * 22 | * This file should only be included through timer-inl.h, which selects the 23 | * particular implementation based on target platform. 24 | */ 25 | 26 | #pragma once 27 | 28 | #if defined(MONGO_HAVE_HEADER_UNISTD_H) 29 | #include 30 | #endif 31 | 32 | #if defined(_WIN32) 33 | 34 | // On Windows, prefer the Windows-specific implementation, which employs QueryPerformanceCounter. 35 | #include "mongo/util/timer-win32-inl.h" 36 | 37 | #elif defined(_POSIX_TIMERS) and _POSIX_TIMERS > 0 and defined(_POSIX_MONOTONIC_CLOCK) and _POSIX_MONOTONIC_CLOCK > 0 38 | 39 | // On systems that support the POSIX clock_gettime function, and the "monotonic" clock, 40 | // use those. 41 | #include "mongo/util/timer-posixclock-inl.h" 42 | 43 | #else 44 | 45 | // If all else fails, fall back to a generic implementation. Performance may suffer. 46 | #include "mongo/util/timer-generic-inl.h" 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/timer-posixclock-inl.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2010 10gen 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 | 16 | /** 17 | * Inline function implementations for timers on systems that support the 18 | * POSIX clock API and CLOCK_MONOTONIC clock. 19 | * 20 | * This file should only be included through timer-inl.h, which selects the 21 | * particular implementation based on target platform. 22 | */ 23 | 24 | #define MONGO_TIMER_IMPL_POSIX_MONOTONIC_CLOCK 25 | 26 | #include 27 | 28 | #include "mongo/util/assert_util.h" 29 | 30 | namespace mongo { 31 | 32 | unsigned long long Timer::now() const { 33 | timespec the_time; 34 | unsigned long long result; 35 | 36 | fassert(16160, !clock_gettime(CLOCK_MONOTONIC, &the_time)); 37 | 38 | // Safe for 292 years after the clock epoch, even if we switch to a signed time value. On 39 | // Linux, the monotonic clock's epoch is the UNIX epoch. 40 | result = static_cast(the_time.tv_sec); 41 | result *= nanosPerSecond; 42 | result += static_cast(the_time.tv_nsec); 43 | return result; 44 | } 45 | 46 | } // namespace mongo 47 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/timer-win32-inl.h: -------------------------------------------------------------------------------- 1 | // @file mongo/util/timer-win32-inl.h 2 | 3 | /* Copyright 2010 10gen Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * Inline function implementations for the Windows-specific implementation of the 20 | * Timer class. Windows selects the best available timer, in its estimation, for 21 | * measuring time at high resolution. This may be the HPET of the TSC on x86 systems, 22 | * but is promised to be synchronized across processors, barring BIOS errors. 23 | * 24 | * Do not include directly. Include "mongo/util/timer.h". 25 | */ 26 | 27 | #pragma once 28 | 29 | #define MONGO_TIMER_IMPL_WIN32 30 | 31 | #include "mongo/platform/windows_basic.h" 32 | #include "mongo/util/assert_util.h" 33 | 34 | namespace mongo { 35 | 36 | unsigned long long Timer::now() const { 37 | LARGE_INTEGER i; 38 | fassert(16161, QueryPerformanceCounter(&i)); 39 | return i.QuadPart; 40 | } 41 | 42 | } // namespace mongo 43 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/touch_pages.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2009 10gen 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 | 16 | #pragma once 17 | 18 | #include 19 | 20 | namespace mongo { 21 | class Extent; 22 | 23 | // Given a namespace, page in all pages associated with that namespace 24 | void touchNs( const std::string& ns ); 25 | 26 | // Touch a range of pages using an OS-specific method. 27 | // Takes a file descriptor, offset, and length, for Linux use. 28 | // Additionally takes an Extent pointer for use on other platforms. 29 | void touch_pages( HANDLE fd, int offset, size_t length, const Extent* ext ); 30 | } 31 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/version.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 10gen Inc. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License, version 3, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #ifndef UTIL_VERSION_HEADER 18 | #define UTIL_VERSION_HEADER 19 | 20 | #include 21 | 22 | #include "mongo/base/string_data.h" 23 | #include "mongo/bson/bsonobjbuilder.h" 24 | 25 | namespace mongo { 26 | struct BSONArray; 27 | 28 | // mongo version 29 | extern const char versionString[]; 30 | extern const BSONArray versionArray; 31 | std::string mongodVersion(); 32 | 33 | // Convert a version string into a numeric array 34 | BSONArray toVersionArray(const char* version); 35 | 36 | // Checks whether another version is the same major version as us 37 | bool isSameMajorVersion(const char* version); 38 | 39 | void appendBuildInfo(BSONObjBuilder& result); 40 | 41 | const char * gitVersion(); 42 | const char * compiledJSEngine(); 43 | const char * allocator(); 44 | const char * loaderFlags(); 45 | const char * compilerFlags(); 46 | 47 | void printGitVersion(); 48 | 49 | std::string sysInfo(); 50 | void printSysInfo(); 51 | void printAllocator(); 52 | 53 | void show_warnings(); 54 | 55 | } // namespace mongo 56 | 57 | #endif // UTIL_VERSION_HEADER 58 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/mongo/util/winutil.h: -------------------------------------------------------------------------------- 1 | // @file winutil.cpp : Windows related utility functions 2 | // 3 | // /** 4 | // * Copyright (C) 2008 10gen Inc. 5 | // * 6 | // * This program is free software: you can redistribute it and/or modify 7 | // * it under the terms of the GNU Affero General Public License, version 3, 8 | // * as published by the Free Software Foundation. 9 | // * 10 | // * This program is distributed in the hope that it will be useful, 11 | // * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // * GNU Affero General Public License for more details. 14 | // * 15 | // * You should have received a copy of the GNU Affero General Public License 16 | // * along with this program. If not, see . 17 | // */ 18 | // 19 | // #include "pch.h" 20 | 21 | #pragma once 22 | 23 | #if defined(_WIN32) 24 | #include 25 | #include "text.h" 26 | 27 | namespace mongo { 28 | 29 | inline string GetWinErrMsg(DWORD err) { 30 | LPTSTR errMsg; 31 | ::FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, (LPTSTR)&errMsg, 0, NULL ); 32 | std::string errMsgStr = toUtf8String( errMsg ); 33 | ::LocalFree( errMsg ); 34 | // FormatMessage() appends a newline to the end of error messages, we trim it because endl flushes the buffer. 35 | errMsgStr = errMsgStr.erase( errMsgStr.length() - 2 ); 36 | std::ostringstream output; 37 | output << errMsgStr << " (" << err << ")"; 38 | 39 | return output.str(); 40 | } 41 | } 42 | 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /pgbson/mongo-cxx-driver-v2.4/src/third_party/murmurhash3/MurmurHash3.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // MurmurHash3 was written by Austin Appleby, and is placed in the public 3 | // domain. The author hereby disclaims copyright to this source code. 4 | 5 | #ifndef _MURMURHASH3_H_ 6 | #define _MURMURHASH3_H_ 7 | 8 | #include 9 | 10 | //----------------------------------------------------------------------------- 11 | 12 | void MurmurHash3_x86_32 ( const void * key, int len, uint32_t seed, void * out ); 13 | 14 | void MurmurHash3_x86_128 ( const void * key, int len, uint32_t seed, void * out ); 15 | 16 | void MurmurHash3_x64_128 ( const void * key, int len, uint32_t seed, void * out ); 17 | 18 | //----------------------------------------------------------------------------- 19 | 20 | #endif // _MURMURHASH3_H_ 21 | -------------------------------------------------------------------------------- /pgbson/pgbson.control: -------------------------------------------------------------------------------- 1 | # pgbson extension 2 | comment = 'BSON data type and associated functions' 3 | default_version = '1.0' 4 | module_pathname = '$libdir/libpgbson' 5 | relocatable = true 6 | superuser = false 7 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_custom_target(test 2 | ${CMAKE_SOURCE_DIR}/test/test.sh 3 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test) 4 | -------------------------------------------------------------------------------- /test/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # if you need to control the host, port, database name, user, password and otghers, set approipriate environment variables 4 | 5 | PSQL=psql 6 | CREATEDB=createdb 7 | DROPDB=dropdb 8 | TESTDB=pgbson_test 9 | 10 | # clean-up after previous, possibly db-crashing test 11 | $DROPDB --if-exists $TESTDB 12 | 13 | # create -> run -> drop 14 | $CREATEDB $TESTDB 15 | $PSQL $TESTDB < test.sql 16 | $DROPDB $TESTDB 17 | --------------------------------------------------------------------------------