本文整理汇总了C++中OovString::appendInt方法的典型用法代码示例。如果您正苦于以下问题:C++ OovString::appendInt方法的具体用法?C++ OovString::appendInt怎么用?C++ OovString::appendInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OovString
的用法示例。
在下文中一共展示了OovString::appendInt方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write
/// For every includer file that is run across during parsing, this means that
/// the includer file was fully parsed, and that no old included information
/// needs to be kept, except to check if the old included information has not
/// changed.
///
/// This code assumes that no tricks are played with ifdef values, and
/// ifdef values must be the same every time a the same file is included.
void IncDirDependencyMap::write()
{
bool anyChanges = false;
time_t curTime;
time_t changedTime = 0;
time(&curTime);
#if(SHARED_FILE)
SharedFile file;
if(!writeFileExclusiveReadUpdate(file))
{
fprintf(stderr, "\nOovCppParser - Write file sharing error %s\n", getFilename().c_str());
}
#endif
// Append new values from parsed includes into the original NameValueFile.
// Update existing values times and make new dependencies.
for(const auto &newMapItem : mParsedIncludeDependencies)
{
bool changed = includedPathsChanged(newMapItem.first, newMapItem.second);
if(changed)
{
// Cheat and say updated time and checked time are the same.
changedTime = curTime;
CompoundValue newIncludedInfoCompVal;
OovString changeStr;
changeStr.appendInt(changedTime);
newIncludedInfoCompVal.addArg(changeStr);
OovString checkedStr;
checkedStr.appendInt(curTime);
newIncludedInfoCompVal.addArg(checkedStr);
for(const auto &str : newMapItem.second)
{
size_t pos = newIncludedInfoCompVal.find(str);
if(pos == CompoundValue::npos)
{
newIncludedInfoCompVal.addArg(str);
}
}
setNameValue(newMapItem.first, newIncludedInfoCompVal.getAsString());
anyChanges = true;
}
}
if(file.isOpen() && anyChanges)
{
#if(SHARED_FILE)
if(!writeFileExclusive(file))
{
OovString str = "Unable to write include map file";
OovError::report(ET_Error, str);
}
#else
writeFile();
#endif
}
}
示例2: write
void CoverageHeader::write(SharedFile &outDefFile, OovStringRef const /*srcFn*/,
int numInstrLines)
{
std::string fnDef = getFileDefine();
mInstrDefineMap[fnDef] = numInstrLines;
int totalCount = 0;
for(auto const &defItem : mInstrDefineMap)
{
totalCount += defItem.second;
}
if(outDefFile.isOpen())
{
OovString buf;
static char const *lines[] =
{
"// Automatically generated file by OovCovInstr\n",
"// This file should not normally be edited manually.\n",
"#define COV_IN(fileIndex, instrIndex) gCoverage[fileIndex+instrIndex]++;\n",
};
for(size_t i=0; i<sizeof(lines)/sizeof(lines[0]); i++)
{
buf += lines[i];
}
buf += "#define COV_TOTAL_INSTRS ";
buf.appendInt(totalCount);
buf += "\n";
buf += "extern unsigned short gCoverage[COV_TOTAL_INSTRS];\n";
int coverageCount = 0;
for(auto const &defItem : mInstrDefineMap)
{
OovString def = "#define ";
def += defItem.first;
def += " ";
def.appendInt(coverageCount);
coverageCount += defItem.second;
def += " // ";
def.appendInt(defItem.second);
def += "\n";
buf += def;
}
outDefFile.truncate();
OovStatus status = outDefFile.seekBegin();
if(status.ok())
{
status = outDefFile.write(&buf[0], static_cast<int>(buf.size()));
}
if(status.needReport())
{
status.report(ET_Error, "Unable to write coverage source");
}
}
}
示例3: idleDebugStatusChange
void Editor::idleDebugStatusChange(eDebuggerChangeStatus st)
{
if(st == DCS_RunState)
{
getEditFiles().updateDebugMenu();
if(mDebugger.getChildState() == DCS_ChildPaused)
{
auto const &loc = mDebugger.getStoppedLocation();
mEditFiles.viewModule(loc.getFilename(), loc.getLine());
mDebugger.startGetStack();
}
}
else if(st == DCS_Stack)
{
GtkTextView *view = GTK_TEXT_VIEW(ControlWindow::getTabView(
ControlWindow::CT_Stack));
Gui::setText(view, mDebugger.getStack());
}
else if(st == DCS_Value)
{
// mVarView.appendText(GuiTreeItem(), mDebugger.getVarValue().getAsString());
GuiTreeItem item;
appendTree(mVarView, item, mDebugger.getVarValue());
GuiTreeItem root;
int numChildren = mVarView.getNumChildren(root);
OovString numPathStr;
numPathStr.appendInt(numChildren-1);
GuiTreePath path(numPathStr);
mVarView.scrollToPath(path);
}
}
示例4: createDuplicatesFile
eDupReturn createDuplicatesFile(/*OovStringRef const projDir,*/ std::string &outFn)
{
eDupReturn ret = DR_NoDupFilesFound;
DuplicateOptions options;
std::vector<DuplicateLineInfo> dupLineInfo;
if(getDuplicateLineInfo(options, dupLineInfo))
{
FilePath outPath(Project::getProjectDirectory(), FP_Dir);
outPath.appendDir(DupsDir);
outPath.appendFile("Dups.txt");
File outFile;
OovStatus status = outFile.open(outPath, "w");
if(status.ok())
{
outFn = outPath;
for(auto const &lineInfo : dupLineInfo)
{
OovString str = "lines ";
str.appendInt(lineInfo.mTotalDupLines);
str += " : ";
str += lineInfo.mFile1;
str += " ";
str.appendInt(lineInfo.mFile1StartLine);
str += " : ";
str += lineInfo.mFile2;
str += " ";
str.appendInt(lineInfo.mFile2StartLine);
str += "\n";
status = outFile.putString(str);
if(!status.ok())
{
break;
}
}
ret = DR_Success;
}
else
{
ret = DR_UnableToCreateDirectory;
}
if(status.needReport())
{
status.report(ET_Error, "Unable to write to duplicates file");
}
}
return ret;
}
示例5: makeOverloadKeyFromOperUSR
OovString ModelStatement::makeOverloadKeyFromOperUSR(OovStringRef operStr)
{
OovString sym;
#define DEBUG_KEY 0
#if(DEBUG_KEY)
sym = operStr;
// Remove symbols that conflict with either the CompoundValue class or
// ModelStatement name separator characters.
sym.replaceStrs("@", "-");
sym.replaceStrs("#", "-");
sym.replaceStrs(":", "-");
sym.appendInt(makeHash(operStr), 16);
#else
sym.appendInt(makeHash(operStr), 16);
#endif
return sym;
}
示例6: appendTree
// This is recursive.
// This adds items if they does not exist. It preserves the tree
// so that the state of expanded items will not be destroyed.
// childIndex of -1 is special since the name is used to find the item.
static void appendTree(GuiTree &varView, GuiTreeItem &parentItem,
DebugResult const &debResult, int childIndex = -1)
{
OovString varPrefix = debResult.getVarName();
OovString str = varPrefix;
if(debResult.getValue().length() > 0)
{
varPrefix += " : ";
str = varPrefix;
str += debResult.getValue();
}
GuiTreeItem item;
bool foundItem = false;
if(childIndex == -1)
{
if(varView.findImmediateChildPartialMatch(varPrefix, parentItem, item))
{
foundItem = true;
}
}
else
{
foundItem = varView.getNthChild(parentItem, childIndex, item);
}
if(foundItem)
{
varView.setText(item, str);
}
else
{
item = varView.appendText(parentItem, str);
}
/// Remove items that no longer are available for the variable name.
{
int numDataChildren = debResult.getChildResults().size();
int numTreeChildren = varView.getNumChildren(item);
for(int childI=numDataChildren; childI<numTreeChildren; childI++)
{
varView.removeNthChild(item, childI);
}
}
int callerChildIndex = 0;
for(auto const &childRes : debResult.getChildResults())
{
appendTree(varView, item, *childRes.get(), callerChildIndex++);
}
/// @TODO - should only expand added item at parent level?
GuiTreeItem root;
int lastChild = varView.getNumChildren(root) - 1;
OovString numPathStr;
numPathStr.appendInt(lastChild);
GuiTreePath path(numPathStr);
varView.expandRow(path);
}
示例7: 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);
}
}
示例8: makeCovInstr
void CppInstr::makeCovInstr(OovString &covStr)
{
appendLineEnding(covStr);
covStr += "COV_IN(";
covStr += getFileDefine();
covStr += ", ";
covStr.appendInt(mInstrCount++);
covStr += ");";
appendLineEnding(covStr);
}
示例9: saveDiagram
OovStatusReturn ClassDiagram::saveDiagram(File &file)
{
OovStatus status(true, SC_File);
NameValueFile nameValFile;
CompoundValue names;
CompoundValue xPositions;
CompoundValue yPositions;
OovString drawingName;
for(auto const &node : mClassGraph.getNodes())
{
if(node.getType())
{
if(drawingName.length() == 0)
{
drawingName = node.getType()->getName();
}
names.addArg(node.getType()->getName());
}
else
{
names.addArg("Oov-Key");
}
OovString num;
num.appendInt(node.getPosition().x);
xPositions.addArg(num);
num.clear();
num.appendInt(node.getPosition().y);
yPositions.addArg(num);
}
if(drawingName.length() > 0)
{
DiagramStorage::setDrawingHeader(nameValFile, DST_Class, drawingName);
nameValFile.setNameValue("Names", names.getAsString());
nameValFile.setNameValue("XPositions", xPositions.getAsString());
nameValFile.setNameValue("YPositions", yPositions.getAsString());
status = nameValFile.writeFile(file);
}
return status;
}
示例10: findInFiles
void Editor::findInFiles(char const * const srchStr, char const * const path,
bool caseSensitive, bool sourceOnly, GtkTextView *view)
{
FindFiles findFiles(srchStr, caseSensitive, sourceOnly, view);
OovStatus status = findFiles.recurseDirs(path);
if(status.needReport())
{
OovString err = "Unable to search path ";
err += path;
status.report(ET_Error, err);
}
OovString matchStr = "Found ";
matchStr.appendInt(findFiles.getNumMatches());
matchStr += " matches";
Gui::appendText(view, matchStr);
}
示例11: processFile
// Return true while success.
bool FindFiles::processFile(OovStringRef const filePath)
{
bool success = true;
FilePath ext(filePath, FP_File);
bool isSource = (isCppHeader(ext) || isCppSource(ext) || isJavaSource(ext));
if(mSourceFilesOnly ? isSource : true)
{
FILE *fp = fopen(filePath.getStr(), "r");
if(fp)
{
char buf[1000];
int lineNum = 0;
while(fgets(buf, sizeof(buf), fp))
{
lineNum++;
char const *match=NULL;
if(mCaseSensitive)
{
match = strstr(buf, mSrchStr.c_str());
}
else
{
match = strcasestr(buf, mSrchStr.c_str());
}
if(match)
{
mNumMatches++;
OovString matchStr = filePath;
matchStr += ':';
matchStr.appendInt(lineNum);
matchStr += " ";
matchStr += buf;
// matchStr += '\n';
Gui::appendText(mView, matchStr);
}
}
fclose(fp);
}
}
return success;
}
示例12: setScreenCoord
void EditOptions::setScreenCoord(char const * const tag, int val)
{
OovString str;
str.appendInt(val);
setNameValue(tag, str);
}