Make index zero-base, and also support relative index.
| 80 | |
| 81 | // Make index zero-base, and also support relative index. |
| 82 | static inline int fixIndex(int idx, int n) |
| 83 | { |
| 84 | if (idx > 0) |
| 85 | return idx - 1; |
| 86 | if (idx == 0) |
| 87 | return 0; |
| 88 | return n + idx; // negative value = relative |
| 89 | } |
| 90 | |
| 91 | static inline std::string parseString(const char*& token) |
| 92 | { |