359 )AWK"; |
359 )AWK"; |
360 |
360 |
361 awkScript << std::endl; |
361 awkScript << std::endl; |
362 |
362 |
363 awkScript << L"function _readVariables() {" << std::endl; |
363 awkScript << L"function _readVariables() {" << std::endl; |
364 for (int i = 0; i < currentReaderMetadata.size(); i++) awkScript << a2v(currentReaderMetadata[i].getAttributeName()) << L"=_unescape($" << (i + 1) << L");" << std::endl; |
364 for (int i = 0; i < currentReaderMetadata.size(); i++) { |
|
365 AttributeMetadata& a = currentReaderMetadata[i]; |
|
366 awkScript << a2v(a.getAttributeName()); |
|
367 if (a.getTypeId() == TypeId::INTEGER) awkScript << L"=$" << (i + 1) << L";"; |
|
368 else if (a.getTypeId() == TypeId::BOOLEAN) awkScript << L"= $" << (i + 1) << L" == \"true\";"; |
|
369 else awkScript << L"=_unescape($" << (i + 1) << L");"; |
|
370 awkScript << std::endl; |
|
371 } |
365 awkScript << L"};" << std::endl; |
372 awkScript << L"};" << std::endl; |
366 awkScript << std::endl; |
373 awkScript << std::endl; |
367 |
374 |
368 awkScript << L"function _writeVariables() {" << std::endl; |
375 awkScript << L"function _writeVariables() {" << std::endl; |
369 awkScript << L"NF=" << currentWriterMetadata.size() << ";" << std::endl; |
376 awkScript << L"NF=" << currentWriterMetadata.size() << ";" << std::endl; |
370 for (int i = 0; i < currentWriterMetadata.size(); i++) awkScript << L"$" << (i + 1) << L"=_escape(" << a2v(currentWriterMetadata[i].attributeName) << L");" << std::endl; |
377 for (int i = 0; i < currentWriterMetadata.size(); i++) { |
|
378 writer::AttributeMetadata& a = currentWriterMetadata[i]; |
|
379 awkScript << L"$" << (i + 1); |
|
380 if (a.typeId == writer::TypeId::INTEGER) awkScript << L"=" << a2v(a.attributeName) << L";"; |
|
381 else if (a.typeId == writer::TypeId::BOOLEAN) awkScript << L"= " << a2v(a.attributeName) << L" ? \"true\" : \"false\" ;"; |
|
382 else awkScript << L"=_escape(" << a2v(a.attributeName) << L");"; |
|
383 awkScript << std::endl; |
|
384 } |
371 awkScript << L"};" << std::endl; |
385 awkScript << L"};" << std::endl; |
372 awkScript << std::endl; |
386 awkScript << std::endl; |
373 |
387 |
374 awkScript << L"function record() {" << std::endl; |
388 awkScript << L"function record() {" << std::endl; |
375 awkScript << L"_writeVariables();" << std::endl; |
389 awkScript << L"_writeVariables();" << std::endl; |