MCPcopy Create free account
hub / github.com/OpenFOAM/OpenFOAM-dev / quotemeta

Method quotemeta

src/OpenFOAM/primitives/strings/string/stringI.H:141–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139
140template<class String>
141inline Foam::string
142Foam::string::quotemeta(const string& str, const char quote)
143{
144 if (!quote)
145 {
146 return str;
147 }
148
149 string sQuoted;
150 sQuoted.reserve(2*str.length());
151
152 int escaped = 0;
153 for (const_iterator iter = str.begin(); iter != str.end(); ++iter)
154 {
155 if (*iter == quote)
156 {
157 escaped ^= 1; // toggle state
158 }
159 else if (escaped)
160 {
161 escaped = 0;
162 }
163 else if (String::meta(*iter))
164 {
165 sQuoted += quote;
166 }
167
168 sQuoted += *iter;
169 }
170
171 sQuoted.resize(sQuoted.length());
172
173 return sQuoted;
174}
175
176
177template<class String>

Callers

nothing calls this directly

Calls 5

reserveMethod · 0.45
lengthMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected