src/AwkHandler.h
branchv_0
changeset 17 54716ea44d52
parent 15 ba91a464d2b3
child 18 2ac59242d0cb
equal deleted inserted replaced
16:4e8fe4cc70f0 17:54716ea44d52
   255 
   255 
   256 	}
   256 	}
   257 
   257 
   258 	void attribute(const string_t& value) override {
   258 	void attribute(const string_t& value) override {
   259 		if (currentRelationConfiguration) {
   259 		if (currentRelationConfiguration) {
   260 			string_t variableName = a2v(currentReaderMetadata[currentAttributeIndex].getAttributeName());
       
   261 			string_t variableValue = escapeAwkValue(value);
       
   262 
       
   263 			currentAttributeIndex++;
   260 			currentAttributeIndex++;
   264 			currentAttributeIndex = currentAttributeIndex % currentReaderMetadata.size();
   261 			currentAttributeIndex = currentAttributeIndex % currentReaderMetadata.size();
   265 
   262 
   266 			// TODO: just the value – move name to the AWK function
   263 			std::string awkValue = convertor.to_bytes(escapeAwkValue(value));
   267 			std::string variablePair = convertor.to_bytes(variableName + L"=" + variableValue);
   264 			if (currentAttributeIndex == 0) awkValue += "\n";
   268 
   265 			else awkValue += "\t";
   269 			if (currentAttributeIndex == 0) variablePair += "\n";
   266 
   270 			else variablePair += "\t";
   267 			write(awkInputWriterFD, awkValue.c_str(), awkValue.length());
   271 
       
   272 			write(awkInputWriterFD, variablePair.c_str(), variablePair.length());
       
   273 
       
   274 		} else {
   268 		} else {
   275 			relationalWriter->writeAttribute(value);
   269 			relationalWriter->writeAttribute(value);
   276 		}
   270 		}
   277 	}
   271 	}
   278 
   272