本文整理汇总了C++中word::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ word::begin方法的具体用法?C++ word::begin怎么用?C++ word::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类word
的用法示例。
在下文中一共展示了word::begin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isWordValid
bool Index::isWordValid(word w) {
//cout << "call isWordValid(" << w << ")" << endl;
int i = 0;
for (string::iterator word_it=w.begin(); word_it != w.end(); word_it++) {
// check first char if it is valid
if (i == 0) {
if (!this->isFirstCharValid(*word_it)) {
//cout << "first char is not valid!" << endl;
//cout << "return false" << endl;
return false;
}
} else {
// all other characters, not at first, check if they're valid
if (!this->isCharValid(*word_it)) {
//cout << "some char in word is not valid" << endl;
//cout << "return false" << endl;
return false;
}
}
i++;
}
//cout << "return true" << endl;
return true;
}
示例2: FatalIOErrorInFunction
void setScoped
(
dictionary& dict,
const word& keyword,
const bool overwrite,
entry* d
)
{
if (keyword[0] == ':')
{
// Go up to top level and recurse to find entries
setScoped
(
const_cast<dictionary&>(dict.topDict()),
keyword.substr(1, keyword.size()-1),
overwrite,
d
);
return;
}
else
{
string::size_type dotPos = keyword.find('.');
if (dotPos == string::npos)
{
// Non-scoped lookup
if (overwrite)
{
dict.set(d);
}
else
{
dict.add(d, false);
}
return;
}
else
{
if (dotPos == 0)
{
// Starting with a '.'. Go up for every 2nd '.' found
const dictionary* dictPtr = &dict;
string::size_type begVar = dotPos + 1;
string::const_iterator iter =
keyword.begin() + begVar;
string::size_type endVar = begVar;
while
(
iter != keyword.end()
&& *iter == '.'
)
{
++iter;
++endVar;
// Go to parent
if (&dictPtr->parent() == &dictionary::null)
{
FatalIOErrorInFunction(dict)
<< "No parent of current dictionary"
<< " when searching for "
<< keyword.substr
(
begVar,
keyword.size() - begVar
)
<< exit(FatalIOError);
}
dictPtr = &dictPtr->parent();
}
setScoped
(
const_cast<dictionary&>(*dictPtr),
keyword.substr(endVar),
overwrite,
d
);
return;
}
else
{
// Extract the first word
word firstWord = keyword.substr(0, dotPos);
const entry* entPtr = dict.lookupScopedEntryPtr
(
firstWord,
false, // Recursive
false
);
if (!entPtr || !entPtr->isDict())
{
FatalIOErrorInFunction(dict)
<< "keyword " << firstWord
<< " is undefined in dictionary "
//.........这里部分代码省略.........