本文整理汇总了C++中nsACString类的典型用法代码示例。如果您正苦于以下问题:C++ nsACString类的具体用法?C++ nsACString怎么用?C++ nsACString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了nsACString类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1:
/* static */
bool
VorbisDataDecoder::IsVorbis(const nsACString& aMimeType)
{
return aMimeType.EqualsLiteral("audio/vorbis");
}
开发者ID:alphan102,项目名称:gecko-dev,代码行数:6,代码来源:VorbisDecoder.cpp
示例2: GetStoreType
NS_IMETHODIMP nsMsgMaildirStore::GetStoreType(nsACString& aType)
{
aType.AssignLiteral("maildir");
return NS_OK;
}
开发者ID:libertyernie,项目名称:marine,代码行数:5,代码来源:nsMsgMaildirStore.cpp
示例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;
}
开发者ID:at13,项目名称:mozilla-central,代码行数:64,代码来源:nsURLHelper.cpp
示例4:
NS_IMETHODIMP
csTpMessagePart::GetKey(nsACString &aKey)
{
aKey.Assign(m_Key);
return NS_OK;
}
开发者ID:psunkari,项目名称:spicebird,代码行数:6,代码来源:csTpChannelInterfaceMessages.cpp
示例5:
NS_IMETHODIMP
nsMIMEInfoAndroid::GetMIMEType(nsACString & aMIMEType)
{
aMIMEType.Assign(mType);
return NS_OK;
}
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:6,代码来源:nsMIMEInfoAndroid.cpp
示例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;
}
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:82,代码来源:nsDSURIContentListener.cpp
示例7:
NS_IMETHODIMP
nsResProtocolHandler::GetScheme(nsACString &result)
{
result.AssignLiteral("resource");
return NS_OK;
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:6,代码来源:nsResProtocolHandler.cpp
示例8:
NS_IMETHODIMP
nsBlobProtocolHandler::GetScheme(nsACString &result)
{
result.AssignLiteral(BLOBURI_SCHEME);
return NS_OK;
}
开发者ID:bgrins,项目名称:gecko-dev,代码行数:6,代码来源:nsHostObjectProtocolHandler.cpp
示例9:
NS_IMETHODIMP
sbLocalDatabaseLibraryFactory::GetContractID(nsACString& aContractID)
{
aContractID.AssignLiteral(SB_LOCALDATABASE_LIBRARYFACTORY_CONTRACTID);
return NS_OK;
}
开发者ID:Brijen,项目名称:nightingale-hacking,代码行数:6,代码来源:sbLocalDatabaseLibraryFactory.cpp
示例10: GetName
NS_IMETHOD
GetName(nsACString& aName) override
{
aName.AssignLiteral("ReleasingTimerHolder");
return NS_OK;
}
开发者ID:bgrins,项目名称:gecko-dev,代码行数:6,代码来源:nsHostObjectProtocolHandler.cpp
示例11:
NS_IMETHODIMP
NullHttpChannel::GetResponseHeader(const nsACString & header, nsACString & _retval)
{
_retval.Truncate();
return NS_ERROR_NOT_IMPLEMENTED;
}
开发者ID:,项目名称:,代码行数:6,代码来源:
示例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;
}
开发者ID:mxOBS,项目名称:deb-pkg_icedove,代码行数:95,代码来源:nsLDAPService.cpp
示例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;
}
开发者ID:mxOBS,项目名称:deb-pkg_icedove,代码行数:90,代码来源:nsLDAPService.cpp
示例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;
}
开发者ID:,项目名称:,代码行数:74,代码来源:
示例15: GetListId
NS_IMETHODIMP nsMsgFilterList::GetListId(nsACString &aListId) {
aListId.Assign(m_listId);
return NS_OK;
}
开发者ID:mozilla,项目名称:releases-comm-central,代码行数:4,代码来源:nsMsgFilterList.cpp
示例16: GetPrimaryFieldType
/* readonly attribute ACString primaryFieldType; */
NS_IMETHODIMP zoteroWinWordApplication::GetPrimaryFieldType(nsACString & aPrimaryFieldType)
{
aPrimaryFieldType.AppendLiteral("Field");
return NS_OK;
}
开发者ID:simonster,项目名称:zotero-word-for-windows-integration,代码行数:6,代码来源:zoteroWinWordApplication.cpp
示例17: path
void
MozMtpDatabase::CreateEntryForFileAndNotify(const nsACString& aPath,
DeviceStorageFile* aFile,
RefCountedMtpServer* aMtpServer)
{
// Find the StorageID that this path corresponds to.
nsCString remainder;
MtpStorageID storageID = FindStorageIDFor(aPath, remainder);
if (storageID == 0) {
// The path in question isn't for a storage area we're monitoring.
nsCString path(aPath);
return;
}
bool exists = false;
aFile->mFile->Exists(&exists);
if (!exists) {
// File doesn't exist, no sense telling MTP about it.
// This could happen if Device Storage created and deleted a file right
// away. Since the notifications wind up being async, the file might
// not exist any more.
return;
}
// Now walk the remaining directories, finding or creating as required.
MtpObjectHandle parent = MTP_PARENT_ROOT;
bool doFind = true;
int32_t offset = aPath.Length() - remainder.Length();
int32_t slash;
do {
nsDependentCSubstring component;
slash = aPath.FindChar('/', offset);
if (slash == kNotFound) {
component.Rebind(aPath, 0, aPath.Length());
} else {
component.Rebind(aPath, 0 , slash);
}
if (doFind) {
MtpObjectHandle entryHandle = FindEntryByPath(component);
if (entryHandle != 0) {
// We found an entry.
parent = entryHandle;
offset = slash + 1 ;
continue;
}
}
// We've got a directory component that doesn't exist. This means that all
// further subdirectories won't exist either, so we can skip searching
// for them.
doFind = false;
// This directory and the file don't exist, create them
RefPtr<DbEntry> entry = new DbEntry;
entry->mStorageID = storageID;
entry->mObjectName = Substring(aPath, offset, slash - offset);
entry->mParent = parent;
entry->mDisplayName = entry->mObjectName;
entry->mPath = component;
if (slash == kNotFound) {
// No slash - this is the file component
entry->mObjectFormat = MTP_FORMAT_DEFINED;
int64_t fileSize = 0;
aFile->mFile->GetFileSize(&fileSize);
entry->mObjectSize = fileSize;
// Note: Even though PRTime records usec, GetLastModifiedTime returns
// msecs.
PRTime dateModifiedMsecs;
aFile->mFile->GetLastModifiedTime(&dateModifiedMsecs);
entry->mDateModified = dateModifiedMsecs / PR_MSEC_PER_SEC;
} else {
// Found a slash, this makes this a directory component
entry->mObjectFormat = MTP_FORMAT_ASSOCIATION;
entry->mObjectSize = 0;
time(&entry->mDateModified);
}
entry->mDateCreated = entry->mDateModified;
entry->mDateAdded = entry->mDateModified;
AddEntryAndNotify(entry, aMtpServer);
MTP_LOG("About to call sendObjectAdded Handle 0x%08x file %s", entry->mHandle, entry->mPath.get());
parent = entry->mHandle;
offset = slash + 1;
} while (slash != kNotFound);
return;
}
开发者ID:kapeels,项目名称:gecko-dev,代码行数:96,代码来源:MozMtpDatabase.cpp
示例18: GetSecondaryFieldType
/* readonly attribute ACString secondaryFieldType; */
NS_IMETHODIMP zoteroWinWordApplication::GetSecondaryFieldType(nsACString & aSecondaryFieldType)
{
aSecondaryFieldType.AppendLiteral("Bookmark");
return NS_OK;
}
开发者ID:simonster,项目名称:zotero-word-for-windows-integration,代码行数:6,代码来源:zoteroWinWordApplication.cpp
示例19:
NS_IMETHODIMP
nsGIOProtocolHandler::GetScheme(nsACString &aScheme)
{
aScheme.Assign(MOZ_GIO_SCHEME);
return NS_OK;
}
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:6,代码来源:nsGIOProtocolHandler.cpp
示例20: CompareWebGLExtensionName
static bool
CompareWebGLExtensionName(const nsACString& name, const char *other)
{
return name.Equals(other, nsCaseInsensitiveCStringComparator());
}
开发者ID:JuannyWang,项目名称:gecko-dev,代码行数:5,代码来源:WebGLContextExtensions.cpp
注:本文中的nsACString类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论