| 1547 | } |
| 1548 | |
| 1549 | void Path::makePath(const JSONCPP_STRING& path, const InArgs& in) { |
| 1550 | const char* current = path.c_str(); |
| 1551 | const char* end = current + path.length(); |
| 1552 | InArgs::const_iterator itInArg = in.begin(); |
| 1553 | while (current != end) { |
| 1554 | if (*current == '[') { |
| 1555 | ++current; |
| 1556 | if (*current == '%') |
| 1557 | addPathInArg(path, in, itInArg, PathArgument::kindIndex); |
| 1558 | else { |
| 1559 | ArrayIndex index = 0; |
| 1560 | for (; current != end && *current >= '0' && *current <= '9'; ++current) |
| 1561 | index = index * 10 + ArrayIndex(*current - '0'); |
| 1562 | args_.push_back(index); |
| 1563 | } |
| 1564 | if (current == end || *++current != ']') |
| 1565 | invalidPath(path, int(current - path.c_str())); |
| 1566 | } else if (*current == '%') { |
| 1567 | addPathInArg(path, in, itInArg, PathArgument::kindKey); |
| 1568 | ++current; |
| 1569 | } else if (*current == '.' || *current == ']') { |
| 1570 | ++current; |
| 1571 | } else { |
| 1572 | const char* beginName = current; |
| 1573 | while (current != end && !strchr("[.", *current)) |
| 1574 | ++current; |
| 1575 | args_.push_back(JSONCPP_STRING(beginName, current)); |
| 1576 | } |
| 1577 | } |
| 1578 | } |
| 1579 | |
| 1580 | void Path::addPathInArg(const JSONCPP_STRING& /*path*/, |
| 1581 | const InArgs& in, |