本文整理汇总了C++中TextParser::setCursor方法的典型用法代码示例。如果您正苦于以下问题:C++ TextParser::setCursor方法的具体用法?C++ TextParser::setCursor怎么用?C++ TextParser::setCursor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextParser
的用法示例。
在下文中一共展示了TextParser::setCursor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compareLines
/*
* Determine if lines from two TextParsers containing *lineSpec are identical.
* Returns nonzero if *lineSpec line not found in both files.
*/
static int compareLines(
TextParser &parser1,
TextParser &parser2,
const char *lineSpec, // e.g., "FFT Type"
bool &match, // RETURNED, true if both parsers have the line and they match
char *lineBufOut) // RETURNED, one of the lines
{
char lineBuf[LINE_LENGTH_MAX];
parser1.setCursor(0);
parser2.setCursor(0);
if(!parser1.findLine(lineSpec, lineBuf)) {
return 1;
}
if(!parser2.findLine(lineSpec, lineBufOut)) {
return 1;
}
if(strcmp(lineBuf, lineBufOut)) {
match = false;
}
else {
match = true;
}
return 0;
}
示例2: fineLineWithTitle
/*
* Search for line containing lineTitle, return portion of the line following ":".
* Returns nonzero if no "lineTitle" line found.
* Line must contain at least 3 tokens - lineTitle, ":", and the string we return.
*/
static int fineLineWithTitle(TextParser &parser,
const char *lineTytle,
char *str) // caller allocates, RETURNED
{
char lineBuf[LINE_LENGTH_MAX];
parser.setCursor(0);
if(!parser.findLine(lineTytle, lineBuf)) {
return 1;
}
unsigned numTokens;
const char **tokens;
numTokens = parser.parseLine(lineBuf, tokens);
if(numTokens < 3) {
return 1;
}
/* copy all tokens after ":" to caller's string */
str[0] = '\0';
for(unsigned dex=2; dex<numTokens; dex++) {
strcat(str, tokens[dex]);
if(dex < (numTokens - 1)) {
strcat(str, " ");
}
}
/* Convenience: "Accelerate" is too big. */
if(strstr(str, "Accelerate")) {
strcpy(str, "vecLib");
}
/* so is CLMatrix */
else if(strstr(str, "CLMatrix")) {
strcpy(str, "CLM");
}
/* ditto MatrixFFT */
else if(strstr(str, "MatrixFFT")) {
strcpy(str, "Matrix");
}
return 0;
}