summaryrefslogtreecommitdiff
path: root/include/postgresHandler.hpp
blob: 2c3f6f4bdde5ca60e388e759a09aea8dcaf4eed6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once
#include "hearthstoneAPIHandler.hpp"
#include <pqxx/pqxx>
#include <regex>

/**
 * Execute a SQL query from a libpqxx transaction
 *
 * @param aTransaction The SQL transaction object used to execute the query
 * @param aQuery The SQL query
 * @return The result of the executed SQL query
 */
const pqxx::result executeQuery(pqxx::work &aTransaction,
                                std::string_view aQuery);

/**
 * Get the type id of the value element in the "key": value regex match
 * For instance, if the regex match is "isZilliaxCosmeticModule":false
 * Then the type id is the one correponding to BOOL
 *
 * @param kSregexIt the regex match for a "key": value card information
 * @return the type identifier of the value element
 */
const unsigned int
getTypeIndexOfRegexIterator(const std::sregex_iterator &kSregexIt);
/**
 * Add a list of cards (TODO: Complete documentation and function)
 *
 * @param kCards
 * @param aTransaction
 */
void addCardsToDatabase(HearthstoneAPIHandler &aAPIIntermediate,
                        pqxx::work &aTransaction,
                        const std::string &kURLOfCardsPage);

void refresh_cards_table();