MCPcopy Create free account
hub / github.com/dhbloo/rapfi / createDBStorageFromCmdline

Function createDBStorageFromCmdline

Rapfi/command/database.cpp:92–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92std::unique_ptr<DBStorage> createDBStorageFromCmdline(std::string cmdline)
93{
94 // Split arguments from cmdline
95 std::vector<char *> arguments;
96 std::istringstream iss(cmdline);
97 std::string token;
98 arguments.push_back(0);
99 while (iss >> token) {
100 char *arg = new char[token.size() + 1];
101 std::copy(token.begin(), token.end(), arg);
102 arg[token.size()] = '\0';
103 arguments.push_back(arg);
104 }
105
106 auto options = makeDBCreationOptions("database create");
107 std::unique_ptr<DBStorage> dbStorage = nullptr;
108 try {
109 auto args = options.parse(arguments.size(), &arguments[0]);
110 dbStorage = createDBStorage(args);
111 }
112 catch (const std::exception &e) {
113 ERRORL("Failed to create database: " << e.what());
114 }
115
116 for (size_t i = 1; i < arguments.size(); i++)
117 delete[] arguments[i];
118
119 return dbStorage;
120}
121
122DBKey parseDBKey(std::string keyStr)
123{

Callers 1

databaseMethod · 0.85

Calls 9

copyFunction · 0.85
makeDBCreationOptionsFunction · 0.85
createDBStorageFunction · 0.85
whatMethod · 0.80
push_backMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected