本文整理汇总了C++中nsACString::Assign方法的典型用法代码示例。如果您正苦于以下问题:C++ nsACString::Assign方法的具体用法?C++ nsACString::Assign怎么用?C++ nsACString::Assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsACString
的用法示例。
在下文中一共展示了nsACString::Assign方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2:
void
MediaEngineWebRTCMicrophoneSource::GetUUID(nsACString& aUUID) const
{
aUUID.Assign(mDeviceUUID);
return;
}
示例3:
NS_IMETHODIMP
nsGIOMimeApp::GetName(nsACString& aName)
{
aName.Assign(g_app_info_get_name(mApp));
return NS_OK;
}
示例4:
NS_CStringSetData(nsACString &aStr, const char *aData, uint32_t aDataLength)
{
aStr.Assign(aData, aDataLength);
return NS_OK; // XXX report errors
}
示例5:
// who we're binding as
//
// readonly attribute AUTF8String bindName
//
NS_IMETHODIMP
nsLDAPConnection::GetBindName(nsACString& _retval)
{
_retval.Assign(mBindName);
return NS_OK;
}
示例6:
/* readonly attribute ACString platformVersion; */
NS_IMETHODIMP
EphyXULAppInfo::GetPlatformVersion(nsACString & aPlatformVersion)
{
aPlatformVersion.Assign ("1.9");
return NS_OK;
}
示例7:
NS_IMETHODIMP
nsGIOProtocolHandler::GetScheme(nsACString &aScheme)
{
aScheme.Assign(MOZ_GIO_SCHEME);
return NS_OK;
}
示例8: contextKey
nsresult
nsAboutCacheEntry::ParseURI(nsIURI *uri,
nsACString &storageName,
nsILoadContextInfo **loadInfo,
nsCString &enahnceID,
nsIURI **cacheUri)
{
//
// about:cache-entry?storage=[string]&contenxt=[string]&eid=[string]&uri=[string]
//
nsresult rv;
nsAutoCString path;
rv = uri->GetPath(path);
if (NS_FAILED(rv))
return rv;
nsACString::const_iterator keyBegin, keyEnd, valBegin, begin, end;
path.BeginReading(begin);
path.EndReading(end);
keyBegin = begin; keyEnd = end;
if (!FindInReadable(NS_LITERAL_CSTRING("?storage="), keyBegin, keyEnd))
return NS_ERROR_FAILURE;
valBegin = keyEnd; // the value of the storage key starts after the key
keyBegin = keyEnd; keyEnd = end;
if (!FindInReadable(NS_LITERAL_CSTRING("&context="), keyBegin, keyEnd))
return NS_ERROR_FAILURE;
storageName.Assign(Substring(valBegin, keyBegin));
valBegin = keyEnd; // the value of the context key starts after the key
keyBegin = keyEnd; keyEnd = end;
if (!FindInReadable(NS_LITERAL_CSTRING("&eid="), keyBegin, keyEnd))
return NS_ERROR_FAILURE;
nsAutoCString contextKey(Substring(valBegin, keyBegin));
valBegin = keyEnd; // the value of the eid key starts after the key
keyBegin = keyEnd; keyEnd = end;
if (!FindInReadable(NS_LITERAL_CSTRING("&uri="), keyBegin, keyEnd))
return NS_ERROR_FAILURE;
enahnceID.Assign(Substring(valBegin, keyBegin));
valBegin = keyEnd; // the value of the uri key starts after the key
nsAutoCString uriSpec(Substring(valBegin, end)); // uri is the last one
// Uf... parsing done, now get some objects from it...
nsCOMPtr<nsILoadContextInfo> info =
CacheFileUtils::ParseKey(contextKey);
if (!info)
return NS_ERROR_FAILURE;
info.forget(loadInfo);
rv = NS_NewURI(cacheUri, uriSpec);
if (NS_FAILED(rv))
return rv;
return NS_OK;
}
示例9:
NS_IMETHODIMP
nsMIMEInfoAndroid::GetMIMEType(nsACString & aMIMEType)
{
aMIMEType.Assign(mType);
return NS_OK;
}
示例10:
NS_IMETHODIMP
csTpMessagePart::GetKey(nsACString &aKey)
{
aKey.Assign(m_Key);
return NS_OK;
}
示例11:
NS_IMETHODIMP
csTpLocation::GetKey(nsACString &aKey)
{
aKey.Assign(m_Key);
return NS_OK;
}
示例12: GetListId
NS_IMETHODIMP nsMsgFilterList::GetListId(nsACString &aListId) {
aListId.Assign(m_listId);
return NS_OK;
}
示例13: 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;
}
示例14: PromiseFlatCString
// aOffset should be added to aCharsetStart and aCharsetEnd if this
// function sets them.
static void
net_ParseMediaType(const nsACString &aMediaTypeStr,
nsACString &aContentType,
nsACString &aContentCharset,
int32_t aOffset,
bool *aHadCharset,
int32_t *aCharsetStart,
int32_t *aCharsetEnd)
{
const nsCString& flatStr = PromiseFlatCString(aMediaTypeStr);
const char* start = flatStr.get();
const char* end = start + flatStr.Length();
// Trim LWS leading and trailing whitespace from type. We include '(' in
// the trailing trim set to catch media-type comments, which are not at all
// standard, but may occur in rare cases.
const char* type = net_FindCharNotInSet(start, end, HTTP_LWS);
const char* typeEnd = net_FindCharInSet(type, end, HTTP_LWS ";(");
const char* charset = "";
const char* charsetEnd = charset;
int32_t charsetParamStart = 0;
int32_t charsetParamEnd = 0;
// Iterate over parameters
bool typeHasCharset = false;
uint32_t paramStart = flatStr.FindChar(';', typeEnd - start);
if (paramStart != uint32_t(kNotFound)) {
// We have parameters. Iterate over them.
uint32_t curParamStart = paramStart + 1;
do {
uint32_t curParamEnd =
net_FindMediaDelimiter(flatStr, curParamStart, ';');
const char* paramName = net_FindCharNotInSet(start + curParamStart,
start + curParamEnd,
HTTP_LWS);
static const char charsetStr[] = "charset=";
if (PL_strncasecmp(paramName, charsetStr,
sizeof(charsetStr) - 1) == 0) {
charset = paramName + sizeof(charsetStr) - 1;
charsetEnd = start + curParamEnd;
typeHasCharset = true;
charsetParamStart = curParamStart - 1;
charsetParamEnd = curParamEnd;
}
curParamStart = curParamEnd + 1;
} while (curParamStart < flatStr.Length());
}
bool charsetNeedsQuotedStringUnescaping = false;
if (typeHasCharset) {
// Trim LWS leading and trailing whitespace from charset. We include
// '(' in the trailing trim set to catch media-type comments, which are
// not at all standard, but may occur in rare cases.
charset = net_FindCharNotInSet(charset, charsetEnd, HTTP_LWS);
if (*charset == '"') {
charsetNeedsQuotedStringUnescaping = true;
charsetEnd =
start + net_FindStringEnd(flatStr, charset - start, *charset);
charset++;
NS_ASSERTION(charsetEnd >= charset, "Bad charset parsing");
} else {
charsetEnd = net_FindCharInSet(charset, charsetEnd, HTTP_LWS ";(");
}
}
// if the server sent "*/*", it is meaningless, so do not store it.
// also, if type is the same as aContentType, then just update the
// charset. however, if charset is empty and aContentType hasn't
// changed, then don't wipe-out an existing aContentCharset. We
// also want to reject a mime-type if it does not include a slash.
// some servers give junk after the charset parameter, which may
// include a comma, so this check makes us a bit more tolerant.
if (type != typeEnd && strncmp(type, "*/*", typeEnd - type) != 0 &&
memchr(type, '/', typeEnd - type) != nullptr) {
// Common case here is that aContentType is empty
bool eq = !aContentType.IsEmpty() &&
aContentType.Equals(Substring(type, typeEnd),
nsCaseInsensitiveCStringComparator());
if (!eq) {
aContentType.Assign(type, typeEnd - type);
ToLowerCase(aContentType);
}
if ((!eq && *aHadCharset) || typeHasCharset) {
*aHadCharset = true;
if (charsetNeedsQuotedStringUnescaping) {
// parameters using the "quoted-string" syntax need
// backslash-escapes to be unescaped (see RFC 2616 Section 2.2)
aContentCharset.Truncate();
for (const char *c = charset; c != charsetEnd; c++) {
if (*c == '\\' && c + 1 != charsetEnd) {
// eat escape
c++;
}
//.........这里部分代码省略.........
示例15: GetRelativeToKey
NS_IMETHODIMP nsRelativeFilePref::GetRelativeToKey(nsACString& aRelativeToKey)
{
aRelativeToKey.Assign(mRelativeToKey);
return NS_OK;
}