Minor bugfix since getline adds an extra char to the string
move hardcoded databaseURI into the config
This commit is contained in:
@@ -217,10 +217,13 @@ and end with
|
|||||||
|
|
||||||
comment +
|
comment +
|
||||||
|
|
||||||
|
Close variable with ;
|
||||||
|
|
||||||
mandatory:
|
mandatory:
|
||||||
emailAddress=
|
emailAddress
|
||||||
emailPassword=
|
emailPassword
|
||||||
emailServerAddress=
|
emailServerAddress
|
||||||
|
databaseConnectionString={postgresql://{user}:{password}@{host}:{port}/{database}}
|
||||||
|
|
||||||
optional:{default}
|
optional:{default}
|
||||||
emailServerPort={587}
|
emailServerPort={587}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
#configstart#
|
#configstart#
|
||||||
|
|
||||||
# Mandatory:
|
# Mandatory:
|
||||||
|
# databaseConnectionString={postgresql://{user}:{password}@{host}:{port}/{database}}
|
||||||
# emailAddress=
|
# emailAddress=
|
||||||
# emailPassword=
|
# emailPassword=
|
||||||
# emailServerAddress=
|
# emailServerAddress=
|
||||||
@@ -12,16 +13,16 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
databaseConnectionString=postgresql://cavecommadmin:cavecomm@localhost:5432/cavecomm;
|
||||||
|
|
||||||
|
emailAddress=testuser0ed6e@waifu.club;
|
||||||
|
|
||||||
emailAddress=testuser0ed6e@waifu.club
|
emailPassword=Ve4m6GSjJ;
|
||||||
|
|
||||||
emailPassword=Ve4m6GSjJ
|
emailServerAddress=mail.cock.li;
|
||||||
|
|
||||||
emailServerAddress=mail.cock.li
|
emailServerPort=587;
|
||||||
|
|
||||||
emailServerPort=587
|
emailAddressDisplay=Cavecomm Automated Management System;
|
||||||
|
|
||||||
emailAddressDisplay=Cavecomm Automated Management System
|
|
||||||
|
|
||||||
#configend#
|
#configend#
|
||||||
|
@@ -30,7 +30,9 @@ int main(int argc, char *argv[]) {
|
|||||||
// return crow::json::wvalue x({{"message", rows[0][0].as<int>();}});
|
// return crow::json::wvalue x({{"message", rows[0][0].as<int>();}});
|
||||||
// });
|
// });
|
||||||
|
|
||||||
string databaseURI = "postgresql://cavecommadmin:cavecomm@localhost:5432/cavecomm";
|
|
||||||
|
|
||||||
|
string databaseURI = configuration.databaseConnectionString;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -36,11 +36,19 @@ namespace Utilities {
|
|||||||
return splitVector;
|
return splitVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string trimFromDelimiter(std::string stringToTrim, char delimiter) {
|
||||||
|
int position = stringToTrim.find(delimiter);
|
||||||
|
if (position != std::string::npos)
|
||||||
|
return stringToTrim.substr(0, position);
|
||||||
|
return stringToTrim;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Struct representing the configuration file
|
* Struct representing the configuration file
|
||||||
*/
|
*/
|
||||||
struct config {
|
struct config {
|
||||||
std::string configPath = "cavecomm.conf";
|
std::string configPath = "cavecomm.conf";
|
||||||
|
std::string databaseConnectionString;
|
||||||
std::string emailAddress;
|
std::string emailAddress;
|
||||||
std::string emailPassword;
|
std::string emailPassword;
|
||||||
std::string emailServerAddress;
|
std::string emailServerAddress;
|
||||||
@@ -54,7 +62,8 @@ namespace Utilities {
|
|||||||
int checkMandatoryVariables() {
|
int checkMandatoryVariables() {
|
||||||
if (emailAddress.compare("") == 0
|
if (emailAddress.compare("") == 0
|
||||||
|| emailPassword.compare("") == 0
|
|| emailPassword.compare("") == 0
|
||||||
|| emailServerAddress.compare("") == 0)
|
|| emailServerAddress.compare("") == 0
|
||||||
|
|| databaseConnectionString.compare("") == 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -105,23 +114,27 @@ namespace Utilities {
|
|||||||
if (lineVector.size() == 2) {
|
if (lineVector.size() == 2) {
|
||||||
std::cout << lineVector.at(0) << " - " << lineVector.at(1) << std::endl;
|
std::cout << lineVector.at(0) << " - " << lineVector.at(1) << std::endl;
|
||||||
if (lineVector.at(0).compare("emailAddress") == 0) {
|
if (lineVector.at(0).compare("emailAddress") == 0) {
|
||||||
emailAddress = lineVector.at(1);
|
emailAddress = trimFromDelimiter(lineVector.at(1), ';');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (lineVector.at(0).compare("emailPassword") == 0) {
|
if (lineVector.at(0).compare("emailPassword") == 0) {
|
||||||
emailPassword = lineVector.at(1);
|
emailPassword = trimFromDelimiter(lineVector.at(1), ';');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (lineVector.at(0).compare("emailServerAddress") == 0) {
|
if (lineVector.at(0).compare("emailServerAddress") == 0) {
|
||||||
emailServerAddress = lineVector.at(1);
|
emailServerAddress = trimFromDelimiter(lineVector.at(1), ';');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (lineVector.at(0).compare("emailServerPort") == 0) {
|
if (lineVector.at(0).compare("emailServerPort") == 0) {
|
||||||
emailServerPort = std::stoi(lineVector.at(1));
|
emailServerPort = std::stoi(trimFromDelimiter(lineVector.at(1), ';'));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (lineVector.at(0).compare("emailAddressDisplay") == 0) {
|
if (lineVector.at(0).compare("emailAddressDisplay") == 0) {
|
||||||
emailAddressDisplay = lineVector.at(1);
|
emailAddressDisplay = trimFromDelimiter(lineVector.at(1), ';');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (lineVector.at(0).compare("databaseConnectionString") == 0) {
|
||||||
|
databaseConnectionString = trimFromDelimiter(lineVector.at(1), ';');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user