本文整理汇总了C++中nsACString::Insert方法的典型用法代码示例。如果您正苦于以下问题:C++ nsACString::Insert方法的具体用法?C++ nsACString::Insert怎么用?C++ nsACString::Insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsACString
的用法示例。
在下文中一共展示了nsACString::Insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
FileLocation::GetURIString(nsACString &result) const
{
if (mBaseFile) {
net_GetURLSpecFromActualFile(mBaseFile, result);
} else if (mBaseZip) {
nsRefPtr<nsZipHandle> handler = mBaseZip->GetFD();
handler->mFile.GetURIString(result);
}
if (IsZip()) {
result.Insert("jar:", 0);
result += "!/";
result += mPath;
}
}
示例2: LOG
/* static */
nsresult
sbURIChecker::CheckDomain( nsACString &aDomain, nsIURI *aSiteURI )
{
NS_ENSURE_ARG_POINTER(aSiteURI);
LOG(( "sbURIChecker::CheckDomain(%s)", aDomain.BeginReading() ));
// get host from URI
nsCString host;
nsresult rv = aSiteURI->GetHost(host);
NS_ENSURE_SUCCESS( rv, rv );
nsCString fixedHost;
rv = sbURIChecker::FixupDomain( host, fixedHost );
NS_ENSURE_SUCCESS( rv, rv );
host.Assign(fixedHost);
if ( !aDomain.IsEmpty() ) {
LOG(("sbURIChecker::CheckDomain() -- Have a domain from the user"));
// remove trailing dots, lowercase it
nsCString fixedDomain;
rv = sbURIChecker::FixupDomain( aDomain, fixedDomain );
NS_ENSURE_SUCCESS( rv, rv );
aDomain.Assign(fixedDomain);
// Deal first with numerical ip addresses
PRNetAddr addr;
if ( PR_StringToNetAddr( host.get(), &addr ) == PR_SUCCESS ) {
// numerical ip address
LOG(("sbURIChecker::CheckDomain() -- Numerical Address "));
if ( !aDomain.Equals(host) ) {
LOG(("sbURIChecker::CheckDomain() -- FAILED ip address check"));
return NS_ERROR_FAILURE;
}
} else {
// domain based host, check it against host from URI
LOG(("sbURIChecker::CheckDomain() -- Domain based host "));
// make sure the domain wasn't '.com' - it should have a dot in it
// we need to skip this check if the host is localhost
PRInt32 dot = aDomain.FindChar('.');
if ( dot < 0 && !host.Equals("localhost")) {
LOG(("sbURIChecker::CheckDomain() -- FAILED dot test "));
return NS_ERROR_FAILURE;
}
// prepend a dot so bar.com doesn't match foobar.com but does foo.bar.com
aDomain.Insert( NS_LITERAL_CSTRING("."), 0 );
PRInt32 domainLength = aDomain.Length();
PRInt32 lengthDiff = host.Length() - domainLength;
if ( lengthDiff == -1 ) {
LOG(("sbURIChecker::CheckDomain() -- long domain check"));
// special case: from user: .bar.com vs. from URI: bar.com
// XXXredfive - I actually think we'll see this most often because
// of the prepending of the dot to the user supplied domain
if ( !StringEndsWith(aDomain, host) ) {
LOG(("sbURIChecker::CheckDomain() -- FAILED long domain check"));
return NS_ERROR_FAILURE;
}
} else if ( lengthDiff == 0 ) {
LOG(("sbURIChecker::CheckDomain() -- same length check"));
// same length better be the same strings
if ( !aDomain.Equals(host) ) {
LOG(("sbURIChecker::CheckDomain() -- FAILED same length check"));
return NS_ERROR_FAILURE;
}
} else if ( lengthDiff > 0 ) {
LOG(("sbURIChecker::CheckDomain() -- parent domain check"));
// normal case URI host is longer that host from user
// from user: .bar.com from URI: foo.bar.com
if ( !StringEndsWith(host, aDomain) ) {
LOG(("sbURIChecker::CheckDomain() -- FAILED parent domain check"));
return NS_ERROR_FAILURE;
}
} else {
// domains are WAY off, the user domain is more than 1 char longer than
// the URI domain. ie: user: jgaunt.com URI: ""
LOG(("sbURIChecker::CheckDomain() -- FAILED, user domain is superset"));
return NS_ERROR_FAILURE;
}
// remove the leading dot we added
aDomain.Cut( 0, 1 );
}
} else {
LOG(( "sbURIChecker::CheckDomain() -- NO domain from the user"));
// If the user didn't specify a host
// if the URI host is empty, make sure we're file://
if ( host.IsEmpty() ) {
PRBool isFileURI;
rv = aSiteURI->SchemeIs( "file", &isFileURI );
NS_ENSURE_SUCCESS( rv, rv );
if (!isFileURI) {
// non-file URI without a host!!!
LOG(("sbURIChecker::CheckDomain() -- FAILED file scheme check"));
return NS_ERROR_FAILURE;
//.........这里部分代码省略.........