From 4637fc0503a711d44d3c0350de5364d588053413 Mon Sep 17 00:00:00 2001 From: Tyler Brock Date: Thu, 29 Jan 2015 14:04:46 -0500 Subject: [PATCH] Add miscellaneous repo files --- .clang-format | 10 +++++ .gitignore | 3 ++ CONTRIBUTING.md | 104 ++++++++++++++++++++++++++++++++++++++++++++++++ TODO.md | 16 +++++++- 4 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 .clang-format create mode 100644 CONTRIBUTING.md diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000000..541db35204 --- /dev/null +++ b/.clang-format @@ -0,0 +1,10 @@ +BasedOnStyle: Google +ColumnLimit: 100 +Cpp11BracedListStyle: true +IndentWidth: 4 +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +SpaceBeforeAssignmentOperators: true +Standard: Cpp11 +UseTab: Never +AllowShortFunctionsOnASingleLine: false diff --git a/.gitignore b/.gitignore index 300bca1968..c19dc3cb80 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,10 @@ *# .#* +tags + #osx .DS_Store ._.DS_Store *.fuse_* +*.swp diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..4f5947cc78 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,104 @@ +### Lifecycle Methods +``` + - default-or-argument-bearing 'user' constructors + + - declaration-or-deletion-of-copy-contructor + - declaration-or-deletetion-of-move-constructor + + - declaration-or-deletion-of-copy-assignment-operator + - declaration-or-deletion-of-move-assignment-operator + + - declaration-of-dtor +``` + +### Headers + + - License + - Include Guard (`#pragma once`) + - Header Prelude + - System Headers `<>` (alphabetical order) + - Driver Headers `""` (alphabetical order) + - Open Namespace mongo + - Open Namespace driver + - Code + - Close Namespace driver + - Close Namespace mongo + - Header Postlude + +Example: +```cpp +// Copyright 2014 MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include "driver/config/prelude.hpp" + +#include + +#include "driver/base/blah.hpp" + +namespace mongo { +namespace driver { + +// Declarations + +// Inline Implementations + +} // namespace driver +} // namespace mongo + +#include "driver/config/postlude.hpp" +``` + +### Class Declarations + +Guidelines: + + - Blank line at beginning and end of class declaration + - Public section up top / private at bottom + - Lifecycle methods first (see rules above) + - Private Member Ordering + - Friendships + - Private Constructors + - Private Methods + - Private Variables + +Example: +```cpp +class foo { + + public: + foo(); + + foo(foo&& other) noexcept; + foo& operator=(foo&& other) noexcept; + + ~foo(); + + private: + friend baz; + + class impl; + std::unique_ptr _impl; + +}; +``` + +### Inlines + - Define outside of class declaration + - Specify inline keyword in declaration and definition (for clarity) + +### Relational Operators + - Prefer to use free functions diff --git a/TODO.md b/TODO.md index 173592cba6..327f39656a 100644 --- a/TODO.md +++ b/TODO.md @@ -2,4 +2,18 @@ - how do we integrate mongoc's error handling with c++'s error handling facilities - how do we integrate mongoc's memory management with c++'s memory management facilities - header include discipline (eg. do we put package prefixes?) - - are we going to put type tags on closing braces? (we are inconsistent now) + - remove type tags on closing braces? + +## Build + - find_libmongocxx cmake helper thing + - figure out how to generate pc files (package config) + - understand libc++ inline macros and determine if we need to use them + - inline visibility macros -- do we want/need? how do we define them? + - template visibility macros? -- do we want/need? how do we define them? + - think about the relationship between include directory and package config + +## Organization + - do we need a namespace for base or should we move its contents up a level + +## Docs + - add a cmake target for this