本文整理汇总了C++中nsAFlatCString::get方法的典型用法代码示例。如果您正苦于以下问题:C++ nsAFlatCString::get方法的具体用法?C++ nsAFlatCString::get怎么用?C++ nsAFlatCString::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsAFlatCString
的用法示例。
在下文中一共展示了nsAFlatCString::get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertURItoUnicode
nsresult nsTextToSubURI::convertURItoUnicode(const nsAFlatCString &aCharset,
const nsAFlatCString &aURI,
bool aIRI,
nsAString &_retval)
{
nsresult rv = NS_OK;
// check for 7bit encoding the data may not be ASCII after we decode
bool isStatefulCharset = statefulCharset(aCharset.get());
if (!isStatefulCharset && IsASCII(aURI)) {
CopyASCIItoUTF16(aURI, _retval);
return rv;
}
if (!isStatefulCharset && aIRI) {
if (IsUTF8(aURI)) {
CopyUTF8toUTF16(aURI, _retval);
return rv;
}
}
// empty charset could indicate UTF-8, but aURI turns out not to be UTF-8.
NS_ENSURE_FALSE(aCharset.IsEmpty(), NS_ERROR_INVALID_ARG);
nsCOMPtr<nsICharsetConverterManager> charsetConverterManager;
charsetConverterManager = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIUnicodeDecoder> unicodeDecoder;
rv = charsetConverterManager->GetUnicodeDecoder(aCharset.get(),
getter_AddRefs(unicodeDecoder));
NS_ENSURE_SUCCESS(rv, rv);
unicodeDecoder->SetInputErrorBehavior(nsIUnicodeDecoder::kOnError_Signal);
int32_t srcLen = aURI.Length();
int32_t dstLen;
rv = unicodeDecoder->GetMaxLength(aURI.get(), srcLen, &dstLen);
NS_ENSURE_SUCCESS(rv, rv);
char16_t *ustr = (char16_t *) NS_Alloc(dstLen * sizeof(char16_t));
NS_ENSURE_TRUE(ustr, NS_ERROR_OUT_OF_MEMORY);
rv = unicodeDecoder->Convert(aURI.get(), &srcLen, ustr, &dstLen);
if (NS_SUCCEEDED(rv))
_retval.Assign(ustr, dstLen);
NS_Free(ustr);
return rv;
}
示例2: convertURItoUnicode
nsresult nsTextToSubURI::convertURItoUnicode(const nsAFlatCString &aCharset,
const nsAFlatCString &aURI,
nsAString &_retval)
{
// check for 7bit encoding the data may not be ASCII after we decode
bool isStatefulCharset = statefulCharset(aCharset.get());
if (!isStatefulCharset) {
if (IsASCII(aURI)) {
CopyASCIItoUTF16(aURI, _retval);
return NS_OK;
}
if (IsUTF8(aURI)) {
CopyUTF8toUTF16(aURI, _retval);
return NS_OK;
}
}
// empty charset could indicate UTF-8, but aURI turns out not to be UTF-8.
NS_ENSURE_FALSE(aCharset.IsEmpty(), NS_ERROR_INVALID_ARG);
nsAutoCString encoding;
if (!EncodingUtils::FindEncodingForLabelNoReplacement(aCharset, encoding)) {
return NS_ERROR_UCONV_NOCONV;
}
nsCOMPtr<nsIUnicodeDecoder> unicodeDecoder =
EncodingUtils::DecoderForEncoding(encoding);
unicodeDecoder->SetInputErrorBehavior(nsIUnicodeDecoder::kOnError_Signal);
int32_t srcLen = aURI.Length();
int32_t dstLen;
nsresult rv = unicodeDecoder->GetMaxLength(aURI.get(), srcLen, &dstLen);
NS_ENSURE_SUCCESS(rv, rv);
char16_t *ustr = (char16_t *) moz_xmalloc(dstLen * sizeof(char16_t));
NS_ENSURE_TRUE(ustr, NS_ERROR_OUT_OF_MEMORY);
rv = unicodeDecoder->Convert(aURI.get(), &srcLen, ustr, &dstLen);
if (NS_SUCCEEDED(rv))
_retval.Assign(ustr, dstLen);
free(ustr);
return rv;
}
示例3:
static nsresult ConvertToUTF8(nsIUnicodeDecoder *aUnicodeDecoder,
nsAFlatCString& aString)
{
int32_t numberOfBytes = aString.Length();
int32_t outUnicodeLen;
nsAutoString buffer;
nsresult rv = aUnicodeDecoder->GetMaxLength(aString.get(), numberOfBytes,
&outUnicodeLen);
NS_ENSURE_SUCCESS(rv, rv);
if (!EnsureStringLength(buffer, outUnicodeLen))
return NS_ERROR_OUT_OF_MEMORY;
rv = aUnicodeDecoder->Convert(aString.get(), &numberOfBytes,
buffer.BeginWriting(), &outUnicodeLen);
NS_ENSURE_SUCCESS(rv, rv);
buffer.SetLength(outUnicodeLen);
CopyUTF16toUTF8(buffer, aString);
return NS_OK;
}
示例4: Encode
nsresult nsTestUConv::Encode(PRUnichar ** aSrc, PRUnichar * aSrcEnd,
char ** aDest, char * aDestEnd,
const nsAFlatCString& aCharset)
{
char * trace = "Encode";
mLog.AddTrace(trace);
nsresult res = NS_OK;
nsCOMPtr<nsICharsetConverterManager> ccMan =
do_GetService(kCharsetConverterManagerCID, &res);
if (NS_FAILED(res)) {
mLog.PrintError("NS_WITH_SERVICE", res);
return res;
}
nsCOMPtr<nsIUnicodeEncoder> enc;
res = ccMan->GetUnicodeEncoder(aCharset.get(), getter_AddRefs(enc));
if (NS_FAILED(res)) {
mLog.PrintError("GetUnicodeEncoder()", res);
return res;
}
res = ConvertEncode(aSrc, aSrcEnd, aDest, aDestEnd, enc);
if (NS_FAILED(res)) {
mLog.PrintError("Convert()", res);
return res;
}
res = FinishEncode(aDest, aDestEnd, enc);
if (NS_FAILED(res)) {
mLog.PrintError("Finish()", res);
return res;
}
mLog.DelTrace(trace);
return res;
}
示例5: permission
nsresult
nsPermissionManager::AddInternal(const nsAFlatCString &aHost,
const nsAFlatCString &aType,
PRUint32 aPermission,
PRInt64 aID,
PRUint32 aExpireType,
PRInt64 aExpireTime,
NotifyOperationType aNotifyOperation,
DBOperationType aDBOperation)
{
if (!IsChildProcess()) {
IPC::Permission permission((aHost),
(aType),
aPermission, aExpireType, aExpireTime);
nsTArray<ContentParent*> cplist;
ContentParent::GetAll(cplist);
for (PRUint32 i = 0; i < cplist.Length(); ++i) {
ContentParent* cp = cplist[i];
if (cp->NeedsPermissionsUpdate())
unused << cp->SendAddPermission(permission);
}
}
if (!gHostArena) {
gHostArena = new PLArenaPool;
if (!gHostArena)
return NS_ERROR_OUT_OF_MEMORY;
PL_INIT_ARENA_POOL(gHostArena, "PermissionHostArena", HOST_ARENA_SIZE);
}
// look up the type index
PRInt32 typeIndex = GetTypeIndex(aType.get(), true);
NS_ENSURE_TRUE(typeIndex != -1, NS_ERROR_OUT_OF_MEMORY);
// When an entry already exists, PutEntry will return that, instead
// of adding a new one
nsHostEntry *entry = mHostTable.PutEntry(aHost.get());
if (!entry) return NS_ERROR_FAILURE;
if (!entry->GetKey()) {
mHostTable.RawRemoveEntry(entry);
return NS_ERROR_OUT_OF_MEMORY;
}
// figure out the transaction type, and get any existing permission value
OperationType op;
PRInt32 index = entry->GetPermissionIndex(typeIndex);
if (index == -1) {
if (aPermission == nsIPermissionManager::UNKNOWN_ACTION)
op = eOperationNone;
else
op = eOperationAdding;
} else {
nsPermissionEntry oldPermissionEntry = entry->GetPermissions()[index];
// remove the permission if the permission is UNKNOWN, update the
// permission if its value or expire type have changed OR if the time has
// changed and the expire type is time, otherwise, don't modify. There's
// no need to modify a permission that doesn't expire with time when the
// only thing changed is the expire time.
if (aPermission == oldPermissionEntry.mPermission &&
aExpireType == oldPermissionEntry.mExpireType &&
(aExpireType != nsIPermissionManager::EXPIRE_TIME ||
aExpireTime == oldPermissionEntry.mExpireTime))
op = eOperationNone;
else if (aPermission == nsIPermissionManager::UNKNOWN_ACTION)
op = eOperationRemoving;
else
op = eOperationChanging;
}
// do the work for adding, deleting, or changing a permission:
// update the in-memory list, write to the db, and notify consumers.
PRInt64 id;
switch (op) {
case eOperationNone:
{
// nothing to do
return NS_OK;
}
case eOperationAdding:
{
if (aDBOperation == eWriteToDB) {
// we'll be writing to the database - generate a known unique id
id = ++mLargestID;
} else {
// we're reading from the database - use the id already assigned
id = aID;
}
entry->GetPermissions().AppendElement(nsPermissionEntry(typeIndex, aPermission, id, aExpireType, aExpireTime));
if (aDBOperation == eWriteToDB && aExpireType != nsIPermissionManager::EXPIRE_SESSION)
UpdateDB(op, mStmtInsert, id, aHost, aType, aPermission, aExpireType, aExpireTime);
if (aNotifyOperation == eNotify) {
NotifyObserversWithPermission(aHost,
mTypeArray[typeIndex],
//.........这里部分代码省略.........
示例6: EnableLogging
void
logging::Enable(const nsAFlatCString& aModules)
{
EnableLogging(aModules.get());
}
示例7: SetData
//----------------------------------------------------------------------------------------
void nsPersistentFileDescriptor::SetData(const nsAFlatCString& inData)
//----------------------------------------------------------------------------------------
{
mDescriptorString.CopyFrom(inData.get(), inData.Length());
}
示例8:
bool
CommonElementAnimationData::CanAnimatePropertyOnCompositor(const dom::Element *aElement,
nsCSSProperty aProperty)
{
static bool sShouldLog;
static bool sShouldLogPrefCached;
if (!sShouldLogPrefCached) {
sShouldLogPrefCached = true;
Preferences::AddBoolVarCache(&sShouldLog,
"layers.offmainthreadcomposition.log-animations");
}
nsIFrame* frame = aElement->GetPrimaryFrame();
if (aProperty == eCSSProperty_visibility) {
return true;
}
if (aProperty == eCSSProperty_opacity) {
bool enabled = nsLayoutUtils::AreOpacityAnimationsEnabled();
if (!enabled && sShouldLog) {
printf_stderr("Performance warning: Async animation of 'opacity' is disabled\n");
}
return enabled;
}
if (aProperty == eCSSProperty_transform) {
if (frame &&
frame->Preserves3D() &&
frame->Preserves3DChildren()) {
if (sShouldLog) {
printf_stderr("Gecko bug: Async animation of 'preserve-3d' transforms is not supported. See bug 779598\n");
}
return false;
}
if (frame && frame->IsSVGTransformed()) {
if (sShouldLog) {
printf_stderr("Gecko bug: Async 'transform' animations of frames with SVG transforms is not supported. See bug 779599\n");
}
return false;
}
bool enabled = nsLayoutUtils::AreTransformAnimationsEnabled();
if (!enabled && sShouldLog) {
printf_stderr("Performance warning: Async animation of 'transform' is disabled\n");
}
return enabled;
}
if (sShouldLog) {
const nsAFlatCString propName = nsCSSProps::GetStringValue(aProperty);
printf_stderr("Performance warning: Async animation cancelled because of unsupported property '%s'\n", propName.get());
}
return false;
}