diff options
| author | Aotrix <[email protected]> | 2025-07-06 11:27:52 +0200 |
|---|---|---|
| committer | Aotrix <[email protected]> | 2025-07-06 11:27:52 +0200 |
| commit | a01e968169344a2bb2278c55b42d7f0c2c3e1763 (patch) | |
| tree | 1e712f7e4f59e3e63324a2352b8a3d84f0c63f67 /src/cardTypeHandlerInfo.cpp | |
| parent | 43ef56e2417de30c693df878d1325b076e45ee39 (diff) | |
added card type handler
Diffstat (limited to 'src/cardTypeHandlerInfo.cpp')
| -rw-r--r-- | src/cardTypeHandlerInfo.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/cardTypeHandlerInfo.cpp b/src/cardTypeHandlerInfo.cpp new file mode 100644 index 0000000..b49057a --- /dev/null +++ b/src/cardTypeHandlerInfo.cpp @@ -0,0 +1,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; +} |
