summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hearthstoneAPIHandler.cpp1
-rw-r--r--src/main.cpp2
-rw-r--r--src/postgresHandler.cpp11
3 files changed, 9 insertions, 5 deletions
diff --git a/src/hearthstoneAPIHandler.cpp b/src/hearthstoneAPIHandler.cpp
index 5dd28d4..5961e1f 100644
--- a/src/hearthstoneAPIHandler.cpp
+++ b/src/hearthstoneAPIHandler.cpp
@@ -139,6 +139,5 @@ HearthstoneAPIHandler::make_api_request(const std::string &t_url,
std::string
HearthstoneAPIHandler::get_cards(const std::string &t_card_parameters) {
- // TODO: Use a parser to generate a std::map or something like that
return make_api_request(get_set_of_cards_url(t_card_parameters), m_header);
}
diff --git a/src/main.cpp b/src/main.cpp
index 6786a5b..54079a7 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -15,6 +15,6 @@ int main() {
// TODO: for test purposes
// use get_cards output instead?
- add_cards_to_database("{\"name\":3}", tx);
+ add_cards_to_database(hs_handler.get_cards("678?locale=fr_FR"), tx);
return 0;
}
diff --git a/src/postgresHandler.cpp b/src/postgresHandler.cpp
index 212202e..a92faaf 100644
--- a/src/postgresHandler.cpp
+++ b/src/postgresHandler.cpp
@@ -17,9 +17,14 @@ void display_query_result(const pqxx::result &t_r) {
}
}
-void add_cards_to_database(std::string_view t_cards, pqxx::work &t_tx) {
+void add_cards_to_database(const std::string &t_cards, pqxx::work &t_tx) {
// TODO: to complete
std::cout << "adding cards..." << std::endl;
- std::regex key_regex; // TODO: to define
- std::cout << t_cards.substr(1, 6) << std::endl;
+ std::regex key_regex("(\".*\"),"); // TODO: write correct regex
+ auto words_begin =
+ std::sregex_iterator(t_cards.begin(), t_cards.end(), key_regex);
+ auto words_end = std::sregex_iterator();
+ for (auto it = words_begin; it != words_end; ++it) {
+ std::cout << (*it).str() << std::endl;
+ }
}