本文整理汇总了C++中CVectorSString::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ CVectorSString::insert方法的具体用法?C++ CVectorSString::insert怎么用?C++ CVectorSString::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVectorSString
的用法示例。
在下文中一共展示了CVectorSString::insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addNewItem
// add a new item a the end of the file
void addNewItem(CVectorSString &lines, uint itemIndex)
{
CVectorSString::iterator it = lines.end();
string s = "_Items#" + toString(itemIndex);
lines.insert(lines.end(), s);
lines.insert(lines.end(), s + "._SheetId=undef");
lines.insert(lines.end(), s + "._ClientInventoryPosition= -1");
lines.insert(lines.end(), s + "._Recommended= 250");
lines.insert(lines.end(), s + "._LocSlot= " + toString(itemIndex));
lines.insert(lines.end(), s + "._PhraseId=undef");
lines.insert(lines.end(), s + "._CraftParameters");
lines.insert(lines.end(), "\n");
}
示例2: updateItemField
// update an item field with a new value
void updateItemField(CVectorSString &lines, uint itemIndex, uint fieldIndex, uint &a, uint &b)
{
string field = fields[fieldIndex];
string val = items[itemIndex][fieldIndex];
string s = "_Items#";
s += toString(itemIndex);
s += ".";
s += field;
// remove jump
val = CSString(val).strtok("\n");
uint craftLine = 0;
bool found = false;
uint i = a-1;
// first pass to check if param have changed
for (i=a ; i<b ; i++)
{
string line = s + "= " + val;
string::size_type pos = lines[i].find(line.c_str());
if (pos != string::npos)
{
found = true;
break;
}
}
// second pass if new value
i = a-1;
while (++i<b && !found)
{
string::size_type pos;
// store the line "_CraftParameters" : reference line
if (craftLine == 0)
{
pos = lines[i].find("_CraftParameters");
if (pos != string::npos)
craftLine = i;
}
// search string
pos = lines[i].find(s.c_str());
if (pos == string::npos)
continue;
if (val != "")
{
// check if the attribute is the right one and not included in another one
// for example: Protection is in ProtectionFactor
if (!CSString::isValidFileNameChar(lines[i][s.size()]))
{
found = true;
if (val != "nul")
{
// udpdate value
lines[i] = s;
lines[i] += "= ";
lines[i] += val;
}
else
{
// remove value
CVectorSString::iterator it = lines.begin() + i;
lines.erase(it);
i--;
b--;
}
}
}
}
// param not found
if (!found && !val.empty() && val != "nul")
{
// add it
if (field.find("_CraftParameters") == string::npos)
{
// before craftLine
CVectorSString::iterator it = lines.begin() + craftLine;
lines.insert(it, s + "= " + val);
}
else
{
// after craftLine
CVectorSString::iterator it = lines.begin() + craftLine + 1;
lines.insert(it, s + "= " + val);
}
}
}