本文整理汇总了C++中nsACString::First方法的典型用法代码示例。如果您正苦于以下问题:C++ nsACString::First方法的具体用法?C++ nsACString::First怎么用?C++ nsACString::First使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsACString
的用法示例。
在下文中一共展示了nsACString::First方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Resolve
NS_IMETHODIMP MsgMailNewsUrlBase::Resolve(const nsACString &relativePath, nsACString &result)
{
// only resolve anchor urls....i.e. urls which start with '#' against the mailnews url...
// everything else shouldn't be resolved against mailnews urls.
nsresult rv = NS_OK;
if (!relativePath.IsEmpty() && relativePath.First() == '#') // an anchor
return m_baseURL->Resolve(relativePath, result);
else
{
// if relativePath is a complete url with it's own scheme then allow it...
nsCOMPtr<nsIIOService> ioService =
mozilla::services::GetIOService();
NS_ENSURE_TRUE(ioService, NS_ERROR_UNEXPECTED);
nsAutoCString scheme;
rv = ioService->ExtractScheme(relativePath, scheme);
// if we have a fully qualified scheme then pass the relative path back as the result
if (NS_SUCCEEDED(rv) && !scheme.IsEmpty())
{
result = relativePath;
rv = NS_OK;
}
else
{
result.Truncate();
rv = NS_ERROR_FAILURE;
}
}
return rv;
}
示例2: SetSpec
NS_IMETHODIMP
RustURL::SetPath(const nsACString & aPath)
{
ENSURE_MUTABLE();
nsAutoCString path;
nsresult rv = GetPrePath(path);
if (NS_FAILED(rv)) {
return rv;
}
if (aPath.Length() > 0 && aPath.First() != '/') {
path.Append('/');
}
path.Append(aPath);
return SetSpec(path);
}
示例3: HostIgnoredByProxy
static bool HostIgnoredByProxy(const nsACString& aIgnore,
const nsACString& aHost)
{
if (aIgnore.Equals(aHost, nsCaseInsensitiveCStringComparator()))
return true;
if (aIgnore.First() == '*' &&
StringEndsWith(aHost, nsDependentCSubstring(aIgnore, 1),
nsCaseInsensitiveCStringComparator()))
return true;
int32_t mask = 128;
nsReadingIterator<char> start;
nsReadingIterator<char> slash;
nsReadingIterator<char> end;
aIgnore.BeginReading(start);
aIgnore.BeginReading(slash);
aIgnore.EndReading(end);
if (FindCharInReadable('/', slash, end)) {
++slash;
nsDependentCSubstring maskStr(slash, end);
nsAutoCString maskStr2(maskStr);
nsresult err;
mask = maskStr2.ToInteger(&err);
if (NS_FAILED(err)) {
mask = 128;
}
--slash;
} else {
slash = end;
}
nsDependentCSubstring ignoreStripped(start, slash);
PRIPv6Addr ignoreAddr, hostAddr;
if (!ConvertToIPV6Addr(ignoreStripped, &ignoreAddr, &mask) ||
!ConvertToIPV6Addr(aHost, &hostAddr, nullptr))
return false;
proxy_MaskIPv6Addr(ignoreAddr, mask);
proxy_MaskIPv6Addr(hostAddr, mask);
return memcmp(&ignoreAddr, &hostAddr, sizeof(PRIPv6Addr)) == 0;
}
示例4: GConfIgnoreHost
static PRBool GConfIgnoreHost(const nsACString& aIgnore,
const nsACString& aHost)
{
if (aIgnore.Equals(aHost, nsCaseInsensitiveCStringComparator()))
return PR_TRUE;
if (aIgnore.First() == '*' &&
StringEndsWith(aHost, nsDependentCSubstring(aIgnore, 1),
nsCaseInsensitiveCStringComparator()))
return PR_TRUE;
PRInt32 mask = 128;
nsReadingIterator<char> start;
nsReadingIterator<char> slash;
nsReadingIterator<char> end;
aIgnore.BeginReading(start);
aIgnore.BeginReading(slash);
aIgnore.EndReading(end);
if (FindCharInReadable('/', slash, end)) {
++slash;
nsDependentCSubstring maskStr(slash, end);
nsCAutoString maskStr2(maskStr);
PRInt32 err;
mask = maskStr2.ToInteger(&err);
if (err != 0) {
mask = 128;
}
--slash;
} else {
slash = end;
}
PRIPv6Addr ignoreAddr, hostAddr;
if (!ConvertToIPV6Addr(aIgnore, &ignoreAddr) ||
!ConvertToIPV6Addr(aHost, &hostAddr))
return PR_FALSE;
proxy_MaskIPv6Addr(ignoreAddr, mask);
proxy_MaskIPv6Addr(hostAddr, mask);
return memcmp(&ignoreAddr, &hostAddr, sizeof(PRIPv6Addr)) == 0;
}
示例5: ConvertFileToStringURI
nsresult nsDefaultURIFixup::ConvertFileToStringURI(const nsACString& aIn,
nsCString& aOut)
{
bool attemptFixup = false;
#if defined(XP_WIN)
// Check for \ in the url-string or just a drive (PC)
if(kNotFound != aIn.FindChar('\\') ||
(aIn.Length() == 2 && (aIn.Last() == ':' || aIn.Last() == '|')))
{
attemptFixup = true;
}
#elif defined(XP_UNIX)
// Check if it starts with / (UNIX)
if(aIn.First() == '/')
{
attemptFixup = true;
}
#else
// Do nothing (All others for now)
#endif
if (attemptFixup)
{
// Test if this is a valid path by trying to create a local file
// object. The URL of that is returned if successful.
// NOTE: Please be sure to check that the call to NS_NewLocalFile
// rejects bad file paths when using this code on a new
// platform.
nsCOMPtr<nsIFile> filePath;
nsresult rv;
// this is not the real fix but a temporary fix
// in order to really fix the problem, we need to change the
// nsICmdLineService interface to use wstring to pass paramenters
// instead of string since path name and other argument could be
// in non ascii.(see bug 87127) Since it is too risky to make interface change right
// now, we decide not to do so now.
// Therefore, the aIn we receive here maybe already in damage form
// (e.g. treat every bytes as ISO-8859-1 and cast up to char16_t
// while the real data could be in file system charset )
// we choice the following logic which will work for most of the case.
// Case will still failed only if it meet ALL the following condiction:
// 1. running on CJK, Russian, or Greek system, and
// 2. user type it from URL bar
// 3. the file name contains character in the range of
// U+00A1-U+00FF but encode as different code point in file
// system charset (e.g. ACP on window)- this is very rare case
// We should remove this logic and convert to File system charset here
// once we change nsICmdLineService to use wstring and ensure
// all the Unicode data come in is correctly converted.
// XXXbz nsICmdLineService doesn't hand back unicode, so in some cases
// what we have is actually a "utf8" version of a "utf16" string that's
// actually byte-expanded native-encoding data. Someone upstream needs
// to stop using AssignWithConversion and do things correctly. See bug
// 58866 for what happens if we remove this
// PossiblyByteExpandedFileName check.
NS_ConvertUTF8toUTF16 in(aIn);
if (PossiblyByteExpandedFileName(in)) {
// removes high byte
rv = NS_NewNativeLocalFile(NS_LossyConvertUTF16toASCII(in), false, getter_AddRefs(filePath));
}
else {
// input is unicode
rv = NS_NewLocalFile(in, false, getter_AddRefs(filePath));
}
if (NS_SUCCEEDED(rv))
{
NS_GetURLSpecFromFile(filePath, aOut);
return NS_OK;
}
}
return NS_ERROR_FAILURE;
}