summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/cardTypeHandlerInfo.hpp16
-rw-r--r--src/cardTypeHandlerInfo.cpp53
2 files changed, 27 insertions, 42 deletions
diff --git a/include/cardTypeHandlerInfo.hpp b/include/cardTypeHandlerInfo.hpp
index 155633c..82eb469 100644
--- a/include/cardTypeHandlerInfo.hpp
+++ b/include/cardTypeHandlerInfo.hpp
@@ -7,21 +7,15 @@ class CardTypeHandlerInfo {
~CardTypeHandlerInfo() = default;
CardTypeHandlerInfo(const CardTypeHandlerInfo &) = delete;
CardTypeHandlerInfo(CardTypeHandlerInfo &&) = default;
- // TODO: rule of 5 ? delete copy operator ? how to call it I forgot
CardTypeHandlerInfo(
- const std::vector<std::string> &kCardTypeVector,
- const std::vector<std::string> &kCardValueRegexVector,
- const std::vector<std::function<const std::string(const std::string &)>>
- kJSONToSQLConverterVector);
+ const std::vector<std::string> &kCardTypeVector, const std::vector<std::string> &kCardValueRegexVector,
+ const std::vector<std::function<const std::string(const std::string &)>> kJSONToSQLConverterVector);
- void addCardInfo(const std::string &kCardType,
- const std::string &kCardValueRegex,
- const std::function<const std::string(const std::string &)>
- kJSONToSQLConverter);
+ void addCardInfo(const std::string &kCardType, const std::string &kCardValueRegex,
+ const std::function<const std::string(const std::string &)> kJSONToSQLConverter);
private:
std::vector<std::string> mCardType;
std::vector<std::string> mCardValueRegex;
- std::vector<std::function<const std::string(const std::string &)>>
- mJSONToSQLConverter;
+ std::vector<std::function<const std::string(const std::string &)>> mJSONToSQLConverter;
};
diff --git a/src/cardTypeHandlerInfo.cpp b/src/cardTypeHandlerInfo.cpp
index b49057a..46e8f56 100644
--- a/src/cardTypeHandlerInfo.cpp
+++ b/src/cardTypeHandlerInfo.cpp
@@ -1,41 +1,32 @@
#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
+void CardTypeHandlerInfo::addCardInfo(const std::string &kCardType, const std::string &kCardValueRegex,
+ const std::function<const std::string(const std::string &)> kJSONToSQLConverter) {
}
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"; });
+ 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;
}