summaryrefslogtreecommitdiff
path: root/src/mongo/rpc/document_range.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/rpc/document_range.h')
-rw-r--r--src/mongo/rpc/document_range.h111
1 files changed, 55 insertions, 56 deletions
diff --git a/src/mongo/rpc/document_range.h b/src/mongo/rpc/document_range.h
index aa8d3131b13..95d23d82b4c 100644
--- a/src/mongo/rpc/document_range.h
+++ b/src/mongo/rpc/document_range.h
@@ -38,62 +38,61 @@
namespace mongo {
namespace rpc {
- /**
- * A read-only view over a sequence of BSON documents.
- *
- * TODO:
- * - Handle document validation
- * - Currently this only supports a contiguous buffer of BSON documents,
- * in the future it should support non-contiguous buffers as well.
- */
- class DocumentRange {
- public:
- class const_iterator;
-
- DocumentRange() = default;
-
- DocumentRange(const char* begin, const char* end);
-
- const_iterator begin() const;
- const_iterator end() const;
-
- // Get a ConstDataRange over the underlying raw buffer.
- ConstDataRange data() const;
-
- // Deep equality of all documents in both ranges.
- friend bool operator==(const DocumentRange& lhs, const DocumentRange& rhs);
- friend bool operator!=(const DocumentRange& lhs, const DocumentRange& rhs);
-
- private:
- ConstDataRange _range{nullptr, nullptr};
- };
-
- class DocumentRange::const_iterator
- : public std::iterator<std::forward_iterator_tag,
- BSONObj,
- std::ptrdiff_t,
- const BSONObj*,
- const BSONObj&> {
- public:
- const_iterator() = default;
-
- reference operator*() const;
- pointer operator->() const;
-
- const_iterator& operator++();
- const_iterator operator++(int);
-
- friend bool operator==(const const_iterator&, const const_iterator&);
- friend bool operator!=(const const_iterator&, const const_iterator&);
-
- private:
- // The only way to get a non-end iterator is from DocumentRange begin().
- friend class DocumentRange;
- explicit const_iterator(ConstDataRangeCursor cursor);
-
- ConstDataRangeCursor _cursor{nullptr, nullptr};
- BSONObj _obj;
- };
+/**
+ * A read-only view over a sequence of BSON documents.
+ *
+ * TODO:
+ * - Handle document validation
+ * - Currently this only supports a contiguous buffer of BSON documents,
+ * in the future it should support non-contiguous buffers as well.
+ */
+class DocumentRange {
+public:
+ class const_iterator;
+
+ DocumentRange() = default;
+
+ DocumentRange(const char* begin, const char* end);
+
+ const_iterator begin() const;
+ const_iterator end() const;
+
+ // Get a ConstDataRange over the underlying raw buffer.
+ ConstDataRange data() const;
+
+ // Deep equality of all documents in both ranges.
+ friend bool operator==(const DocumentRange& lhs, const DocumentRange& rhs);
+ friend bool operator!=(const DocumentRange& lhs, const DocumentRange& rhs);
+
+private:
+ ConstDataRange _range{nullptr, nullptr};
+};
+
+class DocumentRange::const_iterator : public std::iterator<std::forward_iterator_tag,
+ BSONObj,
+ std::ptrdiff_t,
+ const BSONObj*,
+ const BSONObj&> {
+public:
+ const_iterator() = default;
+
+ reference operator*() const;
+ pointer operator->() const;
+
+ const_iterator& operator++();
+ const_iterator operator++(int);
+
+ friend bool operator==(const const_iterator&, const const_iterator&);
+ friend bool operator!=(const const_iterator&, const const_iterator&);
+
+private:
+ // The only way to get a non-end iterator is from DocumentRange begin().
+ friend class DocumentRange;
+ explicit const_iterator(ConstDataRangeCursor cursor);
+
+ ConstDataRangeCursor _cursor{nullptr, nullptr};
+ BSONObj _obj;
+};
} // namespace rpc
} // namespace mongo