// Copyright 2015 by Artem Prilutskiy

#ifndef USERDATASTORE_H
#define USERDATASTORE_H

#include <stdint.h>
#include <stdarg.h>
#include <mysql/mysql.h>

#define PREPARED_STATEMENT_COUNT  2

#define LONG_CALLSIGN_LENGTH      8
#define SLOW_DATA_TEXT_LENGTH     20

class UserDataStore
{
  public:

    UserDataStore(const char* file);
    ~UserDataStore();

    uint32_t getPrivateIDForCall(const char* call);
    bool getCredentialsForID(uint32_t number, char* call, char* text);

  protected:

    MYSQL* connection;
    MYSQL_STMT* statements[PREPARED_STATEMENT_COUNT];

    MYSQL_BIND* bind(int count, va_list* arguments);
    bool execute(int index, int count1, int count2, ...);

};

#endif