本文整理汇总了C++中nsAFlatCString类的典型用法代码示例。如果您正苦于以下问题:C++ nsAFlatCString类的具体用法?C++ nsAFlatCString怎么用?C++ nsAFlatCString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了nsAFlatCString类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: NS_GFX_
extern "C" NS_GFX_(void) NS_RGBToASCIIHex(nscolor aColor,
nsAFlatCString& aResult)
{
aResult.SetLength(7);
NS_ASSERTION(aResult.Length() == 7, "small SetLength failed, use an autostring instead!");
char *buf = aResult.BeginWriting();
PR_snprintf(buf, 8, "#%02x%02x%02x",
NS_GET_R(aColor), NS_GET_G(aColor), NS_GET_B(aColor));
}
开发者ID:BigManager,项目名称:platform,代码行数:9,代码来源:nsColor.cpp
示例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;
}
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:47,代码来源:nsTextToSubURI.cpp
示例3: validOperator
bool validOperator(nsAFlatCString& aString) {
bool result=false;
int len=aString.Length();
switch(len) {
case 1: return true;
case 3:
result=(aString.Equals(NS_LITERAL_CSTRING("<<=")) ||
aString.Equals(NS_LITERAL_CSTRING(">>=")));
break;
default:
switch(aString[0]) {
case '+': case '=':
case '&': case '|':
case '<': case '>':
if((aString[1]==aString[0]) || (aString[1]=='='))
result=true;
break;
case '-':
if((aString[1]==aString[0]) || (aString[1]=='>'))
result=true;
break;
case ':':
if((len==2) && (aString[1]==aString[0]))
result=true;
break;
case '*':
case '/':
case '^':
case '!':
case '~':
case '%':
if((aString[1]=='='))
result=true;
break;
case '(':
result=aString[1]==')'; break;
case '[':
result=aString[1]==']'; break;
default:
break;
}
break;
}
return result;
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:46,代码来源:tokens.cpp
示例4: str_escape
// note that this appends to aResult, and does not assign!
static void str_escape(const char * original, nsAFlatCString& aResult)
{
/* JavaScript does not allow quotes, slashes, or line terminators inside
* strings so we must escape them. ECMAScript defines four line
* terminators, but we're only worrying about \r and \n here. We currently
* feed our pref script to the JS interpreter as Latin-1 so we won't
* encounter \u2028 (line separator) or \u2029 (paragraph separator).
*
* WARNING: There are hints that we may be moving to storing prefs
* as utf8. If we ever feed them to the JS compiler as UTF8 then
* we'll have to worry about the multibyte sequences that would be
* interpreted as \u2028 and \u2029
*/
const char *p;
if (original == NULL)
return;
/* Paranoid worst case all slashes will free quickly */
for (p=original; *p; ++p)
{
switch (*p)
{
case '\n':
aResult.Append("\\n");
break;
case '\r':
aResult.Append("\\r");
break;
case '\\':
aResult.Append("\\\\");
break;
case '\"':
aResult.Append("\\\"");
break;
default:
aResult.Append(*p);
break;
}
}
}
开发者ID:michaelrhanson,项目名称:mozilla-central,代码行数:46,代码来源:prefapi.cpp
示例5: ConvertToUTF8
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;
}
开发者ID:hideakihata,项目名称:mozilla-central.fgv,代码行数:19,代码来源:nsPluginTags.cpp
示例6: printf_stderr
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;
}
开发者ID:mbuttu,项目名称:mozilla-central,代码行数:51,代码来源:AnimationCommon.cpp
示例7: 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;
}
开发者ID:ConradIrwin,项目名称:gecko-dev,代码行数:53,代码来源:nsTextToSubURI.cpp
示例8: readUntil
/**
* Consume characters until you find one contained in given
* input set.
*
* @update gess 3/25/98
* @param
* @return error code
*/
int CScanner::readUntil(nsAFlatCString& aString,nsAFlatCString& aTerminalSet,bool addTerminal){
char theChar=0;
int result=kNoError;
while(kNoError == result) {
result=getChar(theChar);
if(kNoError==result) {
int pos=aTerminalSet.FindChar(theChar);
if(kNotFound!=pos) {
if(addTerminal)
aString+=theChar;
else push(theChar);
break;
}
else aString+=theChar;
}
}
return result;
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:27,代码来源:CScanner.cpp
示例9: 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;
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:37,代码来源:TestUConv.cpp
示例10: if
nsresult
nsHttpChannelAuthProvider::GetCredentialsForChallenge(const char *challenge,
const char *authType,
bool proxyAuth,
nsIHttpAuthenticator *auth,
nsAFlatCString &creds)
{
LOG(("nsHttpChannelAuthProvider::GetCredentialsForChallenge "
"[this=%p channel=%p proxyAuth=%d challenges=%s]\n",
this, mAuthChannel, proxyAuth, challenge));
// this getter never fails
nsHttpAuthCache *authCache = gHttpHandler->AuthCache();
uint32_t authFlags;
nsresult rv = auth->GetAuthFlags(&authFlags);
if (NS_FAILED(rv)) return rv;
nsCAutoString realm;
ParseRealm(challenge, realm);
// if no realm, then use the auth type as the realm. ToUpperCase so the
// ficticious realm stands out a bit more.
// XXX this will cause some single signon misses!
// XXX this was meant to be used with NTLM, which supplies no realm.
/*
if (realm.IsEmpty()) {
realm = authType;
ToUpperCase(realm);
}
*/
// set informations that depend on whether
// we're authenticating against a proxy
// or a webserver
const char *host;
int32_t port;
nsHttpAuthIdentity *ident;
nsCAutoString path, scheme;
bool identFromURI = false;
nsISupports **continuationState;
rv = GetAuthorizationMembers(proxyAuth, scheme, host, port,
path, ident, continuationState);
if (NS_FAILED(rv)) return rv;
if (!proxyAuth) {
// if this is the first challenge, then try using the identity
// specified in the URL.
if (mIdent.IsEmpty()) {
GetIdentityFromURI(authFlags, mIdent);
identFromURI = !mIdent.IsEmpty();
}
}
//
// if we already tried some credentials for this transaction, then
// we need to possibly clear them from the cache, unless the credentials
// in the cache have changed, in which case we'd want to give them a
// try instead.
//
nsHttpAuthEntry *entry = nullptr;
authCache->GetAuthEntryForDomain(scheme.get(), host, port,
realm.get(), &entry);
// hold reference to the auth session state (in case we clear our
// reference to the entry).
nsCOMPtr<nsISupports> sessionStateGrip;
if (entry)
sessionStateGrip = entry->mMetaData;
// for digest auth, maybe our cached nonce value simply timed out...
bool identityInvalid;
nsISupports *sessionState = sessionStateGrip;
rv = auth->ChallengeReceived(mAuthChannel,
challenge,
proxyAuth,
&sessionState,
&*continuationState,
&identityInvalid);
sessionStateGrip.swap(sessionState);
if (NS_FAILED(rv)) return rv;
LOG((" identity invalid = %d\n", identityInvalid));
if (identityInvalid) {
if (entry) {
if (ident->Equals(entry->Identity())) {
LOG((" clearing bad auth cache entry\n"));
// ok, we've already tried this user identity, so clear the
// corresponding entry from the auth cache.
authCache->ClearAuthEntry(scheme.get(), host,
port, realm.get());
entry = nullptr;
ident->Clear();
}
else if (!identFromURI ||
nsCRT::strcmp(ident->User(),
entry->Identity().User()) == 0) {
LOG((" taking identity from auth cache\n"));
//.........这里部分代码省略.........
开发者ID:Type-of-Tool,项目名称:ExMail,代码行数:101,代码来源:nsHttpChannelAuthProvider.cpp
示例11: 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],
//.........这里部分代码省略.........
开发者ID:catlee,项目名称:mozilla-central,代码行数:101,代码来源:nsPermissionManager.cpp
示例12: EnableLogging
void
logging::Enable(const nsAFlatCString& aModules)
{
EnableLogging(aModules.get());
}
开发者ID:EFForg,项目名称:mozilla-central-httpse-tests,代码行数:5,代码来源:Logging.cpp
示例13: SetData
//----------------------------------------------------------------------------------------
void nsPersistentFileDescriptor::SetData(const nsAFlatCString& inData)
//----------------------------------------------------------------------------------------
{
mDescriptorString.CopyFrom(inData.get(), inData.Length());
}
开发者ID:bringhurst,项目名称:vbox,代码行数:6,代码来源:nsFileSpec.cpp
示例14: GetData
//----------------------------------------------------------------------------------------
void nsPersistentFileDescriptor::GetData(nsAFlatCString& outData) const
//----------------------------------------------------------------------------------------
{
outData.Assign(mDescriptorString, mDescriptorString.Length());
}
开发者ID:bringhurst,项目名称:vbox,代码行数:6,代码来源:nsFileSpec.cpp
注:本文中的nsAFlatCString类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论