--- a/src/AwkHandler.h Sun May 26 22:15:05 2019 +0200
+++ b/src/AwkHandler.h Mon May 27 17:54:35 2019 +0200
@@ -361,13 +361,27 @@
awkScript << std::endl;
awkScript << L"function _readVariables() {" << std::endl;
- for (int i = 0; i < currentReaderMetadata.size(); i++) awkScript << a2v(currentReaderMetadata[i].getAttributeName()) << L"=_unescape($" << (i + 1) << L");" << std::endl;
+ for (int i = 0; i < currentReaderMetadata.size(); i++) {
+ AttributeMetadata& a = currentReaderMetadata[i];
+ awkScript << a2v(a.getAttributeName());
+ if (a.getTypeId() == TypeId::INTEGER) awkScript << L"=$" << (i + 1) << L";";
+ else if (a.getTypeId() == TypeId::BOOLEAN) awkScript << L"= $" << (i + 1) << L" == \"true\";";
+ else awkScript << L"=_unescape($" << (i + 1) << L");";
+ awkScript << std::endl;
+ }
awkScript << L"};" << std::endl;
awkScript << std::endl;
awkScript << L"function _writeVariables() {" << std::endl;
awkScript << L"NF=" << currentWriterMetadata.size() << ";" << std::endl;
- for (int i = 0; i < currentWriterMetadata.size(); i++) awkScript << L"$" << (i + 1) << L"=_escape(" << a2v(currentWriterMetadata[i].attributeName) << L");" << std::endl;
+ for (int i = 0; i < currentWriterMetadata.size(); i++) {
+ writer::AttributeMetadata& a = currentWriterMetadata[i];
+ awkScript << L"$" << (i + 1);
+ if (a.typeId == writer::TypeId::INTEGER) awkScript << L"=" << a2v(a.attributeName) << L";";
+ else if (a.typeId == writer::TypeId::BOOLEAN) awkScript << L"= " << a2v(a.attributeName) << L" ? \"true\" : \"false\" ;";
+ else awkScript << L"=_escape(" << a2v(a.attributeName) << L");";
+ awkScript << std::endl;
+ }
awkScript << L"};" << std::endl;
awkScript << std::endl;