0
2
0
... | ... |
@@ -192,50 +192,50 @@ |
192 | 192 |
throw DataFormatError("Item not found"); |
193 | 193 |
} |
194 | 194 |
return _graph.direct(it->second, str[0] == '+'); |
195 | 195 |
} |
196 | 196 |
}; |
197 | 197 |
|
198 |
bool isWhiteSpace(char c) { |
|
198 |
inline bool isWhiteSpace(char c) { |
|
199 | 199 |
return c == ' ' || c == '\t' || c == '\v' || |
200 | 200 |
c == '\n' || c == '\r' || c == '\f'; |
201 | 201 |
} |
202 | 202 |
|
203 |
bool isOct(char c) { |
|
203 |
inline bool isOct(char c) { |
|
204 | 204 |
return '0' <= c && c <='7'; |
205 | 205 |
} |
206 | 206 |
|
207 |
int valueOct(char c) { |
|
207 |
inline int valueOct(char c) { |
|
208 | 208 |
LEMON_ASSERT(isOct(c), "The character is not octal."); |
209 | 209 |
return c - '0'; |
210 | 210 |
} |
211 | 211 |
|
212 |
bool isHex(char c) { |
|
212 |
inline bool isHex(char c) { |
|
213 | 213 |
return ('0' <= c && c <= '9') || |
214 | 214 |
('a' <= c && c <= 'z') || |
215 | 215 |
('A' <= c && c <= 'Z'); |
216 | 216 |
} |
217 | 217 |
|
218 |
int valueHex(char c) { |
|
218 |
inline int valueHex(char c) { |
|
219 | 219 |
LEMON_ASSERT(isHex(c), "The character is not hexadecimal."); |
220 | 220 |
if ('0' <= c && c <= '9') return c - '0'; |
221 | 221 |
if ('a' <= c && c <= 'z') return c - 'a' + 10; |
222 | 222 |
return c - 'A' + 10; |
223 | 223 |
} |
224 | 224 |
|
225 |
bool isIdentifierFirstChar(char c) { |
|
225 |
inline bool isIdentifierFirstChar(char c) { |
|
226 | 226 |
return ('a' <= c && c <= 'z') || |
227 | 227 |
('A' <= c && c <= 'Z') || c == '_'; |
228 | 228 |
} |
229 | 229 |
|
230 |
bool isIdentifierChar(char c) { |
|
230 |
inline bool isIdentifierChar(char c) { |
|
231 | 231 |
return isIdentifierFirstChar(c) || |
232 | 232 |
('0' <= c && c <= '9'); |
233 | 233 |
} |
234 | 234 |
|
235 |
char readEscape(std::istream& is) { |
|
235 |
inline char readEscape(std::istream& is) { |
|
236 | 236 |
char c; |
237 | 237 |
if (!is.get(c)) |
238 | 238 |
throw DataFormatError("Escape format error"); |
239 | 239 |
|
240 | 240 |
switch (c) { |
241 | 241 |
case '\\': |
... | ... |
@@ -281,13 +281,13 @@ |
281 | 281 |
else code = code * 8 + valueOct(c); |
282 | 282 |
return code; |
283 | 283 |
} |
284 | 284 |
} |
285 | 285 |
} |
286 | 286 |
|
287 |
std::istream& readToken(std::istream& is, std::string& str) { |
|
287 |
inline std::istream& readToken(std::istream& is, std::string& str) { |
|
288 | 288 |
std::ostringstream os; |
289 | 289 |
|
290 | 290 |
char c; |
291 | 291 |
is >> std::ws; |
292 | 292 |
|
293 | 293 |
if (!is.get(c)) |
... | ... |
@@ -222,23 +222,23 @@ |
222 | 222 |
throw DataFormatError("Item not found"); |
223 | 223 |
} |
224 | 224 |
return (_graph.direction(val) ? '+' : '-') + it->second; |
225 | 225 |
} |
226 | 226 |
}; |
227 | 227 |
|
228 |
bool isWhiteSpace(char c) { |
|
228 |
inline bool isWhiteSpace(char c) { |
|
229 | 229 |
return c == ' ' || c == '\t' || c == '\v' || |
230 | 230 |
c == '\n' || c == '\r' || c == '\f'; |
231 | 231 |
} |
232 | 232 |
|
233 |
bool isEscaped(char c) { |
|
233 |
inline bool isEscaped(char c) { |
|
234 | 234 |
return c == '\\' || c == '\"' || c == '\'' || |
235 | 235 |
c == '\a' || c == '\b'; |
236 | 236 |
} |
237 | 237 |
|
238 |
static void writeEscape(std::ostream& os, char c) { |
|
238 |
inline static void writeEscape(std::ostream& os, char c) { |
|
239 | 239 |
switch (c) { |
240 | 240 |
case '\\': |
241 | 241 |
os << "\\\\"; |
242 | 242 |
return; |
243 | 243 |
case '\"': |
244 | 244 |
os << "\\\""; |
... | ... |
@@ -273,25 +273,25 @@ |
273 | 273 |
os << c; |
274 | 274 |
} |
275 | 275 |
return; |
276 | 276 |
} |
277 | 277 |
} |
278 | 278 |
|
279 |
bool requireEscape(const std::string& str) { |
|
279 |
inline bool requireEscape(const std::string& str) { |
|
280 | 280 |
if (str.empty() || str[0] == '@') return true; |
281 | 281 |
std::istringstream is(str); |
282 | 282 |
char c; |
283 | 283 |
while (is.get(c)) { |
284 | 284 |
if (isWhiteSpace(c) || isEscaped(c)) { |
285 | 285 |
return true; |
286 | 286 |
} |
287 | 287 |
} |
288 | 288 |
return false; |
289 | 289 |
} |
290 | 290 |
|
291 |
std::ostream& writeToken(std::ostream& os, const std::string& str) { |
|
291 |
inline std::ostream& writeToken(std::ostream& os, const std::string& str) { |
|
292 | 292 |
|
293 | 293 |
if (requireEscape(str)) { |
294 | 294 |
os << '\"'; |
295 | 295 |
for (std::string::const_iterator it = str.begin(); |
296 | 296 |
it != str.end(); ++it) { |
297 | 297 |
writeEscape(os, *it); |
0 comments (0 inline)