本文整理汇总了C++中Arguments::getInputFile方法的典型用法代码示例。如果您正苦于以下问题:C++ Arguments::getInputFile方法的具体用法?C++ Arguments::getInputFile怎么用?C++ Arguments::getInputFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arguments
的用法示例。
在下文中一共展示了Arguments::getInputFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[]){
bool match = 0;
Arguments a;
List_strings b;
a.setParam(argc, argv);
//a.getParam();
b.setFile(a.returnStrFile());
b.pA(a.returnSilent());
string aString = "";
if( a.getInputCount() == 0){
char tempChar;
while (!cin.eof()) {
cin.get(tempChar);
aString += tempChar;
}
int totalByte = 0;
b.resetBothIter();
for( int i = 0; i < b.returnNumber(); i++){
string name = b.getNextName();
string signuture = b.getNextString();
size_t found_old = 0;
do{
size_t found = aString.find(signuture, found_old);
if (found!=std::string::npos){
found_old = found +1;
if(!a.returnSilent()){
cout<<"("<<totalByte+found<<"): "<< name<<endl;
}
match = 1;
}
else{
break;
}
}while(aString.find(signuture, found_old));
if( a.returnStop()){
break;
}
}
}
for(int j = 0; j < a.getInputCount(); j++){
bool file_flag = 0;
FILE * pFile;
pFile=fopen(a.getInputFile(j).c_str(),"rb");
if(pFile == NULL){
perror(a.getInputFile(j).c_str());
continue;
}//input file cannot open
char * line = new char[1024];
int count = 0;
int totalByte = 0;
while( fgets(line,1024,pFile) ) {
string currentLine;
currentLine = line;
count++;
b.resetBothIter();
for( int i = 0; i < b.returnNumber(); i++){
string name = b.getNextName();
string signuture = b.getNextString();
size_t found_old = 0;
do{
size_t found = currentLine.find(signuture, found_old);
if (found!=std::string::npos){
found_old = found +1;
if(!a.returnSilent()){
if(a.getInputCount() > 1){
cout<<a.getInputFile(j);
}
cout<<"("<<totalByte+found<<"): "<< name<<endl;
}
match = 1;
file_flag = 1;
}
else{
break;
}
}while(currentLine.find(signuture, found_old));
if( a.returnStop() && file_flag){
break;
}
totalByte = totalByte+ currentLine.size();
}
}
delete[] line;
}
if( match && !b.returnMal()){
return 1;
}//matches and no malformed strs
//.........这里部分代码省略.........