summaryrefslogtreecommitdiff
path: root/src/mongo/db/ops/modifier_pop.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/ops/modifier_pop.h')
-rw-r--r--src/mongo/db/ops/modifier_pop.h67
1 files changed, 31 insertions, 36 deletions
diff --git a/src/mongo/db/ops/modifier_pop.h b/src/mongo/db/ops/modifier_pop.h
index 41501275619..b0de117a946 100644
--- a/src/mongo/db/ops/modifier_pop.h
+++ b/src/mongo/db/ops/modifier_pop.h
@@ -38,51 +38,46 @@
namespace mongo {
- class LogBuilder;
+class LogBuilder;
- class ModifierPop : public ModifierInterface {
- MONGO_DISALLOW_COPYING(ModifierPop);
+class ModifierPop : public ModifierInterface {
+ MONGO_DISALLOW_COPYING(ModifierPop);
- public:
+public:
+ ModifierPop();
+ virtual ~ModifierPop();
- ModifierPop();
- virtual ~ModifierPop();
+ /**
+ * The format of this modifier ($pop) is {<fieldname>: <value>}.
+ * If the value is number and greater than -1 then an element is removed from the bottom,
+ * otherwise the top. Currently the value can be any anything but we document
+ * the use of the numbers "1, -1" only.
+ *
+ * Ex. $pop: {'a':1} will remove the last item from this array: [1,2,3] -> [1,2]
+ */
+ virtual Status init(const BSONElement& modExpr, const Options& opts, bool* positional = NULL);
- /**
- * The format of this modifier ($pop) is {<fieldname>: <value>}.
- * If the value is number and greater than -1 then an element is removed from the bottom,
- * otherwise the top. Currently the value can be any anything but we document
- * the use of the numbers "1, -1" only.
- *
- * Ex. $pop: {'a':1} will remove the last item from this array: [1,2,3] -> [1,2]
- */
- virtual Status init(const BSONElement& modExpr, const Options& opts,
- bool* positional = NULL);
+ virtual Status prepare(mutablebson::Element root, StringData matchedField, ExecInfo* execInfo);
- virtual Status prepare(mutablebson::Element root,
- StringData matchedField,
- ExecInfo* execInfo);
+ virtual Status apply() const;
- virtual Status apply() const;
+ virtual Status log(LogBuilder* logBuilder) const;
- virtual Status log(LogBuilder* logBuilder) const;
+private:
+ // Access to each component of fieldName that's the target of this mod.
+ FieldRef _fieldRef;
- private:
+ // 0 or index for $-positional in _fieldRef.
+ size_t _positionalPathIndex;
- // Access to each component of fieldName that's the target of this mod.
- FieldRef _fieldRef;
+ // element position to remove from
+ bool _fromTop;
- // 0 or index for $-positional in _fieldRef.
- size_t _positionalPathIndex;
+ // The instance of the field in the provided doc.
+ // This data is valid after prepare, for use by log and apply
+ struct PreparedState;
+ std::unique_ptr<PreparedState> _preparedState;
+};
- // element position to remove from
- bool _fromTop;
-
- // The instance of the field in the provided doc.
- // This data is valid after prepare, for use by log and apply
- struct PreparedState;
- std::unique_ptr<PreparedState> _preparedState;
- };
-
-} // namespace mongo
+} // namespace mongo