Skip to content

added remove_comments_char transformation to address issue #971 #1098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions src/actions/transformations/remove_comments_char.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,28 @@ RemoveCommentsChar::RemoveCommentsChar(std::string action)

std::string RemoveCommentsChar::evaluate(std::string value,
Transaction *transaction) {
/**
* @todo Implement the transformation RemoveCommentsChar
*/
if (transaction) {
#ifndef NO_LOGS
transaction->debug(4, "Transformation RemoveCommentsChar " \
"is not implemented yet.");
#endif
int64_t i;

i = 0;
while (i < value.size()) {
if (value.at(i) == '/' && (i+1 < value.size()) && value.at(i+1) == '*') {
value.erase(i, 2);
} else if (value.at(i) == '*' && (i+1 < value.size()) && value.at(i+1) == '/') {
value.erase(i, 2);
} else if (value.at(i) == '<' && (i+1 < value.size()) && value.at(i+1) == '!' &&
(i+2 < value.size()) && value.at(i+2) == '-' && (i+3 < value.size()) &&
value.at(i+3) == '-') {
value.erase(i, 4);
} else if (value.at(i) == '-' && (i+1 < value.size()) && value.at(i+1) == '-' &&
(i+2 < value.size()) && value.at(i+2) == '>') {
value.erase(i, 3);
} else if (value.at(i) == '-' && (i+1 < value.size()) && value.at(i+1) == '-') {
value.erase(i, 2);
} else if (value.at(i) == '#') {
value.erase(i, 1);
} else {
i++;
}
}
return value;
}
Expand Down