summaryrefslogtreecommitdiff
path: root/src/cardTypeHandlerInfo.cpp
blob: b49057a59f53df59a04d1982a119abd2506b7f26 (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
37
38
39
40
41
#include "cardTypeHandlerInfo.hpp"

void CardTypeHandlerInfo::addCardInfo(
    const std::string &kCardType, const std::string &kCardValueRegex,
    const std::function<const std::string(const std::string &)>
        kJSONToSQLConverter) {
    // TODO: complete
}

const CardTypeHandlerInfo cardTypeHandlerInfoList() {
    CardTypeHandlerInfo aCardTypeHandlerInfo;

    aCardTypeHandlerInfo.addCardInfo(
        "INT", "[0-9]+",
        [](const std::string &kJSONContent) { return kJSONContent; });

    aCardTypeHandlerInfo.addCardInfo(
        "BOOL", "true|false",
        [](const std::string &kJSONContent) { return kJSONContent; });

    aCardTypeHandlerInfo.addCardInfo(
        "STRING", "\"[^\"?]*\"", [](const std::string &kJSONContent) {
            std::string aCopyOfJSONValue = kJSONContent;
            *aCopyOfJSONValue.begin() = '\'';
            *std::prev(aCopyOfJSONValue.end()) = '\'';
            return aCopyOfJSONValue;
        });

    aCardTypeHandlerInfo.addCardInfo(
        "LIST_OF_INT", "\\[[0-9,]*\\]", [](const std::string &kJSONContent) {
            std::string aCopyOfJSONValue = kJSONContent;
            aCopyOfJSONValue.append("\'");
            aCopyOfJSONValue.insert(aCopyOfJSONValue.begin(), '\'');
            return aCopyOfJSONValue;
        });

    aCardTypeHandlerInfo.addCardInfo(
        "NULL", "null", [](const std::string &kJSONContent) { return "NULL"; });

    return aCardTypeHandlerInfo;
}