本文整理汇总了C++中nsCString::StripWhitespace方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCString::StripWhitespace方法的具体用法?C++ nsCString::StripWhitespace怎么用?C++ nsCString::StripWhitespace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsCString
的用法示例。
在下文中一共展示了nsCString::StripWhitespace方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ToLowerCase
void
nsGnomeVFSProtocolHandler::InitSupportedProtocolsPref(nsIPrefBranch *prefs)
{
// read preferences
nsresult rv = prefs->GetCharPref(MOZ_GNOMEVFS_SUPPORTED_PROTOCOLS,
getter_Copies(mSupportedProtocols));
if (NS_SUCCEEDED(rv)) {
mSupportedProtocols.StripWhitespace();
ToLowerCase(mSupportedProtocols);
}
else
mSupportedProtocols.Assign("smb:,sftp:"); // use defaults
LOG(("gnomevfs: supported protocols \"%s\"\n", mSupportedProtocols.get()));
}
示例2: ToLowerCase
void
nsGIOProtocolHandler::InitSupportedProtocolsPref(nsIPrefBranch *prefs)
{
// Get user preferences to determine which protocol is supported.
// Gvfs/GIO has a set of supported protocols like obex, network, archive,
// computer, dav, cdda, gphoto2, trash, etc. Some of these seems to be
// irrelevant to process by browser. By default accept only smb and sftp
// protocols so far.
nsresult rv = prefs->GetCharPref(MOZ_GIO_SUPPORTED_PROTOCOLS,
getter_Copies(mSupportedProtocols));
if (NS_SUCCEEDED(rv)) {
mSupportedProtocols.StripWhitespace();
ToLowerCase(mSupportedProtocols);
}
else
mSupportedProtocols.AssignLiteral("smb:,sftp:"); // use defaults
LOG(("gio: supported protocols \"%s\"\n", mSupportedProtocols.get()));
}
示例3: strchr
nsresult
nsDataHandler::ParseURI(nsCString& spec,
nsCString& contentType,
nsCString& contentCharset,
bool& isBase64,
nsCString& dataBuffer,
nsCString& hashRef) {
isBase64 = false;
// move past "data:"
char *buffer = (char *) PL_strcasestr(spec.BeginWriting(), "data:");
if (!buffer) {
// malformed uri
return NS_ERROR_MALFORMED_URI;
}
buffer += 5;
// First, find the start of the data
char *comma = strchr(buffer, ',');
if (!comma)
return NS_ERROR_MALFORMED_URI;
*comma = '\0';
// determine if the data is base64 encoded.
char *base64 = PL_strcasestr(buffer, ";base64");
if (base64) {
isBase64 = true;
*base64 = '\0';
}
if (comma == buffer) {
// nothing but data
contentType.AssignLiteral("text/plain");
contentCharset.AssignLiteral("US-ASCII");
} else {
// everything else is content type
char *semiColon = (char *) strchr(buffer, ';');
if (semiColon)
*semiColon = '\0';
if (semiColon == buffer || base64 == buffer) {
// there is no content type, but there are other parameters
contentType.AssignLiteral("text/plain");
} else {
contentType = buffer;
ToLowerCase(contentType);
}
if (semiColon) {
char *charset = PL_strcasestr(semiColon + 1, "charset=");
if (charset)
contentCharset = charset + sizeof("charset=") - 1;
*semiColon = ';';
}
}
*comma = ',';
if (isBase64)
*base64 = ';';
contentType.StripWhitespace();
contentCharset.StripWhitespace();
// Split encoded data from terminal "#ref" (if present)
char *data = comma + 1;
char *hash = strchr(data, '#');
if (!hash) {
dataBuffer.Assign(data);
hashRef.Truncate();
} else {
dataBuffer.Assign(data, hash - data);
hashRef.Assign(hash);
}
return NS_OK;
}
示例4: strchr
nsresult
nsDataHandler::ParseURI(nsCString& spec,
nsCString& contentType,
nsCString& contentCharset,
bool& isBase64,
nsCString& dataBuffer,
nsCString& hashRef) {
isBase64 = false;
// move past "data:"
char *buffer = (char *) PL_strcasestr(spec.BeginWriting(), "data:");
if (!buffer) {
// malformed uri
return NS_ERROR_MALFORMED_URI;
}
buffer += 5;
// First, find the start of the data
char *comma = strchr(buffer, ',');
char *hash = strchr(buffer, '#');
if (!comma || (hash && hash < comma))
return NS_ERROR_MALFORMED_URI;
*comma = '\0';
// determine if the data is base64 encoded.
char *base64 = PL_strcasestr(buffer, BASE64_EXTENSION);
if (base64) {
char *beyond = base64 + strlen(BASE64_EXTENSION);
// per the RFC 2397 grammar, "base64" MUST be followed by a comma
// previously substituted by '\0', but we also allow it in between
// parameters so a subsequent ";" is ok as well (this deals with
// *broken* data URIs, see bug 781693 for an example)
if (*beyond == '\0' || *beyond == ';') {
isBase64 = true;
*base64 = '\0';
}
}
if (comma == buffer) {
// nothing but data
contentType.AssignLiteral("text/plain");
contentCharset.AssignLiteral("US-ASCII");
} else {
// everything else is content type
char *semiColon = (char *) strchr(buffer, ';');
if (semiColon)
*semiColon = '\0';
if (semiColon == buffer || base64 == buffer) {
// there is no content type, but there are other parameters
contentType.AssignLiteral("text/plain");
} else {
contentType = buffer;
ToLowerCase(contentType);
}
if (semiColon) {
char *charset = PL_strcasestr(semiColon + 1, "charset=");
if (charset)
contentCharset = charset + sizeof("charset=") - 1;
*semiColon = ';';
}
}
*comma = ',';
if (isBase64)
*base64 = ';';
contentType.StripWhitespace();
contentCharset.StripWhitespace();
// Split encoded data from terminal "#ref" (if present)
char *data = comma + 1;
if (!hash) {
dataBuffer.Assign(data);
hashRef.Truncate();
} else {
dataBuffer.Assign(data, hash - data);
hashRef.Assign(hash);
}
return NS_OK;
}