MCPcopy Create free account
hub / github.com/EmbeddedRPC/erpc / append_string_escape

Function append_string_escape

erpcgen/src/cpptemplate/cpptempl.cpp:841–884  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

839}
840
841int append_string_escape(std::string &str, std::function<char(unsigned)> peek)
842{
843 char esc = peek(1);
844 std::string hex;
845 int n = 2;
846 switch (esc)
847 {
848 // standard C escape sequences
849 case 'a':
850 esc = '\a';
851 break;
852 case 'b':
853 esc = '\b';
854 break;
855 case 'f':
856 esc = '\f';
857 break;
858 case 'n':
859 esc = '\n';
860 break;
861 case 'r':
862 esc = '\r';
863 break;
864 case 't':
865 esc = '\t';
866 break;
867 case 'v':
868 esc = '\v';
869 break;
870 case '0':
871 esc = '\0';
872 break;
873 // handle hex escapes like \x2a
874 case 'x':
875 for (; std::isxdigit(peek(n)); ++n)
876 {
877 hex += peek(n);
878 }
879 esc = static_cast<char>(hex.empty() ? 0 : std::strtoul(hex.c_str(), nullptr, 16));
880 break;
881 }
882 str += esc;
883 return n - 1;
884}
885
886token_vector tokenize_statement(const std::string &text)
887{

Callers 1

tokenize_statementFunction · 0.85

Calls 1

emptyMethod · 0.45

Tested by

no test coverage detected