本文整理汇总了C++中OovString::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ OovString::insert方法的具体用法?C++ OovString::insert怎么用?C++ OovString::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OovString
的用法示例。
在下文中一共展示了OovString::insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateCovSourceCounts
/// Copy a single source file and make a comment that contains the hit count
/// for each instrumented line.
static void updateCovSourceCounts(OovStringRef const relSrcFn,
std::vector<int> &counts)
{
FilePath srcFn(Project::getCoverageSourceDirectory(), FP_Dir);
srcFn.appendFile(relSrcFn);
FilePath dstFn(Project::getCoverageProjectDirectory(), FP_Dir);
dstFn.appendFile(relSrcFn);
File srcFile;
OovStatus status = srcFile.open(srcFn, "r");
if(status.ok())
{
status = FileEnsurePathExists(dstFn);
if(status.ok())
{
File dstFile;
status = dstFile.open(dstFn, "w");
if(status.ok())
{
char buf[1000];
size_t instrCount = 0;
while(srcFile.getString(buf, sizeof(buf), status))
{
if(strstr(buf, "COV_IN("))
{
if(instrCount < counts.size())
{
OovString countStr = " // ";
countStr.appendInt(counts[instrCount]);
OovString newStr = buf;
size_t pos = newStr.find('\n');
newStr.insert(pos, countStr);
if(newStr.length() < sizeof(buf)-1)
{
strcpy(buf, newStr.getStr());
}
}
instrCount++;
}
status = dstFile.putString(buf);
if(!status.ok())
{
break;
}
}
}
}
}
if(status.needReport())
{
OovString err = "Unable to transfer coverage ";
err += srcFn;
err += " ";
err += dstFn;
status.report(ET_Error, err);
}
}
示例2: insertNonCompoundInstr
void CppInstr::insertNonCompoundInstr(CXCursor cursor)
{
if(!clang_Cursor_isNull(cursor))
{
CXCursorKind cursKind = clang_getCursorKind(cursor);
// return statements that are children of if statements must be instrumented
// if not in a compound statement.
// if(cursKind != CXCursor_CompoundStmt /*&& clang_isStatement(cursKind)*/)
// If this is a compound statement, then it will be instrumented anyway.
if(cursKind != CXCursor_CompoundStmt)
{
bool doInstr = true;
// There is sometimes a parsing error where a null statement is returned.
// This occurs when all headers are not included or defines are not proper?
if(cursKind == CXCursor_NullStmt)
{
CXStringDisposer name(clang_getCursorSpelling(cursor));
if(name[0] != ';')
{
SourceLocation loc(cursor);
fprintf(stderr, "Unable to instrument line %d\n", loc.getLine());
doInstr = false;
}
}
if(doInstr)
{
#if(DEBUG_PARSE)
debugInstr(cursor, "insertNCI", mInstrCount);
#endif
SourceRange range(cursor);
OovString covStr;
makeCovInstr(covStr);
covStr.insert(0, "{");
insertOutputText(covStr, range.getStartLocation().getOffset());
insertOutputText("\n}\n", range.getEndLocation().getOffset()+1);
}
}
}
}