diff options
author | Billy Donahue <billy.donahue@mongodb.com> | 2019-06-14 10:01:54 -0400 |
---|---|---|
committer | Billy Donahue <billy.donahue@mongodb.com> | 2019-06-14 13:51:30 -0400 |
commit | 1fa1cb9be9e0dc1ae6b953fb0ce176419e3a4fab (patch) | |
tree | 7519efa40c7ed429defbf5105a5565640bf9dbf2 /src/mongo/base | |
parent | 0b48f950281196e2aa7744f3ac96671cbe69a614 (diff) | |
download | mongo-1fa1cb9be9e0dc1ae6b953fb0ce176419e3a4fab.tar.gz |
SERVER-41733 remove make_string_vector.{cpp,h}
This reverts commit ff4bb67b906c02ace0fba23082b42a59e6cff720.
Diffstat (limited to 'src/mongo/base')
-rw-r--r-- | src/mongo/base/init.h | 11 | ||||
-rw-r--r-- | src/mongo/base/initializer_dependency_graph_test.cpp | 15 | ||||
-rw-r--r-- | src/mongo/base/initializer_test.cpp | 15 | ||||
-rw-r--r-- | src/mongo/base/make_string_vector.cpp | 49 | ||||
-rw-r--r-- | src/mongo/base/make_string_vector.h | 61 |
5 files changed, 22 insertions, 129 deletions
diff --git a/src/mongo/base/init.h b/src/mongo/base/init.h index fcda0bf48d0..84d9ae97ddb 100644 --- a/src/mongo/base/init.h +++ b/src/mongo/base/init.h @@ -48,18 +48,17 @@ #include "mongo/base/initializer.h" #include "mongo/base/initializer_context.h" #include "mongo/base/initializer_function.h" -#include "mongo/base/make_string_vector.h" #include "mongo/base/status.h" /** * Convenience parameter representing an empty set of prerequisites for an initializer function. */ -#define MONGO_NO_PREREQUISITES (NULL) +#define MONGO_NO_PREREQUISITES () /** * Convenience parameter representing an empty set of dependents of an initializer function. */ -#define MONGO_NO_DEPENDENTS (NULL) +#define MONGO_NO_DEPENDENTS () /** * Convenience parameter representing the default set of dependents for initializer functions. @@ -95,6 +94,8 @@ #define MONGO_INITIALIZER_WITH_PREREQUISITES(NAME, PREREQUISITES) \ MONGO_INITIALIZER_GENERAL(NAME, PREREQUISITES, MONGO_NO_DEPENDENTS) +#define MONGO_INITIALIZER_STRIP_PARENS_(...) __VA_ARGS__ + /** * Macro to define an initializer that depends on PREREQUISITES and has DEPENDENTS as explicit * dependents. @@ -125,8 +126,8 @@ std::string(#NAME), \ mongo::InitializerFunction(MONGO_INITIALIZER_FUNCTION_NAME_(NAME)), \ mongo::DeinitializerFunction(nullptr), \ - MONGO_MAKE_STRING_VECTOR PREREQUISITES, \ - MONGO_MAKE_STRING_VECTOR DEPENDENTS); \ + std::vector<std::string>{MONGO_INITIALIZER_STRIP_PARENS_ PREREQUISITES}, \ + std::vector<std::string>{MONGO_INITIALIZER_STRIP_PARENS_ DEPENDENTS}); \ } \ ::mongo::Status MONGO_INITIALIZER_FUNCTION_NAME_(NAME) diff --git a/src/mongo/base/initializer_dependency_graph_test.cpp b/src/mongo/base/initializer_dependency_graph_test.cpp index 6ac78892392..bfd4f114ab6 100644 --- a/src/mongo/base/initializer_dependency_graph_test.cpp +++ b/src/mongo/base/initializer_dependency_graph_test.cpp @@ -37,15 +37,16 @@ #include "mongo/base/init.h" #include "mongo/base/initializer_dependency_graph.h" -#include "mongo/base/make_string_vector.h" #include "mongo/unittest/unittest.h" -#define ADD_INITIALIZER(GRAPH, NAME, FN, PREREQS, DEPS) \ - (GRAPH).addInitializer((NAME), \ - (FN), \ - DeinitializerFunction(), \ - MONGO_MAKE_STRING_VECTOR PREREQS, \ - MONGO_MAKE_STRING_VECTOR DEPS) +#define STRIP_PARENS_(...) __VA_ARGS__ + +#define ADD_INITIALIZER(GRAPH, NAME, FN, PREREQS, DEPS) \ + (GRAPH).addInitializer((NAME), \ + (FN), \ + DeinitializerFunction(), \ + std::vector<std::string>{STRIP_PARENS_ PREREQS}, \ + std::vector<std::string>{STRIP_PARENS_ DEPS}) #define ASSERT_ADD_INITIALIZER(GRAPH, NAME, FN, PREREQS, DEPS) \ ASSERT_EQUALS(Status::OK(), ADD_INITIALIZER(GRAPH, NAME, FN, PREREQS, DEPS)) diff --git a/src/mongo/base/initializer_test.cpp b/src/mongo/base/initializer_test.cpp index d46b8991ed8..5656875d21e 100644 --- a/src/mongo/base/initializer_test.cpp +++ b/src/mongo/base/initializer_test.cpp @@ -34,7 +34,6 @@ #include "mongo/base/init.h" #include "mongo/base/initializer.h" #include "mongo/base/initializer_dependency_graph.h" -#include "mongo/base/make_string_vector.h" #include "mongo/unittest/unittest.h" /* @@ -51,12 +50,14 @@ * */ -#define ADD_INITIALIZER(GRAPH, NAME, FN, PREREQS, DEPS) \ - (GRAPH).addInitializer((NAME), \ - (FN), \ - DeinitializerFunction(), \ - MONGO_MAKE_STRING_VECTOR PREREQS, \ - MONGO_MAKE_STRING_VECTOR DEPS) +#define STRIP_PARENS_(...) __VA_ARGS__ + +#define ADD_INITIALIZER(GRAPH, NAME, FN, PREREQS, DEPS) \ + (GRAPH).addInitializer((NAME), \ + (FN), \ + DeinitializerFunction(), \ + std::vector<std::string>{STRIP_PARENS_ PREREQS}, \ + std::vector<std::string>{STRIP_PARENS_ DEPS}) #define ASSERT_ADD_INITIALIZER(GRAPH, NAME, FN, PREREQS, DEPS) \ ASSERT_EQUALS(Status::OK(), ADD_INITIALIZER(GRAPH, NAME, FN, PREREQS, DEPS)) diff --git a/src/mongo/base/make_string_vector.cpp b/src/mongo/base/make_string_vector.cpp deleted file mode 100644 index 2d4ef0df2d0..00000000000 --- a/src/mongo/base/make_string_vector.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (C) 2018-present MongoDB, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * 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 - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * <http://www.mongodb.com/licensing/server-side-public-license>. - * - * 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 Server Side 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. - */ - -#include "mongo/base/make_string_vector.h" - -#include <cstdlib> -#include <iostream> -#include <stdarg.h> - -namespace mongo { - -std::vector<std::string> _makeStringVector(int ignored, ...) { - va_list ap; - va_start(ap, ignored); - std::vector<std::string> result; - const char* arg = NULL; - while ((arg = va_arg(ap, const char*))) - result.push_back(arg); - va_end(ap); - return result; -} - -} // namespace mongo diff --git a/src/mongo/base/make_string_vector.h b/src/mongo/base/make_string_vector.h deleted file mode 100644 index ce29489ef73..00000000000 --- a/src/mongo/base/make_string_vector.h +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (C) 2018-present MongoDB, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * 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 - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * <http://www.mongodb.com/licensing/server-side-public-license>. - * - * 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 Server Side 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 <string> -#include <vector> - -/** - * Utility macro to construct a std::vector<std::string> from a sequence of C-style - * strings. - * - * Usage: MONGO_MAKE_STRING_VECTOR("a", "b", "c") returns a vector containing - * std::strings "a", "b", "c", in that order. - */ -#define MONGO_MAKE_STRING_VECTOR(...) ::mongo::_makeStringVector(0, __VA_ARGS__, NULL) - -namespace mongo { - -/** - * Create a vector of strings from varargs of C-style strings. - * - * WARNING: Only intended for use by MONGO_MAKE_STRING_VECTOR macro, defined above. Aborts - * ungracefully if you misuse it, so stick to the macro. - * - * The first parameter is ignored in all circumstances. The subsequent parameters must be - * const char* C-style strings, or NULL. Of these parameters, at least one must be - * NULL. Parameters at and beyond the NULL are not inserted. Typically, the NULL will be - * the last parameter. The MONGO_MAKE_STRING_VECTOR macro enforces this. - * - * Returns a vector of std::strings. - */ -std::vector<std::string> _makeStringVector(int ignored, ...); - -} // namespace mongo |