equal
deleted
inserted
replaced
49 shared_ptr<writer::RelationalWriter> relationalWriter; |
49 shared_ptr<writer::RelationalWriter> relationalWriter; |
50 |
50 |
51 wregex relationNameRegEx; |
51 wregex relationNameRegEx; |
52 wregex attributeNameRegEx; |
52 wregex attributeNameRegEx; |
53 wregex searchRegEx; |
53 wregex searchRegEx; |
54 wregex replacementRegEx; |
54 string_t replacement; |
55 |
55 |
56 vector<boolean_t> currentReplacableAttributes; |
56 vector<boolean_t> currentReplacableAttributes; |
57 integer_t currentAttributeIndex = 0; |
57 integer_t currentAttributeIndex = 0; |
58 |
58 |
59 public: |
59 public: |
63 |
63 |
64 if (arguments.size() == 4) { |
64 if (arguments.size() == 4) { |
65 relationNameRegEx = wregex(arguments[0]); |
65 relationNameRegEx = wregex(arguments[0]); |
66 attributeNameRegEx = wregex(arguments[1]); |
66 attributeNameRegEx = wregex(arguments[1]); |
67 searchRegEx = wregex(arguments[2]); |
67 searchRegEx = wregex(arguments[2]); |
68 replacementRegEx = wregex(arguments[3]); |
68 replacement = arguments[3]; |
69 } else { |
69 } else { |
70 throw cli::RelpipeCLIException(L"Usage: relpipe-tr-sed <relationNameRegExp> <attributeNameRegExp> <searchRegExp> <replacementRegExp>", cli::CLI::EXIT_CODE_UNKNOWN_COMMAND); |
70 throw cli::RelpipeCLIException(L"Usage: relpipe-tr-sed <relationNameRegExp> <attributeNameRegExp> <searchRegExp> <replacementRegExp>", cli::CLI::EXIT_CODE_UNKNOWN_COMMAND); |
71 } |
71 } |
72 } |
72 } |
73 |
73 |
89 relationalWriter->startRelation(name, writerMetadata, true); |
89 relationalWriter->startRelation(name, writerMetadata, true); |
90 } |
90 } |
91 |
91 |
92 void attribute(const string_t& value) override { |
92 void attribute(const string_t& value) override { |
93 if (currentReplacableAttributes[currentAttributeIndex]) { |
93 if (currentReplacableAttributes[currentAttributeIndex]) { |
94 relationalWriter->writeAttribute(L"1234"); |
94 relationalWriter->writeAttribute(regex_replace(value, searchRegEx, replacement)); |
95 } else { |
95 } else { |
96 relationalWriter->writeAttribute(value); |
96 relationalWriter->writeAttribute(value); |
97 } |
97 } |
98 |
98 |
99 currentAttributeIndex++; |
99 currentAttributeIndex++; |