MCPcopy Create free account
hub / github.com/apache/trafficserver / extractFirstToken

Function extractFirstToken

plugins/compress/configuration.cc:68–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68string
69extractFirstToken(string &s, int (*fp)(int))
70{
71 int startTok{-1}, endTok{-1}, idx{0};
72
73 for (;; ++idx) {
74 if (idx == int(s.length())) {
75 if (endTok < 0) {
76 endTok = idx;
77 }
78 break;
79 } else if (fp(s[idx])) {
80 if ((startTok >= 0) and (endTok < 0)) {
81 endTok = idx;
82 }
83 } else if (endTok > 0) {
84 break;
85 } else if (startTok < 0) {
86 startTok = idx;
87 }
88 }
89
90 string tmp;
91 if (startTok >= 0) {
92 tmp = string(s, startTok, endTok - startTok);
93 }
94
95 if (idx > 0) {
96 s = string(s, idx, s.length() - idx);
97 }
98
99 return tmp;
100}
101
102enum ParserState {
103 kParseStart,

Callers 3

ParseMethod · 0.85

Calls 2

stringClass · 0.85
lengthMethod · 0.45

Tested by

no test coverage detected