本文整理汇总了C++中nsAString::FindChar方法的典型用法代码示例。如果您正苦于以下问题:C++ nsAString::FindChar方法的具体用法?C++ nsAString::FindChar怎么用?C++ nsAString::FindChar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsAString
的用法示例。
在下文中一共展示了nsAString::FindChar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: embeddedInterface
void
WifiProxyService::DispatchWifiEvent(const nsAString& aEvent, const nsACString& aInterface)
{
MOZ_ASSERT(NS_IsMainThread());
#if ANDROID_VERSION < 19
mListener->OnWaitEvent(aEvent, aInterface);
#else
// The interface might be embedded in the event string such as
// "IFNAME=wlan0 CTRL-EVENT-BSS-ADDED 65 3c:94:d5:7c:11:8b".
// Parse the interface name from the event string and use p2p0
// as the default interface if "IFNAME" is not found.
nsAutoString event;
nsAutoString embeddedInterface(NS_LITERAL_STRING("p2p0"));
if (StringBeginsWith(aEvent, NS_LITERAL_STRING("IFNAME"))) {
int32_t ifnameFrom = aEvent.FindChar('=') + 1;
int32_t ifnameTo = aEvent.FindChar(' ') - 1;
embeddedInterface = Substring(aEvent, ifnameFrom, ifnameTo - ifnameFrom + 1);
event = Substring(aEvent, aEvent.FindChar(' ') + 1);
}
else {
event = aEvent;
}
mListener->OnWaitEvent(event, NS_ConvertUTF16toUTF8(embeddedInterface));
#endif
}
示例2: while
static void
__ReplaceChar (nsAString &string, const PRUnichar replace, const PRUnichar with)
{
PRInt32 i = string.FindChar (replace);
while (i >= 0) {
string.Replace (i, 1, &with, 1);
i = string.FindChar (replace);
}
}
示例3:
NS_IMETHODIMP
nsEditorSpellCheck::SetCurrentDictionary(const nsAString& aDictionary)
{
NS_ENSURE_TRUE(mSpellChecker, NS_ERROR_NOT_INITIALIZED);
if (!mUpdateDictionaryRunning) {
nsDefaultStringComparator comparator;
nsAutoString langCode;
PRInt32 dashIdx = aDictionary.FindChar('-');
if (dashIdx != -1) {
langCode.Assign(Substring(aDictionary, 0, dashIdx));
} else {
langCode.Assign(aDictionary);
}
if (mPreferredLang.IsEmpty() || !nsStyleUtil::DashMatchCompare(mPreferredLang, langCode, comparator)) {
// When user sets dictionary manually, we store this value associated
// with editor url.
gDictionaryStore->StoreCurrentDictionary(mEditor, aDictionary);
} else {
// If user sets a dictionary matching (even partially), lang defined by
// document, we consider content pref has been canceled, and we clear it.
gDictionaryStore->ClearCurrentDictionary(mEditor);
}
// Also store it in as a preference. It will be used as a default value
// when everything else fails.
Preferences::SetString("spellchecker.dictionary", aDictionary);
}
return mSpellChecker->SetCurrentDictionary(aDictionary);
}
示例4: mSourceVariable
nsTemplateCondition::nsTemplateCondition(nsIAtom* aSourceVariable,
const nsAString& aRelation,
const nsAString& aTargets,
bool aIgnoreCase,
bool aNegate,
bool aIsMultiple)
: mSourceVariable(aSourceVariable),
mIgnoreCase(aIgnoreCase),
mNegate(aNegate),
mNext(nullptr)
{
SetRelation(aRelation);
if (aIsMultiple) {
PRInt32 start = 0, end = 0;
while ((end = aTargets.FindChar(',',start)) >= 0) {
if (end > start) {
mTargetList.AppendElement(Substring(aTargets, start, end - start));
}
start = end + 1;
}
if (start < PRInt32(aTargets.Length())) {
mTargetList.AppendElement(Substring(aTargets, start));
}
}
else {
mTargetList.AppendElement(aTargets);
}
MOZ_COUNT_CTOR(nsTemplateCondition);
}
示例5:
static void
RemoveCharsetFromFontSubstitute(nsAString &aName)
{
int32_t comma = aName.FindChar(PRUnichar(','));
if (comma >= 0)
aName.Truncate(comma);
}
示例6: Substring
/* static */ void
PeerIdentity::GetUser(const nsAString& aPeerIdentity, nsAString& aUser)
{
int32_t at = aPeerIdentity.FindChar('@');
if (at >= 0) {
aUser = Substring(aPeerIdentity, 0, at);
} else {
aUser.Truncate();
}
}
示例7: SOAP_EXCEPTION
nsresult
nsSOAPUtils::GetNamespaceURI(nsISOAPEncoding * aEncoding,
nsIDOMElement * aScope,
const nsAString & aQName,
nsAString & aURI)
{
aURI.Truncate();
PRInt32 i = aQName.FindChar(':');
if (i < 0) {
return NS_OK;
}
nsAutoString prefix;
prefix = Substring(aQName, 0, i);
nsAutoString result;
if (prefix.Equals(gSOAPStrings->kXMLPrefix)) {
result.Assign(gSOAPStrings->kXMLNamespaceURI);
}
else {
nsresult rc;
nsCOMPtr<nsIDOMNode> current = aScope;
nsCOMPtr<nsIDOMNamedNodeMap> attrs;
nsCOMPtr<nsIDOMNode> temp;
nsAutoString value;
while (current) {
rc = current->GetAttributes(getter_AddRefs(attrs));
if (NS_FAILED(rc))
return rc;
if (attrs) {
rc = attrs->GetNamedItemNS(gSOAPStrings->kXMLNamespaceNamespaceURI, prefix,
getter_AddRefs(temp));
if (NS_FAILED(rc))
return rc;
if (temp) {
rc = temp->GetNodeValue(result);
if (NS_FAILED(rc))
return rc;
break;
}
}
rc = current->GetParentNode(getter_AddRefs(temp));
if (NS_FAILED(rc))
return rc;
current = temp;
}
if (!current)
return SOAP_EXCEPTION(NS_ERROR_FAILURE,"SOAP_NAMESPACE", "Unable to resolve prefix in attribute value to namespace URI");
}
if (aEncoding) {
return aEncoding->GetInternalSchemaURI(result,aURI);
}
aURI.Assign(result);
return NS_OK;
}
示例8: getLocalPart
const nsDependentSubstring XMLUtils::getLocalPart(const nsAString& src)
{
// Anything after ':' is the local part of the name
PRInt32 idx = src.FindChar(':');
if (idx == kNotFound) {
return Substring(src, 0, src.Length());
}
NS_ASSERTION(idx > 0, "This QName looks invalid.");
return Substring(src, idx + 1, src.Length() - (idx + 1));
}
示例9: Substring
nsresult
nsSOAPUtils::GetLocalName(const nsAString & aQName,
nsAString & aLocalName)
{
PRInt32 i = aQName.FindChar(':');
if (i < 0)
aLocalName = aQName;
else
aLocalName = Substring(aQName, i+1, aQName.Length() - (i+1));
return NS_OK;
}
示例10: ProcessLengthValue
static
void ProcessLengthValue(const nsAString * aInputString, nsAString & aOutputString,
const char * aDefaultValueString,
const char * aPrependString, const char* aAppendString)
{
aOutputString.Truncate();
if (aInputString) {
aOutputString.Append(*aInputString);
if (-1 == aOutputString.FindChar(char16_t('%'))) {
aOutputString.AppendLiteral("px");
}
}
}
示例11: Substring
nsresult
txStylesheetCompilerState::init(const nsAString& aStylesheetURI,
txStylesheet* aStylesheet,
txListIterator* aInsertPosition)
{
NS_ASSERTION(!aStylesheet || aInsertPosition,
"must provide insertposition if loading subsheet");
mStylesheetURI = aStylesheetURI;
// Check for fragment identifier of an embedded stylesheet.
int32_t fragment = aStylesheetURI.FindChar('#') + 1;
if (fragment > 0) {
int32_t fragmentLength = aStylesheetURI.Length() - fragment;
if (fragmentLength > 0) {
// This is really an embedded stylesheet, not just a
// "url#". We may want to unescape the fragment.
mTarget = Substring(aStylesheetURI, (uint32_t)fragment,
fragmentLength);
mEmbedStatus = eNeedEmbed;
mHandlerTable = gTxEmbedHandler;
}
}
nsresult rv = NS_OK;
if (aStylesheet) {
mStylesheet = aStylesheet;
mToplevelIterator = *aInsertPosition;
mIsTopCompiler = false;
}
else {
mStylesheet = new txStylesheet;
NS_ENSURE_TRUE(mStylesheet, NS_ERROR_OUT_OF_MEMORY);
rv = mStylesheet->init();
NS_ENSURE_SUCCESS(rv, rv);
mToplevelIterator =
txListIterator(&mStylesheet->mRootFrame->mToplevelItems);
mToplevelIterator.next(); // go to the end of the list
mIsTopCompiler = true;
}
mElementContext = new txElementContext(aStylesheetURI);
NS_ENSURE_TRUE(mElementContext && mElementContext->mMappings,
NS_ERROR_OUT_OF_MEMORY);
// Push the "old" txElementContext
rv = pushObject(0);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
示例12: StoreCurrentDictionary
NS_IMETHODIMP
nsEditorSpellCheck::SetCurrentDictionary(const nsAString& aDictionary)
{
NS_ENSURE_TRUE(mSpellChecker, NS_ERROR_NOT_INITIALIZED);
nsRefPtr<nsEditorSpellCheck> kungFuDeathGrip = this;
// The purpose of mUpdateDictionaryRunning is to avoid doing all of this if
// UpdateCurrentDictionary's helper method DictionaryFetched, which calls us,
// is on the stack.
if (!mUpdateDictionaryRunning) {
// Ignore pending dictionary fetchers by increasing this number.
mDictionaryFetcherGroup++;
nsDefaultStringComparator comparator;
nsAutoString langCode;
int32_t dashIdx = aDictionary.FindChar('-');
if (dashIdx != -1) {
langCode.Assign(Substring(aDictionary, 0, dashIdx));
} else {
langCode.Assign(aDictionary);
}
uint32_t flags = 0;
mEditor->GetFlags(&flags);
if (!(flags & nsIPlaintextEditor::eEditorMailMask)) {
if (mPreferredLang.IsEmpty() ||
!nsStyleUtil::DashMatchCompare(mPreferredLang, langCode, comparator)) {
// When user sets dictionary manually, we store this value associated
// with editor url.
StoreCurrentDictionary(mEditor, aDictionary);
} else {
// If user sets a dictionary matching (even partially), lang defined by
// document, we consider content pref has been canceled, and we clear it.
ClearCurrentDictionary(mEditor);
}
// Also store it in as a preference. It will be used as a default value
// when everything else fails but we don't want this for mail composer
// because it has spellchecked dictionary settings in Preferences.
Preferences::SetString("spellchecker.dictionary", aDictionary);
}
}
return mSpellChecker->SetCurrentDictionary(aDictionary);
}
示例13: scheme
PRBool
nsHTMLContentSerializer::IsJavaScript(nsIAtom* aAttrNameAtom, const nsAString& aValueString)
{
if (aAttrNameAtom == nsGkAtoms::href ||
aAttrNameAtom == nsGkAtoms::src) {
static const char kJavaScript[] = "javascript";
PRInt32 pos = aValueString.FindChar(':');
if (pos < (PRInt32)(sizeof kJavaScript - 1))
return PR_FALSE;
nsAutoString scheme(Substring(aValueString, 0, pos));
scheme.StripWhitespace();
if ((scheme.Length() == (sizeof kJavaScript - 1)) &&
scheme.EqualsIgnoreCase(kJavaScript))
return PR_TRUE;
else
return PR_FALSE;
}
return nsContentUtils::IsEventAttributeName(aAttrNameAtom,
EventNameType_HTML);
}
示例14: HardReset
nsresult
nsSMILTimedElement::SetBeginOrEndSpec(const nsAString& aSpec,
PRBool aIsBegin)
{
nsRefPtr<nsSMILTimeValueSpec> spec;
SMILTimeValueSpecList& timeSpecsList = aIsBegin ? mBeginSpecs : mEndSpecs;
nsTArray<nsSMILInstanceTime>& instancesList
= aIsBegin ? mBeginInstances : mEndInstances;
timeSpecsList.Clear();
instancesList.Clear();
HardReset(); // XXX Need to take care of time dependents here
PRInt32 start;
PRInt32 end = -1;
PRInt32 length;
do {
start = end + 1;
end = aSpec.FindChar(';', start);
length = (end == -1) ? -1 : end - start;
spec = NS_NewSMILTimeValueSpec(this, aIsBegin,
Substring(aSpec, start, length));
if (spec)
timeSpecsList.AppendElement(spec);
} while (end != -1 && spec);
if (!spec) {
timeSpecsList.Clear();
instancesList.Clear();
HardReset();
return NS_ERROR_FAILURE;
}
UpdateCurrentInterval();
return NS_OK;
}
示例15: scheme
PRBool
nsHTMLContentSerializer::IsJavaScript(nsIAtom* aAttrNameAtom, const nsAString& aValueString)
{
if (aAttrNameAtom == nsHTMLAtoms::href ||
aAttrNameAtom == nsHTMLAtoms::src) {
static const char kJavaScript[] = "javascript";
PRInt32 pos = aValueString.FindChar(':');
if (pos < (PRInt32)(sizeof kJavaScript - 1))
return PR_FALSE;
nsAutoString scheme(Substring(aValueString, 0, pos));
scheme.StripWhitespace();
if ((scheme.Length() == (sizeof kJavaScript - 1)) &&
scheme.EqualsIgnoreCase(kJavaScript))
return PR_TRUE;
else
return PR_FALSE;
}
PRBool result =
(aAttrNameAtom == nsLayoutAtoms::onblur) || (aAttrNameAtom == nsLayoutAtoms::onchange)
|| (aAttrNameAtom == nsLayoutAtoms::onclick) || (aAttrNameAtom == nsLayoutAtoms::ondblclick)
|| (aAttrNameAtom == nsLayoutAtoms::onfocus) || (aAttrNameAtom == nsLayoutAtoms::onkeydown)
|| (aAttrNameAtom == nsLayoutAtoms::onkeypress) || (aAttrNameAtom == nsLayoutAtoms::onkeyup)
|| (aAttrNameAtom == nsLayoutAtoms::onload) || (aAttrNameAtom == nsLayoutAtoms::onmousedown)
|| (aAttrNameAtom == nsLayoutAtoms::onpageshow) || (aAttrNameAtom == nsLayoutAtoms::onpagehide)
|| (aAttrNameAtom == nsLayoutAtoms::onmousemove) || (aAttrNameAtom == nsLayoutAtoms::onmouseout)
|| (aAttrNameAtom == nsLayoutAtoms::onmouseover) || (aAttrNameAtom == nsLayoutAtoms::onmouseup)
|| (aAttrNameAtom == nsLayoutAtoms::onreset) || (aAttrNameAtom == nsLayoutAtoms::onselect)
|| (aAttrNameAtom == nsLayoutAtoms::onsubmit) || (aAttrNameAtom == nsLayoutAtoms::onunload)
|| (aAttrNameAtom == nsLayoutAtoms::onabort) || (aAttrNameAtom == nsLayoutAtoms::onerror)
|| (aAttrNameAtom == nsLayoutAtoms::onpaint) || (aAttrNameAtom == nsLayoutAtoms::onresize)
|| (aAttrNameAtom == nsLayoutAtoms::onscroll) || (aAttrNameAtom == nsLayoutAtoms::onbroadcast)
|| (aAttrNameAtom == nsLayoutAtoms::onclose) || (aAttrNameAtom == nsLayoutAtoms::oncontextmenu)
|| (aAttrNameAtom == nsLayoutAtoms::oncommand) || (aAttrNameAtom == nsLayoutAtoms::oncommandupdate)
|| (aAttrNameAtom == nsLayoutAtoms::ondragdrop) || (aAttrNameAtom == nsLayoutAtoms::ondragenter)
|| (aAttrNameAtom == nsLayoutAtoms::ondragexit) || (aAttrNameAtom == nsLayoutAtoms::ondraggesture)
|| (aAttrNameAtom == nsLayoutAtoms::ondragover) || (aAttrNameAtom == nsLayoutAtoms::oninput);
return result;
}