本文整理汇总了C++中nsACString类的典型用法代码示例。如果您正苦于以下问题:C++ nsACString类的具体用法?C++ nsACString怎么用?C++ nsACString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了nsACString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/* static */
bool
VorbisDataDecoder::IsVorbis(const nsACString& aMimeType)
{
return aMimeType.EqualsLiteral("audio/vorbis");
}
示例2: GetStoreType
NS_IMETHODIMP nsMsgMaildirStore::GetStoreType(nsACString& aType)
{
aType.AssignLiteral("maildir");
return NS_OK;
}
示例3: net_ParseFileURL
nsresult
net_ParseFileURL(const nsACString &inURL,
nsACString &outDirectory,
nsACString &outFileBaseName,
nsACString &outFileExtension)
{
nsresult rv;
outDirectory.Truncate();
outFileBaseName.Truncate();
outFileExtension.Truncate();
const nsPromiseFlatCString &flatURL = PromiseFlatCString(inURL);
const char *url = flatURL.get();
uint32_t schemeBeg, schemeEnd;
rv = net_ExtractURLScheme(flatURL, &schemeBeg, &schemeEnd, nullptr);
if (NS_FAILED(rv)) return rv;
if (strncmp(url + schemeBeg, "file", schemeEnd - schemeBeg) != 0) {
NS_ERROR("must be a file:// url");
return NS_ERROR_UNEXPECTED;
}
nsIURLParser *parser = net_GetNoAuthURLParser();
NS_ENSURE_TRUE(parser, NS_ERROR_UNEXPECTED);
uint32_t pathPos, filepathPos, directoryPos, basenamePos, extensionPos;
int32_t pathLen, filepathLen, directoryLen, basenameLen, extensionLen;
// invoke the parser to extract the URL path
rv = parser->ParseURL(url, flatURL.Length(),
nullptr, nullptr, // don't care about scheme
nullptr, nullptr, // don't care about authority
&pathPos, &pathLen);
if (NS_FAILED(rv)) return rv;
// invoke the parser to extract filepath from the path
rv = parser->ParsePath(url + pathPos, pathLen,
&filepathPos, &filepathLen,
nullptr, nullptr, // don't care about query
nullptr, nullptr); // don't care about ref
if (NS_FAILED(rv)) return rv;
filepathPos += pathPos;
// invoke the parser to extract the directory and filename from filepath
rv = parser->ParseFilePath(url + filepathPos, filepathLen,
&directoryPos, &directoryLen,
&basenamePos, &basenameLen,
&extensionPos, &extensionLen);
if (NS_FAILED(rv)) return rv;
if (directoryLen > 0)
outDirectory = Substring(inURL, filepathPos + directoryPos, directoryLen);
if (basenameLen > 0)
outFileBaseName = Substring(inURL, filepathPos + basenamePos, basenameLen);
if (extensionLen > 0)
outFileExtension = Substring(inURL, filepathPos + extensionPos, extensionLen);
// since we are using a no-auth url parser, there will never be a host
// XXX not strictly true... file://localhost/foo/bar.html is a valid URL
return NS_OK;
}
示例4:
NS_IMETHODIMP
csTpMessagePart::GetKey(nsACString &aKey)
{
aKey.Assign(m_Key);
return NS_OK;
}
示例5:
NS_IMETHODIMP
nsMIMEInfoAndroid::GetMIMEType(nsACString & aMIMEType)
{
aMIMEType.Assign(mType);
return NS_OK;
}
示例6: copy
NS_IMETHODIMP
nsDSURIContentListener::DoContent(const nsACString& aContentType,
bool aIsContentPreferred,
nsIRequest* aRequest,
nsIStreamListener** aContentHandler,
bool* aAbortProcess)
{
nsresult rv;
NS_ENSURE_ARG_POINTER(aContentHandler);
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
// Check whether X-Frame-Options permits us to load this content in an
// iframe and abort the load (unless we've disabled x-frame-options
// checking).
if (!CheckFrameOptions(aRequest)) {
*aAbortProcess = true;
return NS_OK;
}
*aAbortProcess = false;
// determine if the channel has just been retargeted to us...
nsLoadFlags loadFlags = 0;
nsCOMPtr<nsIChannel> aOpenedChannel = do_QueryInterface(aRequest);
if (aOpenedChannel) {
aOpenedChannel->GetLoadFlags(&loadFlags);
}
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) {
// XXX: Why does this not stop the content too?
mDocShell->Stop(nsIWebNavigation::STOP_NETWORK);
mDocShell->SetLoadType(aIsContentPreferred ? LOAD_LINK : LOAD_NORMAL);
}
// In case of multipart jpeg request (mjpeg) we don't really want to
// create new viewer since the one we already have is capable of
// rendering multipart jpeg correctly (see bug 625012)
nsCOMPtr<nsIChannel> baseChannel;
if (nsCOMPtr<nsIMultiPartChannel> mpchan = do_QueryInterface(aRequest)) {
mpchan->GetBaseChannel(getter_AddRefs(baseChannel));
}
bool reuseCV = baseChannel && baseChannel == mExistingJPEGRequest &&
aContentType.EqualsLiteral("image/jpeg");
if (mExistingJPEGStreamListener && reuseCV) {
RefPtr<nsIStreamListener> copy(mExistingJPEGStreamListener);
copy.forget(aContentHandler);
rv = NS_OK;
} else {
rv = mDocShell->CreateContentViewer(aContentType, aRequest, aContentHandler);
if (NS_SUCCEEDED(rv) && reuseCV) {
mExistingJPEGStreamListener = *aContentHandler;
} else {
mExistingJPEGStreamListener = nullptr;
}
mExistingJPEGRequest = baseChannel;
}
if (rv == NS_ERROR_REMOTE_XUL) {
aRequest->Cancel(rv);
*aAbortProcess = true;
return NS_OK;
}
if (NS_FAILED(rv)) {
// we don't know how to handle the content
*aContentHandler = nullptr;
return rv;
}
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) {
nsCOMPtr<nsPIDOMWindowOuter> domWindow =
mDocShell ? mDocShell->GetWindow() : nullptr;
NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
domWindow->Focus();
}
return NS_OK;
}
示例7:
NS_IMETHODIMP
nsResProtocolHandler::GetScheme(nsACString &result)
{
result.AssignLiteral("resource");
return NS_OK;
}
示例8:
NS_IMETHODIMP
nsBlobProtocolHandler::GetScheme(nsACString &result)
{
result.AssignLiteral(BLOBURI_SCHEME);
return NS_OK;
}
示例9:
NS_IMETHODIMP
sbLocalDatabaseLibraryFactory::GetContractID(nsACString& aContractID)
{
aContractID.AssignLiteral(SB_LOCALDATABASE_LIBRARYFACTORY_CONTRACTID);
return NS_OK;
}
示例10: GetName
NS_IMETHOD
GetName(nsACString& aName) override
{
aName.AssignLiteral("ReleasingTimerHolder");
return NS_OK;
}
示例11:
NS_IMETHODIMP
NullHttpChannel::GetResponseHeader(const nsACString & header, nsACString & _retval)
{
_retval.Truncate();
return NS_ERROR_NOT_IMPLEMENTED;
}
示例12: ParseDn
// Parse a distinguished name (DN) and returns the relative DN,
// base DN and the list of attributes that make up the relative DN.
NS_IMETHODIMP nsLDAPService::ParseDn(const char *aDn,
nsACString &aRdn,
nsACString &aBaseDn,
uint32_t *aRdnCount,
char ***aRdnAttrs)
{
NS_ENSURE_ARG_POINTER(aRdnCount);
NS_ENSURE_ARG_POINTER(aRdnAttrs);
// explode the DN
char **dnComponents = ldap_explode_dn(aDn, 0);
if (!dnComponents) {
NS_ERROR("nsLDAPService::ParseDn: parsing DN failed");
return NS_ERROR_UNEXPECTED;
}
// count DN components
if (!*dnComponents || !*(dnComponents + 1)) {
NS_ERROR("nsLDAPService::ParseDn: DN has too few components");
ldap_value_free(dnComponents);
return NS_ERROR_UNEXPECTED;
}
// get the base DN
nsAutoCString baseDn(nsDependentCString(*(dnComponents + 1)));
for (char **component = dnComponents + 2; *component; ++component) {
baseDn.AppendLiteral(",");
baseDn.Append(nsDependentCString(*component));
}
// explode the RDN
char **rdnComponents = ldap_explode_rdn(*dnComponents, 0);
if (!rdnComponents) {
NS_ERROR("nsLDAPService::ParseDn: parsing RDN failed");
ldap_value_free(dnComponents);
return NS_ERROR_UNEXPECTED;
}
// count RDN attributes
uint32_t rdnCount = 0;
for (char **component = rdnComponents; *component; ++component)
++rdnCount;
if (rdnCount < 1) {
NS_ERROR("nsLDAPService::ParseDn: RDN has too few components");
ldap_value_free(dnComponents);
ldap_value_free(rdnComponents);
return NS_ERROR_UNEXPECTED;
}
// get the RDN attribute names
char **attrNameArray = static_cast<char **>(
nsMemory::Alloc(rdnCount * sizeof(char *)));
if (!attrNameArray) {
NS_ERROR("nsLDAPService::ParseDn: out of memory ");
ldap_value_free(dnComponents);
ldap_value_free(rdnComponents);
return NS_ERROR_OUT_OF_MEMORY;
}
uint32_t index = 0;
for (char **component = rdnComponents; *component; ++component) {
uint32_t len = 0;
char *p;
for (p = *component; *p != '\0' && *p != '='; ++p)
++len;
if (*p != '=') {
NS_ERROR("nsLDAPService::parseDn: "
"could not find '=' in RDN component");
ldap_value_free(dnComponents);
ldap_value_free(rdnComponents);
return NS_ERROR_UNEXPECTED;
}
if (!(attrNameArray[index] = (char*)NS_Alloc(len + 1))) {
NS_ERROR("nsLDAPService::ParseDn: out of memory ");
ldap_value_free(dnComponents);
ldap_value_free(rdnComponents);
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(index, attrNameArray);
return NS_ERROR_OUT_OF_MEMORY;
}
memcpy(attrNameArray[index], *component, len);
*(attrNameArray[index] + len) = '\0';
++index;
}
// perform assignments
aRdn.Assign(*dnComponents);
aBaseDn.Assign(baseDn);
*aRdnCount = rdnCount;
*aRdnAttrs = attrNameArray;
ldap_value_free(dnComponents);
ldap_value_free(rdnComponents);
return NS_OK;
}
示例13: CreateFilter
/* AString createFilter (in unsigned long aMaxSize, in AString aPattern, in AString aPrefix, in AString aSuffix, in AString aAttr, in AString aValue); */
NS_IMETHODIMP nsLDAPService::CreateFilter(uint32_t aMaxSize,
const nsACString & aPattern,
const nsACString & aPrefix,
const nsACString & aSuffix,
const nsACString & aAttr,
const nsACString & aValue,
nsACString & _retval)
{
if (!aMaxSize) {
return NS_ERROR_INVALID_ARG;
}
// figure out how big of an array we're going to need for the tokens,
// including a trailing NULL, and allocate space for it.
//
const char *iter = aValue.BeginReading();
const char *iterEnd = aValue.EndReading();
uint32_t numTokens = CountTokens(iter, iterEnd);
char **valueWords;
valueWords = static_cast<char **>(nsMemory::Alloc((numTokens + 1) *
sizeof(char *)));
if (!valueWords) {
return NS_ERROR_OUT_OF_MEMORY;
}
// build the array of values
//
uint32_t curToken = 0;
while (iter != iterEnd && curToken < numTokens ) {
valueWords[curToken] = NextToken(&iter, &iterEnd);
if ( !valueWords[curToken] ) {
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(curToken, valueWords);
return NS_ERROR_OUT_OF_MEMORY;
}
curToken++;
}
valueWords[numTokens] = 0; // end of array signal to LDAP C SDK
// make buffer to be used for construction
//
char *buffer = static_cast<char *>(nsMemory::Alloc(aMaxSize * sizeof(char)));
if (!buffer) {
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(numTokens, valueWords);
return NS_ERROR_OUT_OF_MEMORY;
}
// create the filter itself
//
nsresult rv;
int result = ldap_create_filter(buffer, aMaxSize,
const_cast<char *>(PromiseFlatCString(aPattern).get()),
const_cast<char *>(PromiseFlatCString(aPrefix).get()),
const_cast<char *>(PromiseFlatCString(aSuffix).get()),
const_cast<char *>(PromiseFlatCString(aAttr).get()),
const_cast<char *>(PromiseFlatCString(aValue).get()),
valueWords);
switch (result) {
case LDAP_SUCCESS:
rv = NS_OK;
break;
case LDAP_SIZELIMIT_EXCEEDED:
PR_LOG(gLDAPLogModule, PR_LOG_DEBUG,
("nsLDAPService::CreateFilter(): "
"filter longer than max size of %d generated",
aMaxSize));
rv = NS_ERROR_NOT_AVAILABLE;
break;
case LDAP_PARAM_ERROR:
rv = NS_ERROR_INVALID_ARG;
break;
default:
NS_ERROR("nsLDAPService::CreateFilter(): ldap_create_filter() "
"returned unexpected error");
rv = NS_ERROR_UNEXPECTED;
break;
}
_retval.Assign(buffer);
// done with the array and the buffer
//
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(numTokens, valueWords);
nsMemory::Free(buffer);
return rv;
}
示例14: PrepareAcceptLanguages
/**
* Allocates a C string into that contains a ISO 639 language list
* notated with HTTP "q" values for output with a HTTP Accept-Language
* header. Previous q values will be stripped because the order of
* the langs imply the q value. The q values are calculated by dividing
* 1.0 amongst the number of languages present.
*
* Ex: passing: "en, ja"
* returns: "en,ja;q=0.5"
*
* passing: "en, ja, fr_CA"
* returns: "en,ja;q=0.7,fr_CA;q=0.3"
*/
static nsresult
PrepareAcceptLanguages(const char *i_AcceptLanguages, nsACString &o_AcceptLanguages)
{
if (!i_AcceptLanguages)
return NS_OK;
PRUint32 n, size, wrote;
double q, dec;
char *p, *p2, *token, *q_Accept, *o_Accept;
const char *comma;
PRInt32 available;
o_Accept = nsCRT::strdup(i_AcceptLanguages);
if (!o_Accept)
return NS_ERROR_OUT_OF_MEMORY;
for (p = o_Accept, n = size = 0; '\0' != *p; p++) {
if (*p == ',') n++;
size++;
}
available = size + ++n * 11 + 1;
q_Accept = new char[available];
if (!q_Accept) {
nsCRT::free(o_Accept);
return NS_ERROR_OUT_OF_MEMORY;
}
*q_Accept = '\0';
q = 1.0;
dec = q / (double) n;
n = 0;
p2 = q_Accept;
for (token = nsCRT::strtok(o_Accept, ",", &p);
token != (char *) 0;
token = nsCRT::strtok(p, ",", &p))
{
token = net_FindCharNotInSet(token, HTTP_LWS);
char* trim;
trim = net_FindCharInSet(token, ";" HTTP_LWS);
if (trim != (char*)0) // remove "; q=..." if present
*trim = '\0';
if (*token != '\0') {
comma = n++ != 0 ? "," : ""; // delimiter if not first item
PRUint32 u = QVAL_TO_UINT(q);
if (u < 10)
wrote = PR_snprintf(p2, available, "%s%s;q=0.%u", comma, token, u);
else
wrote = PR_snprintf(p2, available, "%s%s", comma, token);
q -= dec;
p2 += wrote;
available -= wrote;
NS_ASSERTION(available > 0, "allocated string not long enough");
}
}
nsCRT::free(o_Accept);
o_AcceptLanguages.Assign((const char *) q_Accept);
delete [] q_Accept;
return NS_OK;
}
示例15: GetListId
NS_IMETHODIMP nsMsgFilterList::GetListId(nsACString &aListId) {
aListId.Assign(m_listId);
return NS_OK;
}