Xmipp  v3.23.11-Nereus
Functions
argsparser.cpp File Reference
#include <algorithm>
#include <sstream>
#include "argsparser.h"
#include "xmipp_error.h"
Include dependency graph for argsparser.cpp:

Go to the source code of this file.

Functions

void addOcurrence (std::map< String, int > &map, const String &name)
 
void reportExclusiveErrors (std::stringstream &errors, std::vector< ParamDef *> &exclusive)
 

Function Documentation

◆ addOcurrence()

void addOcurrence ( std::map< String, int > &  map,
const String name 
)

Definition at line 849 of file argsparser.cpp.

850 {
851  if (map.find(name) != map.end())
852  map[name]++;
853  else
854  map[name] = 1;
855 }

◆ reportExclusiveErrors()

void reportExclusiveErrors ( std::stringstream &  errors,
std::vector< ParamDef *> &  exclusive 
)

Definition at line 857 of file argsparser.cpp.

858 {
859  if (exclusive.empty())
860  return;
861 
862  std::vector<ParamDef*> exclusive2;
863  for (size_t i = 0; i < exclusive.size(); ++i)
864  if (exclusive[i]->counter == 1)
865  exclusive2.push_back(exclusive[i]);
866  if (exclusive2.size() > 1)
867  {
868  errors << "Parameters ";
869  for (size_t i = 0; i < exclusive.size() - 1; ++i)
870  errors << exclusive[i]->name << " ";
871  errors << "and " << exclusive[exclusive.size()-1]->name << " are mutually exclusive (check alias)" << std::endl;
872  }
873  else if (exclusive2.empty() && exclusive[0]->notOptional)
874  {
875  errors << "You should provide parameter " << exclusive[0]->name;
876  for (size_t i = 1; i < exclusive.size(); ++i)
877  errors << " or " << exclusive[i]->name;
878  errors << std::endl;
879  }
880  exclusive.clear();
881 }
#define i