本文整理汇总了C++中SkString::endsWith方法的典型用法代码示例。如果您正苦于以下问题:C++ SkString::endsWith方法的具体用法?C++ SkString::endsWith怎么用?C++ SkString::endsWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkString
的用法示例。
在下文中一共展示了SkString::endsWith方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseConfigFile
/**
* This function parses the given filename and stores the results in the given
* families array.
*/
static void parseConfigFile(const char *filename, SkTDArray<FontFamily*> &families) {
FILE* file = NULL;
#if !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
// if we are using a version of Android prior to Android 4.2 (JellyBean MR1
// at API Level 17) then we need to look for files with a different suffix.
char sdkVersion[PROP_VALUE_MAX];
__system_property_get("ro.build.version.sdk", sdkVersion);
const int sdkVersionInt = atoi(sdkVersion);
if (0 != *sdkVersion && sdkVersionInt < 17) {
SkString basename;
SkString updatedFilename;
SkString locale = SkFontConfigParser::GetLocale();
basename.set(filename);
// Remove the .xml suffix. We'll add it back in a moment.
if (basename.endsWith(".xml")) {
basename.resize(basename.size()-4);
}
// Try first with language and region
updatedFilename.printf("%s-%s.xml", basename.c_str(), locale.c_str());
file = fopen(updatedFilename.c_str(), "r");
if (!file) {
// If not found, try next with just language
updatedFilename.printf("%s-%.2s.xml", basename.c_str(), locale.c_str());
file = fopen(updatedFilename.c_str(), "r");
}
}
#endif
if (NULL == file) {
file = fopen(filename, "r");
}
// Some of the files we attempt to parse (in particular, /vendor/etc/fallback_fonts.xml)
// are optional - failure here is okay because one of these optional files may not exist.
if (NULL == file) {
return;
}
XML_Parser parser = XML_ParserCreate(NULL);
FamilyData *familyData = new FamilyData(&parser, families);
XML_SetUserData(parser, familyData);
XML_SetElementHandler(parser, startElementHandler, endElementHandler);
char buffer[512];
bool done = false;
while (!done) {
fgets(buffer, sizeof(buffer), file);
int len = strlen(buffer);
if (feof(file) != 0) {
done = true;
}
XML_Parse(parser, buffer, len, done);
}
XML_ParserFree(parser);
fclose(file);
}
示例2: openLocalizedFile
/**
* Use the current system locale (language and region) to open the best matching
* customization. For example, when the language is Japanese, the sequence might be:
* /system/etc/fallback_fonts-ja-JP.xml
* /system/etc/fallback_fonts-ja.xml
* /system/etc/fallback_fonts.xml
*/
FILE* openLocalizedFile(const char* origname) {
FILE* file = 0;
#if !defined(SK_BUILD_FOR_ANDROID_NDK)
SkString basename;
SkString filename;
char language[3] = "";
char region[3] = "";
basename.set(origname);
// Remove the .xml suffix. We'll add it back in a moment.
if (basename.endsWith(".xml")) {
basename.resize(basename.size()-4);
}
getLocale(language, region);
// Try first with language and region
filename.printf("%s-%s-%s.xml", basename.c_str(), language, region);
file = fopen(filename.c_str(), "r");
if (!file) {
// If not found, try next with just language
filename.printf("%s-%s.xml", basename.c_str(), language);
file = fopen(filename.c_str(), "r");
}
#endif
if (!file) {
// If still not found, try just the original name
file = fopen(origname, "r");
}
return file;
}
示例3: openLocalizedFile
/**
* Use the current system locale (language and region) to open the best matching
* customization. For example, when the language is Japanese, the sequence might be:
* /system/etc/fallback_fonts-ja-JP.xml
* /system/etc/fallback_fonts-ja.xml
* /system/etc/fallback_fonts.xml
*/
FILE* openLocalizedFile(const char* origname) {
FILE* file = 0;
SkString basename;
SkString filename;
AndroidLocale locale;
basename.set(origname);
// Remove the .xml suffix. We'll add it back in a moment.
if (basename.endsWith(".xml")) {
basename.resize(basename.size()-4);
}
getLocale(locale);
// Try first with language and region
filename.printf("%s-%s-%s.xml", basename.c_str(), locale.language, locale.region);
file = fopen(filename.c_str(), "r");
if (!file) {
// If not found, try next with just language
filename.printf("%s-%s.xml", basename.c_str(), locale.language);
file = fopen(filename.c_str(), "r");
if (!file) {
// If still not found, try just the original name
file = fopen(origname, "r");
}
}
return file;
}
示例4: tool_main
//.........这里部分代码省略.........
switch (numUnflaggedArguments++) {
case 0:
baseDir.set(argv[i]);
continue;
case 1:
comparisonDir.set(argv[i]);
continue;
case 2:
outputDir.set(argv[i]);
continue;
default:
SkDebugf("extra unflagged argument <%s>\n", argv[i]);
usage(argv[0]);
return kGenericError;
}
}
if (!strcmp(argv[i], "--listFailingBase")) {
listFailingBase = true;
continue;
}
SkDebugf("Unrecognized argument <%s>\n", argv[i]);
usage(argv[0]);
return kGenericError;
}
if (numUnflaggedArguments == 2) {
outputDir = comparisonDir;
} else if (numUnflaggedArguments != 3) {
usage(argv[0]);
return kGenericError;
}
if (!baseDir.endsWith(PATH_DIV_STR)) {
baseDir.append(PATH_DIV_STR);
}
if (printDirNames) {
printf("baseDir is [%s]\n", baseDir.c_str());
}
if (!comparisonDir.endsWith(PATH_DIV_STR)) {
comparisonDir.append(PATH_DIV_STR);
}
if (printDirNames) {
printf("comparisonDir is [%s]\n", comparisonDir.c_str());
}
if (!outputDir.endsWith(PATH_DIV_STR)) {
outputDir.append(PATH_DIV_STR);
}
if (generateDiffs) {
if (printDirNames) {
printf("writing diffs to outputDir is [%s]\n", outputDir.c_str());
}
} else {
if (printDirNames) {
printf("not writing any diffs to outputDir [%s]\n", outputDir.c_str());
}
outputDir.set("");
}
// If no matchSubstrings were specified, match ALL strings
// (except for whatever nomatchSubstrings were specified, if any).
if (matchSubstrings.isEmpty()) {
matchSubstrings.push(new SkString(""));
}
示例5: test_options
/**
* Given either a SkStream or a SkData, try to decode the encoded
* image using the specified options and report errors.
*/
static void test_options(skiatest::Reporter* reporter,
const SkDecodingImageGenerator::Options& opts,
SkStreamRewindable* encodedStream,
SkData* encodedData,
bool useData,
const SkString& path) {
SkBitmap bm;
bool success = false;
if (useData) {
if (NULL == encodedData) {
return;
}
success = SkInstallDiscardablePixelRef(
SkDecodingImageGenerator::Create(encodedData, opts), &bm);
} else {
if (NULL == encodedStream) {
return;
}
success = SkInstallDiscardablePixelRef(
SkDecodingImageGenerator::Create(encodedStream->duplicate(), opts), &bm);
}
if (!success) {
if (opts.fUseRequestedColorType
&& (kARGB_4444_SkColorType == opts.fRequestedColorType)) {
return; // Ignore known conversion inabilities.
}
// If we get here, it's a failure and we will need more
// information about why it failed.
ERRORF(reporter, "Bounds decode failed [sampleSize=%d dither=%s "
"colorType=%s %s]", opts.fSampleSize, yn(opts.fDitherImage),
options_colorType(opts), path.c_str());
return;
}
#if defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_UNIX)
// Android is the only system that use Skia's image decoders in
// production. For now, we'll only verify that samplesize works
// on systems where it already is known to work.
REPORTER_ASSERT(reporter, check_rounding(bm.height(), kExpectedHeight,
opts.fSampleSize));
REPORTER_ASSERT(reporter, check_rounding(bm.width(), kExpectedWidth,
opts.fSampleSize));
// The ImageDecoder API doesn't guarantee that SampleSize does
// anything at all, but the decoders that this test excercises all
// produce an output size in the following range:
// (((sample_size * out_size) > (in_size - sample_size))
// && out_size <= SkNextPow2(((in_size - 1) / sample_size) + 1));
#endif // SK_BUILD_FOR_ANDROID || SK_BUILD_FOR_UNIX
SkAutoLockPixels alp(bm);
if (bm.getPixels() == NULL) {
ERRORF(reporter, "Pixel decode failed [sampleSize=%d dither=%s "
"colorType=%s %s]", opts.fSampleSize, yn(opts.fDitherImage),
options_colorType(opts), path.c_str());
return;
}
SkColorType requestedColorType = opts.fRequestedColorType;
REPORTER_ASSERT(reporter,
(!opts.fUseRequestedColorType)
|| (bm.colorType() == requestedColorType));
// Condition under which we should check the decoding results:
if ((kN32_SkColorType == bm.colorType())
&& (!path.endsWith(".jpg")) // lossy
&& (opts.fSampleSize == 1)) { // scaled
const SkColor* correctPixels = kExpectedPixels;
SkASSERT(bm.height() == kExpectedHeight);
SkASSERT(bm.width() == kExpectedWidth);
int pixelErrors = 0;
for (int y = 0; y < bm.height(); ++y) {
for (int x = 0; x < bm.width(); ++x) {
if (*correctPixels != bm.getColor(x, y)) {
++pixelErrors;
}
++correctPixels;
}
}
if (pixelErrors != 0) {
ERRORF(reporter, "Pixel-level mismatch (%d of %d) "
"[sampleSize=%d dither=%s colorType=%s %s]",
pixelErrors, kExpectedHeight * kExpectedWidth,
opts.fSampleSize, yn(opts.fDitherImage),
options_colorType(opts), path.c_str());
}
}
}
示例6: tool_main
//.........这里部分代码省略.........
case 1:
comparisonFile.set(argv[i]);
continue;
default:
SkDebugf("extra unflagged argument <%s>\n", argv[i]);
usage(argv[0]);
return kGenericError;
}
}
SkDebugf("Unrecognized argument <%s>\n", argv[i]);
usage(argv[0]);
return kGenericError;
}
if (numUnflaggedArguments != 2) {
usage(argv[0]);
return kGenericError;
}
if (listFilenames) {
printf("Base file is [%s]\n", baseFile.c_str());
}
if (listFilenames) {
printf("Comparison file is [%s]\n", comparisonFile.c_str());
}
if (outputDir.isEmpty()) {
if (listFilenames) {
printf("Not writing any diffs. No output dir specified.\n");
}
} else {
if (!outputDir.endsWith(PATH_DIV_STR)) {
outputDir.append(PATH_DIV_STR);
}
if (listFilenames) {
printf("Writing diffs. Output dir is [%s]\n", outputDir.c_str());
}
}
// Some obscure documentation about diff/patch labels:
//
// Posix says the format is: <filename><tab><date>
// It also states that if a filename contains <tab> or <newline>
// the result is implementation defined
//
// Svn diff --diff-cmd provides labels of the form: <filename><tab><revision>
//
// Git diff --ext-diff does not supply arguments compatible with diff.
// However, it does provide the filename directly.
// skimagediff_git.sh: skimagediff %2 %5 -L "%1\t(%3)" -L "%1\t(%6)"
//
// Git difftool sets $LOCAL, $REMOTE, $MERGED, and $BASE instead of command line parameters.
// difftool.<>.cmd: skimagediff $LOCAL $REMOTE -L "$MERGED\t(local)" -L "$MERGED\t(remote)"
//
// Diff will write any specified label verbatim. Without a specified label diff will write
// <filename><tab><date>
// However, diff will encode the filename as a cstring if the filename contains
// Any of <space> or <double quote>
// A char less than 32
// Any escapable character \\, \a, \b, \t, \n, \v, \f, \r
//
// Patch decodes:
// If first <non-white-space> is <double quote>, parse filename from cstring.
// If there is a <tab> after the first <non-white-space>, filename is