Witam.
Mam takiego ifa:
}else if(AP.ArgumentsCount==2 && AP[1]=="create"){
if(AP[2]==AP.OutOfBound) {
std::cout<<"\tSecond argument is empty!";
return 5;
}
std::cout<<"asd";
}
Po tym ifie (if(AP[2]==AP.OutOfBound)) nic się nie wykonuje. Cokolwiek bym wpisał to asd się nie wypisze. Nie wiem jaki jest problem. Tutaj kod ArgParsera:
ArgParser.cpp:
#include "ArgParser.h"
ArgP::ArgumentParser::ArgumentParser(int ArgCount, char* ArgVal[]){
this->ArgsCount = ArgCount;
this->ArgumentsCount = ArgCount;
ArgValues.reserve(ArgsCount);
for(int i=0; i<ArgsCount; ++i){
ArgValues[i] = std::string(ArgVal[i]);
}
}
std::string ArgP::ArgumentParser::operator[](int index){
if(index>=ArgsCount){
return OutOfBound;
}
return this->ArgValues[index];
}
ArgParser.h:
#ifndef ARG_P_ARGPARSER
#define ARG_P_ARGPARSER
#include <string>
#include <vector>
#include <iostream>
namespace ArgP{
class ArgumentParser{
public:
explicit ArgumentParser(int ArgCount, char* ArgVal[]);
~ArgumentParser() = default;
std::string operator[](int index);
int ArgumentsCount;
std::string OutOfBound = "OutOfBound-ArgParser";
private:
int ArgsCount = 0;
std::vector<std::string> ArgValues;
};
}
#endif
Z góry dziękuję za pomoc.
Pzodrawiam.