diff options
author | Tess Avitabile <tess.avitabile@mongodb.com> | 2017-04-14 16:06:18 -0400 |
---|---|---|
committer | Tess Avitabile <tess.avitabile@mongodb.com> | 2017-04-20 13:22:12 -0400 |
commit | 0293c14cbdc5646d9f09f4fe5b2a27e6d540dce0 (patch) | |
tree | 427f823c34f54fcd8d7fa28969ce7f40c740a354 /src/mongo/db/update/field_checker.h | |
parent | c08590a6ac9dc54c9d910822d47ea17140b56f89 (diff) | |
download | mongo-0293c14cbdc5646d9f09f4fe5b2a27e6d540dce0.tar.gz |
SERVER-28621 Parse BSON update expression into an UpdateNode tree
Diffstat (limited to 'src/mongo/db/update/field_checker.h')
-rw-r--r-- | src/mongo/db/update/field_checker.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/mongo/db/update/field_checker.h b/src/mongo/db/update/field_checker.h new file mode 100644 index 00000000000..772034d4773 --- /dev/null +++ b/src/mongo/db/update/field_checker.h @@ -0,0 +1,59 @@ +/** + * Copyright (C) 2013 10gen Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the GNU Affero General Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ + +#pragma once + +#include "mongo/base/status.h" + +namespace mongo { + +class FieldRef; + +namespace fieldchecker { + +/** + * Returns OK if all the below conditions on 'field' are valid: + * + Non-empty + * + Does not start or end with a '.' + * Otherwise returns a code indicating cause of failure. + */ +Status isUpdatable(const FieldRef& field); + +/** + * Returns true, the position 'pos' of the first $-sign if present in 'fieldRef', and + * how many other $-signs were found in 'count'. Otherwise return false. + * + * Note: + * isPositional assumes that the field is updatable. Call isUpdatable() above to + * verify. + */ +bool isPositional(const FieldRef& fieldRef, size_t* pos, size_t* count = NULL); + +} // namespace fieldchecker + +} // namespace mongo |