parser.cpp 741 B

1234567891011121314151617181920212223242526
  1. #include "parser.hpp"
  2. Parser::Parser (int argc, char** argv) {
  3. for(int i = 0; i < argc; i++) {
  4. flags.push_back(argv[i]);
  5. }
  6. }
  7. bool Parser::cmdOption (const std::string& option) {
  8. return std::find(flags.begin(), flags.end(), option) != flags.end();
  9. }
  10. const std::string& Parser::setFilename(const std::string& option, const int32_t points, const uint32_t number_channels, const uint32_t freq) {
  11. if(cmdOption(option)) {
  12. auto it = std::find(flags.begin(), flags.end(), option) - flags.begin();
  13. if(it - 1 == flags.size()) {
  14. return std::to_string(points) + std::to_string(number_channels) + std::to_string(freq);
  15. }
  16. else {
  17. return flags[it + 1];
  18. }
  19. }
  20. }