Parse attribute parameters
| 1440 | |
| 1441 | // Parse attribute parameters |
| 1442 | std::vector<Param> SourceFileAttributesParser::parseParameters( |
| 1443 | const std::string& input) { |
| 1444 | std::string::size_type blockstart = input.find_first_of(kParamBlockStart); |
| 1445 | std::string::size_type blockend = input.find_last_of(kParamBlockEnd); |
| 1446 | |
| 1447 | const std::string delimiters(","); |
| 1448 | std::vector<Param> params; |
| 1449 | std::string::size_type current; |
| 1450 | std::string::size_type next = std::string::npos; |
| 1451 | std::string::size_type signature_param_start = std::string::npos; |
| 1452 | do { // #nocov |
| 1453 | next = input.find_first_not_of(delimiters, next + 1); |
| 1454 | if (next == std::string::npos) |
| 1455 | break; // #nocov |
| 1456 | current = next; |
| 1457 | do { |
| 1458 | next = input.find_first_of(delimiters, next + 1); |
| 1459 | } while((next >= blockstart) && (next <= blockend) && |
| 1460 | (next != std::string::npos)); |
| 1461 | params.push_back(Param(input.substr(current, next - current))); |
| 1462 | if(params.back().name() == kExportSignature) { |
| 1463 | signature_param_start = current; |
| 1464 | } |
| 1465 | } while(next != std::string::npos); |
| 1466 | |
| 1467 | // if the signature param was found, then check that the name, |
| 1468 | // start block and end block exist and are in the correct order |
| 1469 | if(signature_param_start != std::string::npos) { |
| 1470 | bool sigchecks = |
| 1471 | signature_param_start < blockstart && |
| 1472 | blockstart < blockend && |
| 1473 | blockstart != std::string::npos && |
| 1474 | blockend != std::string::npos; |
| 1475 | if(!sigchecks) { |
| 1476 | throw Rcpp::exception("signature parameter found but missing {}"); |
| 1477 | } |
| 1478 | } |
| 1479 | return params; |
| 1480 | } |
| 1481 | |
| 1482 | // Parse a function from the specified spot in the source file |
| 1483 | Function SourceFileAttributesParser::parseFunction(size_t lineNumber) { |