I need to parse URI-like string. This URI is specific to the project and corresponds to "scheme://path/to/file
", where path should be a syntactically correct path to file from filesystem point of view. For this purpose std::regex
was used with pattern R"(^(r[o|w])\:\/\/(((?!\$|\~|\.{2,}|\/$).)+)$)"
.
It works fine but code analyzer complies that it is not compliant as $
character is not belong to the C++ Language Standard basic source character set:
AUTOSAR C++14 A2-3-1 (Required) Only those characters specified in the C++ Language Standard basic source character set shall be used in the source code.
Exception to this rule (according to Autosar Guidelines):
It is permitted to use other characters inside the text of a wide string and a UTF-8 encoded string literal.
wchar_t
is prohibited by other rule, although it works with UTF-8 string
(but it looks ugly and unreadable in the code, also I'm afraid it is not safe).
Could someone help me with workaround or std::regex
here is not the best solution, then what would be better?
Are any other drawbacks of using UTF-8 string literal?
P.S. I need $
to be sure (on parsing phase) that path is not a directory and that it is not contain none of /../
, ~
, $
, so I can't just skip it.
Aucun commentaire:
Enregistrer un commentaire