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 <rapidjson/stringbuffer.h>
|
||||
#include <rapidjson/writer.h>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
template<class T>
|
||||
|
22
src/main.cpp
22
src/main.cpp
@ -57,11 +57,16 @@ int main(int argc, char *argv[]) {
|
||||
accountOptHandler.help();
|
||||
}
|
||||
if (accountOptHandler.getSetOpts()->create) {
|
||||
accounts.insert(std::pair(
|
||||
accountOptHandler.getSetOpts()->createAccount,
|
||||
(storageD + "accounts/" + accountOptHandler.getSetOpts()->createAccount +
|
||||
".json", accountOptHandler.getSetOpts()->createAccount)
|
||||
));
|
||||
auto a = accounts.find(accountOptHandler.getSetOpts()->delAccount);
|
||||
if (a == accounts.end()) {
|
||||
accounts.emplace(std::piecewise_construct,
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user