本文整理汇总了C++中Tokenizer::isFinished方法的典型用法代码示例。如果您正苦于以下问题:C++ Tokenizer::isFinished方法的具体用法?C++ Tokenizer::isFinished怎么用?C++ Tokenizer::isFinished使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tokenizer
的用法示例。
在下文中一共展示了Tokenizer::isFinished方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPage
TextPage* TextParser::getPage(unsigned int no)
{
while ((! tokenizer.isFinished()) && (pages.size() <= no))
parseNextPage();
if (pages.size() <= no)
return NULL;
else
return pages[no];
}
示例2: getPage
TextPage* TextParser::getPage(unsigned int no)
{
while ((! tokenizer.isFinished()) && (pages.size() <= no))
parseNextPage();
return (pages.size() > no)? pages[no] : NULL;
}
示例3: parseNextPage
void TextParser::parseNextPage()
{
if (tokenizer.isFinished())
return;
int curPosY = 0;
int lineWidth = 0;
TextPage *page = new TextPage();
std::wstring line;
while (true) {
Token t = tokenizer.getNextToken();
if (Token::Eof == t.getType())
break;
if (Token::Para == t.getType()) {
if (0 < line.length())
addLine(page, line, curPosY, lineWidth);
if (! page->isEmpty())
curPosY += 10;
} else if (Token::Word == t.getType()) {
const std::wstring &word = t.getContent();
if (isImage(word)) {
addLine(page, line, curPosY, lineWidth);
SDL_Surface *image = getImage(keywordToImage(word));
if ((image->h + curPosY < pageHeight) || page->isEmpty()) {
int x = offsetX + (pageWidth - image->w) / 2;
page->add(new Picture(x, offsetY + curPosY, image));
curPosY += image->h;
} else {
tokenizer.unget(t);
break;
}
} else {
int width = font.getWidth(word);
if (lineWidth + width > pageWidth) {
if (! lineWidth) {
line = word;
addLine(page, line, curPosY, lineWidth);
} else {
addLine(page, line, curPosY, lineWidth);
if (curPosY >= pageHeight) {
tokenizer.unget(t);
break;
}
line = word;
lineWidth = width;
}
} else {
lineWidth += width;
if (line.size()) {
line += L' ';
lineWidth += spaceWidth;
}
line += word;
}
}
}
if (curPosY >= pageHeight)
break;
}
addLine(page, line, curPosY, lineWidth);
if (! page->isEmpty())
pages.push_back(page);
else
delete page;
}