Optimized the creation of accounts and removed writing null to newly
created
This commit is contained in:
parent
1d9c2010f9
commit
e8d12d2e56
@ -10,6 +10,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <rapidjson/stringbuffer.h>
|
#include <rapidjson/stringbuffer.h>
|
||||||
#include <rapidjson/writer.h>
|
#include <rapidjson/writer.h>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
22
src/main.cpp
22
src/main.cpp
@ -57,11 +57,16 @@ int main(int argc, char *argv[]) {
|
|||||||
accountOptHandler.help();
|
accountOptHandler.help();
|
||||||
}
|
}
|
||||||
if (accountOptHandler.getSetOpts()->create) {
|
if (accountOptHandler.getSetOpts()->create) {
|
||||||
accounts.insert(std::pair(
|
auto a = accounts.find(accountOptHandler.getSetOpts()->delAccount);
|
||||||
accountOptHandler.getSetOpts()->createAccount,
|
if (a == accounts.end()) {
|
||||||
(storageD + "accounts/" + accountOptHandler.getSetOpts()->createAccount +
|
accounts.emplace(std::piecewise_construct,
|
||||||
".json", accountOptHandler.getSetOpts()->createAccount)
|
std::make_tuple(accountOptHandler.getSetOpts()->createAccount), std::make_tuple(
|
||||||
));
|
storageD + "accounts/" + accountOptHandler.getSetOpts()->createAccount + ".json",
|
||||||
|
accountOptHandler.getSetOpts()->createAccount));
|
||||||
|
} else {
|
||||||
|
std::cout << "Account " << accountOptHandler.getSetOpts()->delAccount << " already exists."
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (accountOptHandler.getSetOpts()->value) {
|
if (accountOptHandler.getSetOpts()->value) {
|
||||||
auto a = accounts.find(accountOptHandler.getSetOpts()->valueAccount);
|
auto a = accounts.find(accountOptHandler.getSetOpts()->valueAccount);
|
||||||
@ -69,6 +74,13 @@ int main(int argc, char *argv[]) {
|
|||||||
std::cout << "Account value: " << a->second.getAccount()->getValue() << std::endl;
|
std::cout << "Account value: " << a->second.getAccount()->getValue() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (accountOptHandler.getSetOpts()->del) {
|
||||||
|
auto a = accounts.find(accountOptHandler.getSetOpts()->delAccount);
|
||||||
|
if (a != accounts.end()) {
|
||||||
|
accounts.erase(a);
|
||||||
|
std::cout << "Deleted account: " << accountOptHandler.getSetOpts()->delAccount << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user