本文整理汇总了C++中Arguments::haveOption方法的典型用法代码示例。如果您正苦于以下问题:C++ Arguments::haveOption方法的具体用法?C++ Arguments::haveOption怎么用?C++ Arguments::haveOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arguments
的用法示例。
在下文中一共展示了Arguments::haveOption方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mylogFileSize
void
StdOutputRedirector::init(const Arguments & theArguments) {
if (theArguments.haveOption("--std-logfile")) {
const char * myEnv = ::getenv(LOG_WRAPAROUND_FILESIZE);
if (myEnv) {
string mylogFileSize(myEnv);
_myMaximumFileSize = asl::as<long>(mylogFileSize);
}
myEnv = ::getenv(LOG_CREATE_ON_EACH_RUN);
if (myEnv) {
string myTmpStr(myEnv);
_myLogInOneFileFlag = !(strcmp(toLowerCase(myTmpStr).c_str(), "true") == 0);
}
myEnv = ::getenv(LOG_REMOVE_OLD_ARCHIVE);
if (myEnv) {
string myTmpStr(myEnv);
_myRemoveOldArchiveFlag = (strcmp(toLowerCase(myTmpStr).c_str(), "true") == 0);
}
myEnv = ::getenv(LOG_WRAPAROUND_CHECK_SEC);
if (myEnv) {
string myTmpStr(myEnv);
_myFileSizeCheckFrequInSec = asl::as<long>(myTmpStr);
}
std::string myFilenameWithTimestamp = expandString(theArguments.getOptionArgument("--std-logfile"),
_myOutputFilename);
if (!_myLogInOneFileFlag) {
_myOutputFilename = myFilenameWithTimestamp;
}
// for syncing c like stderr & c++ cerr
// default is true, not syncing is supposted to be faster, so maybe we should disable it
//ios_base::sync_with_stdio(false);
redirect();
// write a timestamp
cout << ourAppStartMessage << _myOutputFilename << endl;
cout << "Timestamp: " << getCurrentTimeString() << endl;
cout << "---------" << endl;
// remove all but latest archives
if (_myRemoveOldArchiveFlag) {
removeoldArchives();
}
}
}
示例2: main
int main(int argc, char *argv[]) {
Arguments::AllowedOption myOptions[] = {
{"-o", "%s"},
{"-p", ""},
{"-d", ""},
{"-s", ""},
{"-l", ""},
{"-e", "%s"},
{"-b", "%s"},
{"-E", "%s"},
{"-B", "%s"},
{"-m", "%s"},
{"-O", "%s"},
{"-k", "%s"},
{"-K", "%s"},
{"-x", ""},
{"", ""}
};
try {
Arguments myArguments;
myArguments.addAllowedOptions(myOptions);
if (myArguments.parse(argc,argv) && myArguments.getCount()>=0) {
string keywords;
string begin_keywords;
string end_keywords;
string dictionary;
int minOverlap = 2;
int maxOverlap = 3;
if (myArguments.haveOption("-o")) {
minOverlap = asl::as<int>(myArguments.getOptionArgument("-o"));
}
if (myArguments.haveOption("-O")) {
maxOverlap = asl::as<int>(myArguments.getOptionArgument("-O"));
}
if (myArguments.haveOption("-m")) {
maxResultLen = asl::as<int>(myArguments.getOptionArgument("-m"));
}
if (myArguments.haveOption("-K")) {
keywords = readFile(myArguments.getOptionArgument("-K"), keywords);
}
if (myArguments.haveOption("-k")) {
if (keywords.size()) keywords.append("\n");
keywords.append(myArguments.getOptionArgument("-k"));
}
if (myArguments.haveOption("-B")) {
if (!readFile(myArguments.getOptionArgument("-B"), begin_keywords)) {
cerr << "Could not read begin keywords file '" << myArguments.getOptionArgument("-B") << "'" << endl;
exit(1);
}
}
if (myArguments.haveOption("-b")) {
if (begin_keywords.size()) begin_keywords.append("\n");
begin_keywords.append(myArguments.getOptionArgument("-b"));
}
if (myArguments.haveOption("-E")) {
if (!readFile(myArguments.getOptionArgument("-E"), end_keywords)) {
cerr << "Could not read end keywords file '" << myArguments.getOptionArgument("-E") << "'" << endl;
exit(1);
}
}
if (myArguments.haveOption("-e")) {
if (end_keywords.size()) end_keywords.append("\n");
end_keywords.append(myArguments.getOptionArgument("-e"));
}
shortForm = myArguments.haveOption("-s");
std::vector<string> myKeyWordList = splitString(keywords, " \n\r\t,:");
std::vector<string> myBeginKeyWordList = splitString(begin_keywords, " \n\r\t,:");
std::vector<string> myEndKeyWordList = splitString(end_keywords, " \n\r\t,:");
std::vector<string> myDictWordList;
for (int i = 0; i < myArguments.getCount();++i) {
cerr << "reading dictionary file '" << myArguments.getArgument(i) << "'" << endl;
if (readFile(myArguments.getArgument(i), dictionary)) {
std::vector<string> myNewDict = splitString(dictionary);
myDictWordList.insert(myDictWordList.end(), myNewDict.begin(), myNewDict.end());
} else {
cerr << "Could not read dictionary file '" << myArguments.getArgument(i) << "'" << endl;
exit(1);
}
}
if (myArguments.haveOption("-l")) {
cerr << "Converting dictionary and keywords to lower case" << endl;
for (unsigned int i = 0; i < myKeyWordList.size();++i) {
myKeyWordList[i] = toLowerCase(myKeyWordList[i]);
}
for (unsigned int i = 0; i < myBeginKeyWordList.size();++i) {
myBeginKeyWordList[i] = toLowerCase(myBeginKeyWordList[i]);
}
for (unsigned int i = 0; i < myEndKeyWordList.size();++i) {
myEndKeyWordList[i] = toLowerCase(myEndKeyWordList[i]);
}
for (unsigned int i = 0; i < myDictWordList.size();++i) {
myDictWordList[i] = toLowerCase(myDictWordList[i]);
}
}
if (myArguments.haveOption("-p")) {
cout << "Keywords:" << endl;
//.........这里部分代码省略.........