MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / AtomMatchesChar

Function AtomMatchesChar

rtpose_wrapper/src/gtest/gtest-all.cpp:8004–8023  ·  view source on GitHub ↗

Returns true iff the given atom (specified by escaped and pattern) matches ch. The result is undefined if the atom is invalid.

Source from the content-addressed store, hash-verified

8002// Returns true iff the given atom (specified by escaped and pattern)
8003// matches ch. The result is undefined if the atom is invalid.
8004bool AtomMatchesChar(bool escaped, char pattern_char, char ch) {
8005 if (escaped) { // "\\p" where p is pattern_char.
8006 switch (pattern_char) {
8007 case 'd': return IsAsciiDigit(ch);
8008 case 'D': return !IsAsciiDigit(ch);
8009 case 'f': return ch == '\f';
8010 case 'n': return ch == '\n';
8011 case 'r': return ch == '\r';
8012 case 's': return IsAsciiWhiteSpace(ch);
8013 case 'S': return !IsAsciiWhiteSpace(ch);
8014 case 't': return ch == '\t';
8015 case 'v': return ch == '\v';
8016 case 'w': return IsAsciiWordChar(ch);
8017 case 'W': return !IsAsciiWordChar(ch);
8018 }
8019 return IsAsciiPunct(pattern_char) && pattern_char == ch;
8020 }
8021
8022 return (pattern_char == '.' && ch != '\n') || pattern_char == ch;
8023}
8024
8025// Helper function used by ValidateRegex() to format error messages.
8026String FormatRegexSyntaxError(const char* regex, int index) {

Callers 2

MatchRegexAtHeadFunction · 0.85

Calls 4

IsAsciiDigitFunction · 0.85
IsAsciiWhiteSpaceFunction · 0.85
IsAsciiWordCharFunction · 0.85
IsAsciiPunctFunction · 0.85

Tested by

no test coverage detected