Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottBailey committed Apr 13, 2023
1 parent 1d3fec4 commit 52bce66
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tools/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@

namespace antler {

/// Remove escape sequence character from input.
/// @note This is a SIMPLE algorithm that ONLY removes the first `\` in a 2 charachter sequence.
/// @todo Consider implementing more complicated transforms (e.g. convert "\t" to 0x09 or "\xFF" to 0xFF, etc).
/// @param input Input string that may or may not contain escape characters.
/// @return The transformed string.
std::string escape_transform(std::string input) {
for(auto i=input.begin(); i != input.end(); ++i) {
// Only remove this char *if* there is a char following.
// Note: erase plus increment effectively steps over the char follwing the erased `\` (e.g. "\\-O2" becomes "\-O2").
if(*i == '\\' && i+1 != input.end())
i = input.erase(i);
}
Expand Down

0 comments on commit 52bce66

Please sign in to comment.