2
* Copyright (C) 2012 10gen Inc.
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.
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.
13
* You should have received a copy of the GNU Affero General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
22
#include "mongo/base/string_data.h"
23
#include "mongo/db/jsobj.h"
28
* The MongoVersionRange represents a min/max of MongoDB versions, useful for
29
* excluding/including particular versions.
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
36
struct MongoVersionRange {
38
static bool parseBSONArray(const BSONArray& arr,
39
std::vector<MongoVersionRange>* excludes,
42
static BSONArray toBSONArray(const std::vector<MongoVersionRange>& ranges);
44
bool parseBSONElement(const BSONElement& el, std::string* errMsg);
46
void toBSONElement(BSONArrayBuilder* barr) const;
48
bool isInRange(const StringData& version) const;
50
std::string minVersion;
51
std::string maxVersion;
54
bool isInMongoVersionRanges(const StringData& version,
55
const std::vector<MongoVersionRange>& ranges);