本文整理汇总了C++中PromiseFlatString函数的典型用法代码示例。如果您正苦于以下问题:C++ PromiseFlatString函数的具体用法?C++ PromiseFlatString怎么用?C++ PromiseFlatString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PromiseFlatString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: __android_log_print
void
MessageManagerGlobal::Dump(const nsAString& aStr)
{
if (!DOMPrefs::DumpEnabled()) {
return;
}
#ifdef ANDROID
__android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", NS_ConvertUTF16toUTF8(aStr).get());
#endif
#ifdef XP_WIN
if (IsDebuggerPresent()) {
OutputDebugStringW(PromiseFlatString(aStr).get());
}
#endif
fputs(NS_ConvertUTF16toUTF8(aStr).get(), stdout);
fflush(stdout);
}
开发者ID:artines1,项目名称:gecko-dev,代码行数:18,代码来源:MessageManagerGlobal.cpp
示例2: NS_ENSURE_TRUE
NS_IMETHODIMP nsCollationMacUC::AllocateRawSortKey(int32_t strength, const nsAString& stringIn,
uint8_t** key, uint32_t* outLen)
{
NS_ENSURE_TRUE(mInit, NS_ERROR_NOT_INITIALIZED);
NS_ENSURE_ARG_POINTER(key);
NS_ENSURE_ARG_POINTER(outLen);
nsresult res = EnsureCollator(strength);
NS_ENSURE_SUCCESS(res, res);
uint32_t stringInLen = stringIn.Length();
uint32_t maxKeyLen = (1 + stringInLen) * kCollationValueSizeFactor * sizeof(UCCollationValue);
if (maxKeyLen > mBufferLen) {
uint32_t newBufferLen = mBufferLen;
do {
newBufferLen *= 2;
} while (newBufferLen < maxKeyLen);
void *newBuffer = PR_Malloc(newBufferLen);
if (!newBuffer)
return NS_ERROR_OUT_OF_MEMORY;
PR_FREEIF(mBuffer);
mBuffer = newBuffer;
mBufferLen = newBufferLen;
}
ItemCount actual;
OSStatus err = ::UCGetCollationKey(mCollator, (const UniChar*) PromiseFlatString(stringIn).get(),
(UniCharCount) stringInLen,
(ItemCount) (mBufferLen / sizeof(UCCollationValue)),
&actual, (UCCollationValue *)mBuffer);
NS_ENSURE_TRUE((err == noErr), NS_ERROR_FAILURE);
uint32_t keyLength = actual * sizeof(UCCollationValue);
void *newKey = PR_Malloc(keyLength);
if (!newKey)
return NS_ERROR_OUT_OF_MEMORY;
memcpy(newKey, mBuffer, keyLength);
*key = (uint8_t *)newKey;
*outLen = keyLength;
return NS_OK;
}
开发者ID:Incognito,项目名称:mozilla-central,代码行数:44,代码来源:nsCollationMacUC.cpp
示例3: NS_ASSERTION
PRInt32
nsStaticCaseInsensitiveNameTable::Lookup(const nsAString& aName)
{
NS_ASSERTION(mNameArray, "not inited");
NS_ASSERTION(mNameTable.ops, "not inited");
const nsAFlatString& str = PromiseFlatString(aName);
NameTableKey key(&str);
NameTableEntry *entry =
static_cast<NameTableEntry*>
(PL_DHashTableOperate(&mNameTable, &key,
PL_DHASH_LOOKUP));
if (PL_DHASH_ENTRY_IS_FREE(entry))
return nsStaticCaseInsensitiveNameTable::NOT_FOUND;
return entry->mIndex;
}
开发者ID:Akin-Net,项目名称:mozilla-central,代码行数:19,代码来源:nsStaticNameTable.cpp
示例4: CheckTlbPath
static void
CheckTlbPath(JSONWriter& aJson, const nsAString& aTypelibPath)
{
const nsString& flatPath = PromiseFlatString(aTypelibPath);
DWORD bufCharLen = ExpandEnvironmentStrings(flatPath.get(), nullptr, 0);
auto buf = MakeUnique<WCHAR[]>(bufCharLen);
if (!ExpandEnvironmentStrings(flatPath.get(), buf.get(), bufCharLen)) {
return;
}
// See whether this tlb can actually be loaded
RefPtr<ITypeLib> typeLib;
HRESULT hr = LoadTypeLibEx(buf.get(), REGKIND_NONE, getter_AddRefs(typeLib));
nsPrintfCString loadResult("0x%08X", hr);
aJson.StringProperty("LoadResult", loadResult.get());
}
开发者ID:yrliou,项目名称:gecko-dev,代码行数:19,代码来源:InterfaceRegistrationAnnotator.cpp
示例5: ParseInteger
static bool ParseInteger(nsDependentSubstring& aString,
int32_t& aResult)
{
uint32_t index = FirstNonDigit(aString, 0);
if (index == 0) {
return false;
}
nsDependentSubstring n(aString, 0, index);
nsresult ec;
int32_t s = PromiseFlatString(n).ToInteger(&ec);
if (NS_FAILED(ec)) {
return false;
}
aString.Rebind(aString, index);
aResult = s;
return true;
}
开发者ID:alessandrod,项目名称:mozilla-central,代码行数:19,代码来源:nsMediaFragmentURIParser.cpp
示例6: serv
NS_IMETHODIMP
mozSpellChecker::SetCurrentDictionary(const nsAString &aDictionary)
{
if(!mSpellCheckingEngine)
return NS_ERROR_NULL_POINTER;
nsresult res;
res = mSpellCheckingEngine->SetDictionary(PromiseFlatString(aDictionary).get());
if(NS_FAILED(res)){
NS_WARNING("Dictionary load failed");
return res;
}
nsXPIDLString language;
nsCOMPtr<mozISpellI18NManager> serv(do_GetService("@mozilla.org/spellchecker/i18nmanager;1", &res));
if(serv && NS_SUCCEEDED(res)){
res = serv->GetUtil(language.get(),getter_AddRefs(mConverter));
}
return res;
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:20,代码来源:mozSpellChecker.cpp
示例7: RegOpenKeyExW
NS_IMETHODIMP
nsWindowsRegKey::HasChild(const nsAString& aName, bool* aResult)
{
if (NS_WARN_IF(!mKey)) {
return NS_ERROR_NOT_INITIALIZED;
}
// Check for the existence of a child key by opening the key with minimal
// rights. Perhaps there is a more efficient way to do this?
HKEY key;
LONG rv = RegOpenKeyExW(mKey, PromiseFlatString(aName).get(), 0,
STANDARD_RIGHTS_READ, &key);
if ((*aResult = (rv == ERROR_SUCCESS && key))) {
RegCloseKey(key);
}
return NS_OK;
}
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:20,代码来源:nsWindowsRegKey.cpp
示例8: NS_ENSURE_TRUE
NS_IMETHODIMP
nsWindowsRegKey::ReadStringValue(const nsAString &name, nsAString &result)
{
NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);
DWORD type, size;
const nsString &flatName = PromiseFlatString(name);
LONG rv = RegQueryValueExW(mKey, flatName.get(), 0, &type, NULL, &size);
if (rv != ERROR_SUCCESS)
return NS_ERROR_FAILURE;
// This must be a string type in order to fetch the value as a string.
// We're being a bit forgiving here by allowing types other than REG_SZ.
NS_ENSURE_STATE(type == REG_SZ ||
type == REG_EXPAND_SZ ||
type == REG_MULTI_SZ);
// The buffer size must be a multiple of 2.
NS_ENSURE_STATE(size % 2 == 0);
if (size == 0) {
result.Truncate();
return NS_OK;
}
// |size| includes room for the terminating null character
DWORD resultLen = size / 2 - 1;
result.SetLength(resultLen);
nsAString::iterator begin;
result.BeginWriting(begin);
if (begin.size_forward() != resultLen)
return NS_ERROR_OUT_OF_MEMORY;
rv = RegQueryValueExW(mKey, flatName.get(), 0, NULL, (LPBYTE) begin.get(),
&size);
return (rv == ERROR_SUCCESS) ? NS_OK : NS_ERROR_FAILURE;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:41,代码来源:nsWindowsRegKey.cpp
示例9: GetFileSystemCharset
//-------------------------------------------------------------------------
char * nsFilePicker::ConvertToFileSystemCharset(const nsAString& inString)
{
char *outString = nsnull;
nsresult rv = NS_OK;
// get file system charset and create a unicode encoder
if (nsnull == mUnicodeEncoder) {
nsCAutoString fileSystemCharset;
GetFileSystemCharset(fileSystemCharset);
nsCOMPtr<nsICharsetConverterManager> ccm =
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
rv = ccm->GetUnicodeEncoderRaw(fileSystemCharset.get(), &mUnicodeEncoder);
}
}
// converts from unicode to the file system charset
if (NS_SUCCEEDED(rv)) {
PRInt32 inLength = inString.Length();
const nsAFlatString& flatInString = PromiseFlatString(inString);
PRInt32 outLength;
rv = mUnicodeEncoder->GetMaxLength(flatInString.get(), inLength,
&outLength);
if (NS_SUCCEEDED(rv)) {
outString = static_cast<char*>(nsMemory::Alloc( outLength+1 ));
if (nsnull == outString) {
return nsnull;
}
rv = mUnicodeEncoder->Convert(flatInString.get(), &inLength, outString,
&outLength);
if (NS_SUCCEEDED(rv)) {
outString[outLength] = '\0';
}
}
}
return NS_SUCCEEDED(rv) ? outString : nsnull;
}
开发者ID:amyvmiwei,项目名称:firefox,代码行数:42,代码来源:nsFilePicker.cpp
示例10: GetEngineList
NS_IMETHODIMP
mozSpellChecker::SetCurrentDictionary(const nsAString &aDictionary)
{
// Calls to mozISpellCheckingEngine::SetDictionary might destroy us
nsRefPtr<mozSpellChecker> kungFuDeathGrip = this;
mSpellCheckingEngine = nullptr;
if (aDictionary.IsEmpty()) {
return NS_OK;
}
nsresult rv;
nsCOMArray<mozISpellCheckingEngine> spellCheckingEngines;
rv = GetEngineList(&spellCheckingEngines);
NS_ENSURE_SUCCESS(rv, rv);
for (int32_t i = 0; i < spellCheckingEngines.Count(); i++) {
// We must set mSpellCheckingEngine before we call SetDictionary, since
// SetDictionary calls back to this spell checker to check if the
// dictionary was set
mSpellCheckingEngine = spellCheckingEngines[i];
rv = mSpellCheckingEngine->SetDictionary(PromiseFlatString(aDictionary).get());
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<mozIPersonalDictionary> personalDictionary = do_GetService("@mozilla.org/spellchecker/personaldictionary;1");
mSpellCheckingEngine->SetPersonalDictionary(personalDictionary.get());
nsXPIDLString language;
nsCOMPtr<mozISpellI18NManager> serv(do_GetService("@mozilla.org/spellchecker/i18nmanager;1", &rv));
NS_ENSURE_SUCCESS(rv, rv);
return serv->GetUtil(language.get(),getter_AddRefs(mConverter));
}
}
mSpellCheckingEngine = nullptr;
// We could not find any engine with the requested dictionary
return NS_ERROR_NOT_AVAILABLE;
}
开发者ID:Incognito,项目名称:mozilla-central,代码行数:41,代码来源:mozSpellChecker.cpp
示例11: FirstNonDigit
bool nsMediaFragmentURIParser::ParseNPTFraction(nsDependentSubstring& aString, double& aFraction)
{
double fraction = 0.0;
if (aString.Length() > 0 && aString[0] == '.') {
PRUint32 index = FirstNonDigit(aString, 1);
if (index > 1) {
nsDependentSubstring number(aString, 0, index);
PRInt32 ec;
fraction = PromiseFlatString(number).ToDouble(&ec);
if (NS_FAILED(ec)) {
return PR_FALSE;
}
}
aString.Rebind(aString, index);
}
aFraction = fraction;
return PR_TRUE;
}
开发者ID:ehsan,项目名称:mozilla-history,代码行数:21,代码来源:nsMediaFragmentURIParser.cpp
示例12: ResetIfSet
PRBool nsAttrValue::ParseDoubleValue(const nsAString& aString)
{
ResetIfSet();
PRInt32 ec;
double val = PromiseFlatString(aString).ToDouble(&ec);
if (NS_FAILED(ec)) {
return PR_FALSE;
}
if (EnsureEmptyMiscContainer()) {
MiscContainer* cont = GetMiscContainer();
cont->mDoubleValue = val;
cont->mType = eDoubleValue;
nsAutoString serializedFloat;
serializedFloat.AppendFloat(val);
SetMiscAtomOrString(serializedFloat.Equals(aString) ? nsnull : &aString);
return PR_TRUE;
}
return PR_FALSE;
}
开发者ID:Egyptghost1,项目名称:DOMinator,代码行数:21,代码来源:nsAttrValue.cpp
示例13: CSP_IsQuotelessKeyword
bool
CSP_IsQuotelessKeyword(const nsAString& aKey)
{
nsString lowerKey = PromiseFlatString(aKey);
ToLowerCase(lowerKey);
static_assert(CSP_LAST_KEYWORD_VALUE ==
(sizeof(CSPStrKeywords) / sizeof(CSPStrKeywords[0])),
"CSP_LAST_KEYWORD_VALUE does not match length of CSPStrKeywords");
nsAutoString keyword;
for (uint32_t i = 0; i < CSP_LAST_KEYWORD_VALUE; i++) {
// skipping the leading ' and trimming the trailing '
keyword.AssignASCII(CSPStrKeywords[i] + 1);
keyword.Trim("'", false, true);
if (lowerKey.Equals(keyword)) {
return true;
}
}
return false;
}
开发者ID:CodeSpeaker,项目名称:gecko-dev,代码行数:21,代码来源:nsCSPUtils.cpp
示例14: NS_ENSURE_TRUE
NS_IMETHODIMP
XPathEvaluator::CreateExpression(const nsAString & aExpression,
nsIDOMXPathNSResolver *aResolver,
nsIDOMXPathExpression **aResult)
{
nsresult rv;
if (!mRecycler) {
nsRefPtr<txResultRecycler> recycler = new txResultRecycler;
NS_ENSURE_TRUE(recycler, NS_ERROR_OUT_OF_MEMORY);
rv = recycler->init();
NS_ENSURE_SUCCESS(rv, rv);
mRecycler = recycler;
}
nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocument);
XPathEvaluatorParseContext pContext(aResolver, !(doc && doc->IsHTML()));
nsAutoPtr<Expr> expression;
rv = txExprParser::createExpr(PromiseFlatString(aExpression), &pContext,
getter_Transfers(expression));
if (NS_FAILED(rv)) {
if (rv == NS_ERROR_DOM_NAMESPACE_ERR) {
return NS_ERROR_DOM_NAMESPACE_ERR;
}
return NS_ERROR_DOM_INVALID_EXPRESSION_ERR;
}
nsCOMPtr<nsIDOMDocument> document = do_QueryReferent(mDocument);
*aResult = new nsXPathExpression(expression, mRecycler, document);
if (!*aResult) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(*aResult);
return NS_OK;
}
开发者ID:JuannyWang,项目名称:gecko-dev,代码行数:40,代码来源:XPathEvaluator.cpp
示例15: PromiseFlatCString
NS_IMETHODIMP
nsPersistentProperties::SetStringProperty(const nsACString& aKey,
const nsAString& aNewValue,
nsAString& aOldValue)
{
const nsAFlatCString& flatKey = PromiseFlatCString(aKey);
PropertyTableEntry* entry = static_cast<PropertyTableEntry*>(
PL_DHashTableAdd(&mTable, flatKey.get()));
if (entry->mKey) {
aOldValue = entry->mValue;
NS_WARNING(nsPrintfCString("the property %s already exists\n",
flatKey.get()).get());
} else {
aOldValue.Truncate();
}
entry->mKey = ArenaStrdup(flatKey, &mArena);
entry->mValue = ArenaStrdup(PromiseFlatString(aNewValue), &mArena);
return NS_OK;
}
开发者ID:ashishrana7,项目名称:firefox,代码行数:22,代码来源:nsPersistentProperties.cpp
示例16: NS_PRECONDITION
PRBool
nsAttrValue::ParseIntWithBounds(const nsAString& aString,
PRInt32 aMin, PRInt32 aMax)
{
NS_PRECONDITION(aMin < aMax &&
aMin >= NS_ATTRVALUE_INTEGERTYPE_MINVALUE &&
aMax <= NS_ATTRVALUE_INTEGERTYPE_MAXVALUE, "bad boundaries");
ResetIfSet();
PRInt32 ec;
PRInt32 val = PromiseFlatString(aString).ToInteger(&ec);
if (NS_FAILED(ec)) {
return PR_FALSE;
}
val = PR_MAX(val, aMin);
val = PR_MIN(val, aMax);
SetIntValueAndType(val, eInteger);
return PR_TRUE;
}
开发者ID:EdgarChen,项目名称:mozilla-cvs-history,代码行数:22,代码来源:nsAttrValue.cpp
示例17: FirstNonDigit
bool nsMediaFragmentURIParser::ParseNPTHH(nsDependentSubstring& aString, uint32_t& aHour)
{
if (aString.Length() == 0) {
return false;
}
uint32_t index = FirstNonDigit(aString, 0);
if (index == 0) {
return false;
}
nsDependentSubstring n(aString, 0, index);
nsresult ec;
int32_t u = PromiseFlatString(n).ToInteger(&ec);
if (NS_FAILED(ec)) {
return false;
}
aString.Rebind(aString, index);
aHour = u;
return true;
}
开发者ID:alessandrod,项目名称:mozilla-central,代码行数:22,代码来源:nsMediaFragmentURIParser.cpp
示例18: EnsureFresh
NS_IMETHODIMP
nsDOMWindowList::NamedItem(const nsAString& aName, nsIDOMWindow** aReturn)
{
nsCOMPtr<nsIDocShellTreeItem> item;
*aReturn = nullptr;
EnsureFresh();
if (mDocShellNode) {
mDocShellNode->FindChildWithName(PromiseFlatString(aName).get(),
false, false, nullptr,
nullptr, getter_AddRefs(item));
nsCOMPtr<nsIScriptGlobalObject> globalObject(do_GetInterface(item));
if (globalObject) {
CallQueryInterface(globalObject.get(), aReturn);
}
}
return NS_OK;
}
开发者ID:AshishNamdev,项目名称:mozilla-central,代码行数:22,代码来源:nsDOMWindowList.cpp
示例19: do_CreateInstance
NS_IMETHODIMP
nsNSSDialogs::ShowCertError(nsIInterfaceRequestor *ctx,
nsISSLStatus *status,
nsIX509Cert *cert,
const nsAString & textErrorMessage,
const nsAString & htmlErrorMessage,
const nsACString & hostName,
PRUint32 portNumber)
{
nsCOMPtr<nsIPKIParamBlock> block =
do_CreateInstance(NS_PKIPARAMBLOCK_CONTRACTID);
if (!block)
return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<nsIDialogParamBlock> dialogBlock = do_QueryInterface(block);
nsresult rv;
rv = dialogBlock->SetInt(1, portNumber);
if (NS_FAILED(rv))
return rv;
rv = dialogBlock->SetString(1, NS_ConvertUTF8toUTF16(hostName).get());
if (NS_FAILED(rv))
return rv;
rv = dialogBlock->SetString(2, PromiseFlatString(textErrorMessage).get());
if (NS_FAILED(rv))
return rv;
rv = block->SetISupportAtIndex(1, cert);
if (NS_FAILED(rv))
return rv;
rv = nsNSSDialogHelper::openDialog(nsnull,
"chrome://pippki/content/certerror.xul",
block);
return rv;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:38,代码来源:nsNSSDialogs.cpp
示例20: OnMouseMove
NS_IMETHODIMP
compzillaWindow::HandleEvent (nsIDOMEvent* aDOMEvent)
{
nsAutoString type;
aDOMEvent->GetType (type);
if (type.EqualsLiteral ("mousemove")) {
OnMouseMove (aDOMEvent);
} else if (type.EqualsLiteral ("DOMMouseScroll")) {
OnDOMMouseScroll (aDOMEvent);
} else if (type.EqualsLiteral ("focus")) {
FocusIn (aDOMEvent);
} else if (type.EqualsLiteral ("blur")) {
FocusOut (aDOMEvent);
} else {
nsCOMPtr<nsIDOMEventTarget> target;
aDOMEvent->GetTarget (getter_AddRefs (target));
SPEW_EVENT ("HandleEvent: Unhandled type=%s, target=%p!!!\n",
PromiseFlatString (type).get(), target.get ());
}
return NS_OK;
}
开发者ID:orph,项目名称:pyro,代码行数:23,代码来源:compzillaWindow.cpp
注:本文中的PromiseFlatString函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论