本文整理汇总了C++中FindInReadable函数的典型用法代码示例。如果您正苦于以下问题:C++ FindInReadable函数的具体用法?C++ FindInReadable怎么用?C++ FindInReadable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FindInReadable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nsAccessKeyInfo
void
nsTextBoxFrame::UpdateAccessIndex()
{
PRInt32 menuAccessKey;
nsMenuBarListener::GetMenuAccessKey(&menuAccessKey);
if (menuAccessKey) {
if (mAccessKey.IsEmpty()) {
if (mAccessKeyInfo) {
delete mAccessKeyInfo;
mAccessKeyInfo = nsnull;
}
} else {
if (!mAccessKeyInfo) {
mAccessKeyInfo = new nsAccessKeyInfo();
if (!mAccessKeyInfo)
return;
}
nsAString::const_iterator start, end;
mCroppedTitle.BeginReading(start);
mCroppedTitle.EndReading(end);
// remember the beginning of the string
nsAString::const_iterator originalStart = start;
PRBool found;
if (!AlwaysAppendAccessKey()) {
// not appending access key - do case-sensitive search
// first
found = FindInReadable(mAccessKey, start, end);
if (!found) {
// didn't find it - perform a case-insensitive search
start = originalStart;
found = FindInReadable(mAccessKey, start, end,
nsCaseInsensitiveStringComparator());
}
} else {
found = RFindInReadable(mAccessKey, start, end,
nsCaseInsensitiveStringComparator());
}
if (found)
mAccessKeyInfo->mAccesskeyIndex = Distance(originalStart, start);
else
mAccessKeyInfo->mAccesskeyIndex = kNotFound;
}
}
}
示例2: IsVideoContentType
bool IsVideoContentType(const nsCString& aContentType) {
NS_NAMED_LITERAL_CSTRING(video, "video");
if (FindInReadable(video, aContentType)) {
return true;
}
return false;
}
示例3: start
// static
Modifiers
UIEvent::ComputeModifierState(const nsAString& aModifiersList)
{
if (aModifiersList.IsEmpty()) {
return 0;
}
// Be careful about the performance. If aModifiersList is too long,
// parsing it needs too long time.
// XXX Should we abort if aModifiersList is too long?
Modifiers modifiers = 0;
nsAString::const_iterator listStart, listEnd;
aModifiersList.BeginReading(listStart);
aModifiersList.EndReading(listEnd);
for (uint32_t i = 0; i < ArrayLength(kPairs); i++) {
nsAString::const_iterator start(listStart), end(listEnd);
if (!FindInReadable(NS_ConvertASCIItoUTF16(kPairs[i].name), start, end)) {
continue;
}
if ((start != listStart && !NS_IsAsciiWhitespace(*(--start))) ||
(end != listEnd && !NS_IsAsciiWhitespace(*(end)))) {
continue;
}
modifiers |= kPairs[i].modifier;
}
return modifiers;
}
示例4:
nsresult
nsAboutCache::ParseURI(nsIURI * uri, nsCString &deviceID)
{
//
// about:cache[?device=string]
//
nsresult rv;
deviceID.Truncate();
nsCAutoString path;
rv = uri->GetPath(path);
if (NS_FAILED(rv)) return rv;
nsACString::const_iterator start, valueStart, end;
path.BeginReading(start);
path.EndReading(end);
valueStart = end;
if (!FindInReadable(NS_LITERAL_CSTRING("?device="), start, valueStart))
return NS_OK;
deviceID.Assign(Substring(valueStart, end));
return NS_OK;
}
示例5: PushOverBoundary
// Reads over a boundary and sets start to the position after the end of the
// boundary. Returns false if no boundary is found immediately.
bool
PushOverBoundary(const nsACString& aBoundaryString,
nsACString::const_iterator& aStart,
nsACString::const_iterator& aEnd)
{
// We copy the end iterator to keep the original pointing to the real end
// of the string.
nsACString::const_iterator end(aEnd);
const char* beginning = aStart.get();
if (FindInReadable(aBoundaryString, aStart, end)) {
// We either should find the body immediately, or after 2 chars with the
// 2 chars being '-', everything else is failure.
if ((aStart.get() - beginning) == 0) {
aStart.advance(aBoundaryString.Length());
return true;
}
if ((aStart.get() - beginning) == 2) {
if (*(--aStart) == '-' && *(--aStart) == '-') {
aStart.advance(aBoundaryString.Length() + 2);
return true;
}
}
}
return false;
}
示例6: FindCRLF
bool
FindCRLF(nsACString::const_iterator& aStart,
nsACString::const_iterator& aEnd)
{
nsACString::const_iterator end(aEnd);
return FindInReadable(NS_LITERAL_CSTRING("\r\n"), aStart, end);
}
示例7: DoFindInReadable
static PRBool DoFindInReadable(const nsACString& str, const nsACString& value)
{
nsACString::const_iterator start, end;
str.BeginReading(start);
str.EndReading(end);
return FindInReadable(value, start, end);
}
示例8: FindCharInReadable
nsresult
nsAboutCacheEntry::ParseURI(nsIURI *uri, nsCString &clientID,
bool &streamBased, nsCString &key)
{
//
// about:cache-entry?client=[string]&sb=[boolean]&key=[string]
//
nsresult rv;
nsAutoCString path;
rv = uri->GetPath(path);
if (NS_FAILED(rv)) return rv;
nsACString::const_iterator i1, i2, i3, end;
path.BeginReading(i1);
path.EndReading(end);
i2 = end;
if (!FindInReadable(NS_LITERAL_CSTRING("?client="), i1, i2))
return NS_ERROR_FAILURE;
// i2 points to the start of clientID
i1 = i2;
i3 = end;
if (!FindInReadable(NS_LITERAL_CSTRING("&sb="), i1, i3))
return NS_ERROR_FAILURE;
// i1 points to the end of clientID
// i3 points to the start of isStreamBased
clientID.Assign(Substring(i2, i1));
i1 = i3;
i2 = end;
if (!FindInReadable(NS_LITERAL_CSTRING("&key="), i1, i2))
return NS_ERROR_FAILURE;
// i1 points to the end of isStreamBased
// i2 points to the start of key
streamBased = FindCharInReadable('1', i3, i1);
key.Assign(Substring(i2, end));
return NS_OK;
}
示例9: AttrHasSubstring
static bool
AttrHasSubstring(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName,
nsIAtom* aStr_)
{
FakeRef<nsIAtom> aStr(aStr_);
auto match = [aStr](const nsAttrValue* aValue) {
nsAutoString str;
aValue->ToString(str);
return FindInReadable(str, nsDependentAtomString(aStr));
};
return DoMatch(aElement, aNS, aName, match);
}
示例10: FindInReadable
// the following block is to append the accesskey to mTitle if there is an accesskey
// but the mTitle doesn't have the character
void
nsTextBoxFrame::UpdateAccessTitle()
{
/*
* Note that if you change appending access key label spec,
* you need to maintain same logic in following methods. See bug 324159.
* toolkit/content/commonDialog.js (setLabelForNode)
* toolkit/content/widgets/text.xml (formatAccessKey)
*/
PRInt32 menuAccessKey;
nsMenuBarListener::GetMenuAccessKey(&menuAccessKey);
if (!menuAccessKey || mAccessKey.IsEmpty())
return;
if (!AlwaysAppendAccessKey() &&
FindInReadable(mAccessKey, mTitle, nsCaseInsensitiveStringComparator()))
return;
nsAutoString accessKeyLabel;
accessKeyLabel += '(';
accessKeyLabel += mAccessKey;
ToUpperCase(accessKeyLabel);
accessKeyLabel += ')';
if (mTitle.IsEmpty()) {
mTitle = accessKeyLabel;
return;
}
const nsDependentString& kEllipsis = nsContentUtils::GetLocalizedEllipsis();
PRUint32 offset = mTitle.Length();
if (StringEndsWith(mTitle, kEllipsis)) {
offset -= kEllipsis.Length();
} else if (StringEndsWith(mTitle, OLD_ELLIPSIS)) {
// Try to check with our old ellipsis (for old addons)
offset -= OLD_ELLIPSIS.Length();
} else {
// Try to check with
// our default ellipsis (for non-localized addons) or ':'
const PRUnichar kLastChar = mTitle.Last();
if (kLastChar == PRUnichar(0x2026) || kLastChar == PRUnichar(':'))
offset--;
}
if (InsertSeparatorBeforeAccessKey() &&
offset > 0 && !NS_IS_SPACE(mTitle[offset - 1])) {
mTitle.Insert(' ', offset);
offset++;
}
mTitle.Insert(accessKeyLabel, offset);
}
示例11: FindInReadable
NS_IMETHODIMP nsMailboxService::NewURI(const nsACString &aSpec,
const char *aOriginCharset,
nsIURI *aBaseURI,
nsIURI **_retval)
{
nsresult rv = NS_OK;
nsACString::const_iterator b, e;
if (FindInReadable(NS_LITERAL_CSTRING("?uidl="), aSpec.BeginReading(b), aSpec.EndReading(e)) ||
FindInReadable(NS_LITERAL_CSTRING("&uidl="), aSpec.BeginReading(b), aSpec.EndReading(e)))
{
nsCOMPtr<nsIProtocolHandler> handler =
do_GetService(kCPop3ServiceCID, &rv);
if (NS_SUCCEEDED(rv))
rv = handler->NewURI(aSpec, aOriginCharset, aBaseURI, _retval);
}
else
{
nsCOMPtr<nsIURI> aMsgUri = do_CreateInstance(kCMailboxUrl, &rv);
if (NS_SUCCEEDED(rv))
{
if (aBaseURI)
{
nsCAutoString newSpec;
rv = aBaseURI->Resolve(aSpec, newSpec);
if (NS_FAILED(rv))
return rv;
aMsgUri->SetSpec(newSpec);
}
else
{
aMsgUri->SetSpec(aSpec);
}
NS_ADDREF(*_retval = aMsgUri);
}
}
return rv;
}
示例12: NS_NAMED_LITERAL_CSTRING
NS_IMETHODIMP
nsLocalFile::SetRelativeDescriptor(nsIFile* aFromFile,
const nsACString& aRelativeDesc)
{
NS_NAMED_LITERAL_CSTRING(kParentDirStr, "../");
nsCOMPtr<nsIFile> targetFile;
nsresult rv = aFromFile->Clone(getter_AddRefs(targetFile));
if (NS_FAILED(rv)) {
return rv;
}
//
// aRelativeDesc is UTF-8 encoded
//
nsCString::const_iterator strBegin, strEnd;
aRelativeDesc.BeginReading(strBegin);
aRelativeDesc.EndReading(strEnd);
nsCString::const_iterator nodeBegin(strBegin), nodeEnd(strEnd);
nsCString::const_iterator pos(strBegin);
nsCOMPtr<nsIFile> parentDir;
while (FindInReadable(kParentDirStr, nodeBegin, nodeEnd)) {
rv = targetFile->GetParent(getter_AddRefs(parentDir));
if (NS_FAILED(rv)) {
return rv;
}
if (!parentDir) {
return NS_ERROR_FILE_UNRECOGNIZED_PATH;
}
targetFile = parentDir;
nodeBegin = nodeEnd;
pos = nodeEnd;
nodeEnd = strEnd;
}
nodeBegin = nodeEnd = pos;
while (nodeEnd != strEnd) {
FindCharInReadable('/', nodeEnd, strEnd);
targetFile->Append(NS_ConvertUTF8toUTF16(Substring(nodeBegin, nodeEnd)));
if (nodeEnd != strEnd) { // If there's more left in the string, inc over the '/' nodeEnd is on.
++nodeEnd;
}
nodeBegin = nodeEnd;
}
return InitWithFile(targetFile);
}
示例13: NS_ENSURE_FALSE
nsresult
nsDASHWebMODParser::GetTime(nsAString& aTimeStr, double& aTime)
{
NS_ENSURE_FALSE(aTimeStr.IsEmpty(), NS_ERROR_NOT_INITIALIZED);
// Fail if time string is not of the format "PT<time>S".
NS_NAMED_LITERAL_STRING(prefix, "PT");
NS_NAMED_LITERAL_STRING(suffix, "S");
nsAString::const_iterator start, end, prefixStart, prefixEnd,
suffixStart, suffixEnd;
// Search for "PT" at the start.
aTimeStr.BeginReading(start);
aTimeStr.EndReading(end);
prefixStart = start;
prefixEnd = end;
NS_ENSURE_TRUE(FindInReadable(prefix, prefixStart, prefixEnd),
NS_ERROR_ILLEGAL_VALUE);
NS_ENSURE_TRUE(prefixStart == start, NS_ERROR_ILLEGAL_VALUE);
// Search for "S" after "PT".
suffixStart = prefixEnd;
suffixEnd = end;
NS_ENSURE_TRUE(FindInReadable(suffix, suffixStart, suffixEnd),
NS_ERROR_ILLEGAL_VALUE);
NS_ENSURE_TRUE(suffixStart != prefixEnd, NS_ERROR_ILLEGAL_VALUE);
NS_ENSURE_TRUE(suffixEnd == end, NS_ERROR_ILLEGAL_VALUE);
// Parse inner substring for time.
const nsAutoString timeSubString(Substring(prefixEnd, suffixStart));
LOG("Parsing substring \"%s\" in \"%s\"",
NS_ConvertUTF16toUTF8(timeSubString).get(),
NS_ConvertUTF16toUTF8(aTimeStr).get());
NS_ENSURE_FALSE(timeSubString.IsEmpty(), NS_ERROR_ILLEGAL_VALUE);
nsresult rv;
aTime = timeSubString.ToDouble(&rv);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
示例14: ReplaceChar
static void ReplaceChar(nsCString& str, const nsACString& character,
const nsACString& replacement)
{
nsCString::const_iterator start, end;
str.BeginReading(start);
str.EndReading(end);
while (FindInReadable(character, start, end)) {
PRInt32 pos = end.size_backward();
str.Replace(pos - 1, 1, replacement);
str.BeginReading(start);
start.advance(pos + replacement.Length() - 1);
str.EndReading(end);
}
}
示例15: ContainsTopLevelSubstring
/**
* Determines whether or not a string exists as the root element in an XML data
* string buffer.
* @param dataString
* The data being sniffed
* @param substring
* The substring being tested for existence and root-ness.
* @returns true if the substring exists and is the documentElement, false
* otherwise.
*/
static bool
ContainsTopLevelSubstring(nsACString& dataString, const char *substring)
{
nsACString::const_iterator start, end;
dataString.BeginReading(start);
dataString.EndReading(end);
if (!FindInReadable(nsCString(substring), start, end)){
return false;
}
auto offset = start.get() - dataString.Data();
const char *begin = dataString.BeginReading();
// Only do the validation when we find the substring.
return IsDocumentElement(begin, begin + offset);
}