本文整理汇总了C++中OovString::getStr方法的典型用法代码示例。如果您正苦于以下问题:C++ OovString::getStr方法的具体用法?C++ OovString::getStr怎么用?C++ OovString::getStr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OovString
的用法示例。
在下文中一共展示了OovString::getStr方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeCoverageStats
bool makeCoverageStats()
{
bool success = false;
SharedFile covHeaderFile;
OovString covHeaderFn = CoverageHeaderReader::getFn(
Project::getCoverageSourceDirectory());
eOpenStatus stat = covHeaderFile.open(covHeaderFn, M_ReadShared, OE_Binary);
if(stat == OS_Opened)
{
CoverageHeaderReader covHeaderReader;
OovStatus status = covHeaderReader.read(covHeaderFile);
if(status.needReport())
{
status.report(ET_Error, "Unable to read coverage header");
}
int headerInstrLines = covHeaderReader.getNumInstrumentedLines();
if(headerInstrLines > 0)
{
success = true;
FilePath covCountsFn(Project::getCoverageProjectDirectory(), FP_Dir);
covCountsFn.appendDir("out-Debug");
static char const covCountsFnStr[] = "OovCoverageCounts.txt";
covCountsFn.appendFile(covCountsFnStr);
CoverageCountsReader covCounts;
covCounts.read(covCountsFn);
int covInstrLines = covCounts.getNumInstrumentedLines();
if(headerInstrLines == covInstrLines)
{
makeCoverageStats(covHeaderReader, covCounts);
updateCovSourceCounts(covHeaderReader, covCounts);
}
else
{
fprintf(stderr, "Number of OovCoverage.h lines %d don't match %s lines %d\n",
headerInstrLines, covCountsFnStr, covInstrLines);
}
}
else
{
fprintf(stderr, "No lines are instrumented in %s\n", covHeaderFn.getStr());
}
}
else
{
fprintf(stderr, "Unable to open file %s\n", covHeaderFn.getStr());
}
return success;
}
示例2: write
bool CppFileContents::write(OovStringRef const fn)
{
SimpleFile file;
eOpenStatus openStat = file.open(fn, M_WriteExclusiveTrunc, OE_Binary);
OovStatus status(openStat == OS_Opened, SC_File);
if(status.ok())
{
OovString includeCov = "#include \"OovCoverage.h\"";
appendLineEnding(includeCov);
updateMemory();
status = file.write(includeCov.c_str(), includeCov.length());
}
if(status.ok())
{
status = file.write(mFileContents.data(), mFileContents.size());
}
if(!status.ok())
{
OovString str = "Unable to write %s ";
str += fn;
str += "\n";
status.report(ET_Error, str.getStr());
}
return status.ok();
}
示例3: 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);
}
}
示例4: FileIsFileOnDisk
bool FileIsFileOnDisk(OovStringRef const path, bool &success)
{
OovString tempPath = path;
FilePathRemovePathSep(tempPath, tempPath.size()-1);
struct OovStat32 statval;
int statRet = OovStat32(tempPath.getStr(), &statval);
// Indicate there is an error only if the error is not ENOENT.
success = ((statRet == 0) || (errno == ENOENT));
// Only indicate the file exists if there was no error, and it is a file.
return((statRet == 0) && !S_ISDIR(statval.st_mode));
}
示例5: setStyle
void Editor::setStyle()
{
GtkCssProvider *provider = gtk_css_provider_get_default();
GdkDisplay *display = gdk_display_get_default();
GdkScreen *screen = gdk_display_get_default_screen(display);
OovString path = Project::getBinDirectory();
path += "OovEdit.css";
GError *err = 0;
gtk_css_provider_load_from_path(provider, path.getStr(), &err);
gtk_style_context_add_provider_for_screen (screen,
GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref(provider);
}
示例6: FileEnsurePathExists
bool FileEnsurePathExists(OovStringRef const path)
{
bool success = true;
// Walk up the tree to find a base that exists.
FilePath fp(path, FP_File);
size_t pos = fp.getPosEndDir();
while(pos != 0)
{
fp.discardTail(pos);
bool ignoredSuccess = true;
if(fp.isDirOnDisk(ignoredSuccess))
break;
else
pos = fp.getPosLeftPathSep(pos, RP_RetPosFailure);
}
while(pos != std::string::npos && pos != 0 && success)
{
pos = findPathSep(path, pos);
if(pos != std::string::npos)
{
OovString partPath = path;
partPath.resize(pos);
if(!FileIsDirOnDisk(partPath, success))
{
#ifdef __linux__
success = (mkdir(partPath.getStr(), 0x1FF) == 0); // 0777
#else
success = (_mkdir(partPath.getStr()) == 0);
#endif
}
pos++;
}
}
return success;
}
示例7: coerceParentComponents
void ComponentTypesFile::coerceParentComponents(OovStringRef const compName)
{
OovString name = compName;
while(1)
{
size_t pos = name.rfind('/');
if(pos != std::string::npos)
{
name.erase(pos);
}
if(compName != name.getStr())
{
setComponentType(name, CT_Unknown);
}
if(pos == std::string::npos)
{
break;
}
}
}
示例8: read
bool CppFileContents::read(char const *fn)
{
SimpleFile file;
eOpenStatus openStat = file.open(fn, M_ReadWriteExclusive, OE_Binary);
OovStatus status(openStat == OS_Opened, SC_File);
if(status.ok())
{
int size = file.getSize();
mFileContents.resize(size);
int actual = 0;
status = file.read(mFileContents.data(), size, actual);
}
if(!status.ok())
{
OovString str = "Unable to read %s ";
str += fn;
str += "\n";
status.report(ET_Error, str.getStr());
}
return status.ok();
}