Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
3 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
 
#include <iostream>
#include <unordered_map>
#include <gtest/gtest.h>
 
#include "runtimeParameters.h"
 
namespace RuntimeParameters {
std::unordered_map<std::string, std::string> Parameters;
}
 
namespace {
void usage(char** argv, int failedArgument) {
  std::cerr << "Unrecognized argument: " << argv[failedArgument] << "\n"
            << "Usage:\n\t" << argv[0] << " [/p:parameterName=parameterValue ...]\n";
}
 
bool parseArgument(const std::string& argument) {
  if (argument.rfind("/p:", 0) == 0) {
    // Parse argument in the form of /p:parameterName=parameterValue
    auto separatorIndex = argument.find('=');
    if (separatorIndex == std::string::npos || separatorIndex == 3) {
      return false;
    }
    auto parameterName = argument.substr(3, separatorIndex - 3);
    auto parameterValue = argument.substr(separatorIndex + 1);
    RuntimeParameters::Parameters[parameterName] = parameterValue;
    return true;
  }
  return false;
}
}  // namespace
 
int main(int argc, char** argv) {
  ::testing::InitGoogleTest(&argc, argv);
  for (int i = 1; i < argc; i++) {
    if (!parseArgument(argv[i])) {
      usage(argv, i);
      return -1;
    }
  }
  return RUN_ALL_TESTS();
}