本文整理汇总了C++中nsCString::Cut方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCString::Cut方法的具体用法?C++ nsCString::Cut怎么用?C++ nsCString::Cut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsCString
的用法示例。
在下文中一共展示了nsCString::Cut方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: uriStr
/* parses NewsMessageURI */
nsresult
nsParseNewsMessageURI(const char* uri, nsCString& folderURI, PRUint32 *key)
{
NS_ENSURE_ARG_POINTER(uri);
NS_ENSURE_ARG_POINTER(key);
nsCAutoString uriStr(uri);
PRInt32 keySeparator = uriStr.FindChar('#');
if(keySeparator != -1)
{
PRInt32 keyEndSeparator = uriStr.FindCharInSet("?&",
keySeparator);
uriStr.Left(folderURI, keySeparator);
folderURI.Cut(4, 8); // cut out the -message part of news-message:
nsCAutoString keyStr;
if (keyEndSeparator != -1)
uriStr.Mid(keyStr, keySeparator+1,
keyEndSeparator-(keySeparator+1));
else
uriStr.Right(keyStr, uriStr.Length() - (keySeparator + 1));
PRInt32 errorCode;
*key = keyStr.ToInteger(&errorCode);
return errorCode;
}
return NS_ERROR_FAILURE;
}
示例2:
void
nsUrlClassifierDBService::BuildTables(bool aTrackingProtectionEnabled,
nsCString &tables)
{
nsAutoCString malware;
// LookupURI takes a comma-separated list already.
Preferences::GetCString(MALWARE_TABLE_PREF, &malware);
if (mCheckMalware && !malware.IsEmpty()) {
tables.Append(malware);
}
nsAutoCString phishing;
Preferences::GetCString(PHISH_TABLE_PREF, &phishing);
if (mCheckPhishing && !phishing.IsEmpty()) {
tables.Append(',');
tables.Append(phishing);
}
if (aTrackingProtectionEnabled) {
nsAutoCString tracking, trackingWhitelist;
Preferences::GetCString(TRACKING_TABLE_PREF, &tracking);
if (!tracking.IsEmpty()) {
tables.Append(',');
tables.Append(tracking);
}
Preferences::GetCString(TRACKING_WHITELIST_TABLE_PREF, &trackingWhitelist);
if (!trackingWhitelist.IsEmpty()) {
tables.Append(',');
tables.Append(trackingWhitelist);
}
}
if (StringBeginsWith(tables, NS_LITERAL_CSTRING(","))) {
tables.Cut(0, 1);
}
}
示例3: normalizeDriverId
// The driver ID is a string like PCI\VEN_15AD&DEV_0405&SUBSYS_040515AD, possibly
// followed by &REV_XXXX. We uppercase the string, and strip the &REV_ part
// from it, if found.
static void normalizeDriverId(nsCString& driverid) {
ToUpperCase(driverid);
PRInt32 rev = driverid.Find(NS_LITERAL_CSTRING("&REV_"));
if (rev != -1) {
driverid.Cut(rev, driverid.Length());
}
}
示例4: nsParseImapMessageURI
/* parses ImapMessageURI */
nsresult nsParseImapMessageURI(const char* uri, nsCString& folderURI, PRUint32 *key, char **part)
{
if(!key)
return NS_ERROR_NULL_POINTER;
nsCAutoString uriStr(uri);
PRInt32 folderEnd = -1;
// imap-message uri's can have imap:// url strings tacked on the end,
// e.g., when opening/saving attachments. We don't want to look for '#'
// in that part of the uri, if the attachment name contains '#',
// so check for that here.
if (StringBeginsWith(uriStr, NS_LITERAL_CSTRING("imap-message")))
folderEnd = uriStr.Find("imap://");
PRInt32 keySeparator = MsgRFindChar(uriStr, '#', folderEnd);
if(keySeparator != -1)
{
PRInt32 keyEndSeparator = MsgFindCharInSet(uriStr, "/?&", keySeparator);
nsAutoString folderPath;
folderURI = StringHead(uriStr, keySeparator);
folderURI.Cut(4, 8); // cut out the _message part of imap-message:
// folder uri's don't have fully escaped usernames.
PRInt32 atPos = folderURI.FindChar('@');
if (atPos != -1)
{
nsCString unescapedName, escapedName;
PRInt32 userNamePos = folderURI.Find("//") + 2;
PRUint32 origUserNameLen = atPos - userNamePos;
if (NS_SUCCEEDED(MsgUnescapeString(Substring(folderURI, userNamePos,
origUserNameLen),
0, unescapedName)))
{
// Re-escape the username, matching the way we do it in uris, not the
// way necko escapes urls. See nsMsgIncomingServer::GetServerURI.
MsgEscapeString(unescapedName, nsINetUtil::ESCAPE_XALPHAS, escapedName);
folderURI.Replace(userNamePos, origUserNameLen, escapedName);
}
}
nsCAutoString keyStr;
if (keyEndSeparator != -1)
keyStr = Substring(uriStr, keySeparator + 1, keyEndSeparator - (keySeparator + 1));
else
keyStr = Substring(uriStr, keySeparator + 1);
*key = strtoul(keyStr.get(), nsnull, 10);
if (part && keyEndSeparator != -1)
{
PRInt32 partPos = MsgFind(uriStr, "part=", PR_FALSE, keyEndSeparator);
if (partPos != -1)
{
*part = ToNewCString(Substring(uriStr, keyEndSeparator));
}
}
}
return NS_OK;
}
示例5:
nsresult
rdf_MakeRelativeRef(const nsCSubstring& aBaseURI, nsCString& aURI)
{
// This implementation is extremely simple: e.g., it can't compute
// relative paths, or anything fancy like that. If the context URI
// is not a prefix of the URI in question, we'll just bail.
PRUint32 prefixLen = aBaseURI.Length();
if (prefixLen != 0 && StringBeginsWith(aURI, aBaseURI)) {
if (prefixLen < aURI.Length() && aURI.CharAt(prefixLen) == '/')
++prefixLen; // chop the leading slash so it's not `absolute'
aURI.Cut(0, prefixLen);
}
return NS_OK;
}
示例6: nsParseImapMessageURI
/* parses ImapMessageURI */
nsresult nsParseImapMessageURI(const char* uri, nsCString& folderURI, PRUint32 *key, char **part)
{
if(!key)
return NS_ERROR_NULL_POINTER;
nsCAutoString uriStr(uri);
PRInt32 keySeparator = uriStr.RFindChar('#');
if(keySeparator != -1)
{
PRInt32 keyEndSeparator = uriStr.FindCharInSet("/?&",
keySeparator);
nsAutoString folderPath;
uriStr.Left(folderURI, keySeparator);
folderURI.Cut(4, 8); // cut out the _message part of imap-message:
nsCAutoString keyStr;
if (keyEndSeparator != -1)
uriStr.Mid(keyStr, keySeparator+1,
keyEndSeparator-(keySeparator+1));
else
uriStr.Right(keyStr, uriStr.Length() - (keySeparator + 1));
PRInt32 errorCode;
*key = keyStr.ToInteger(&errorCode);
if (part && keyEndSeparator != -1)
{
PRInt32 partPos = uriStr.Find("part=", PR_FALSE, keyEndSeparator);
if (partPos != -1)
{
nsCString partSubStr;
uriStr.Right(partSubStr, uriStr.Length() - keyEndSeparator);
*part = ToNewCString(partSubStr);
}
}
}
return NS_OK;
}
示例7: ExtractNoteField
void nsEudoraAddress::ExtractNoteField(nsCString& note, nsCString& value, const char *pFieldName)
{
value.Truncate();
nsCString field("<");
field.Append(pFieldName);
field.Append(':');
/*
this is a bit of a cheat, but there's no reason it won't work
fine for us, even better than Eudora in some cases!
*/
int32_t idx = note.Find(field);
if (idx != -1) {
idx += field.Length();
int32_t endIdx = note.FindChar('>', idx);
if (endIdx == -1)
endIdx = note.Length() - 1;
value = Substring(note, idx, endIdx - idx);
idx -= field.Length();
note.Cut(idx, endIdx + 1);
}
}
示例8: CleanUpIcalString
static
void CleanUpIcalString(nsCString & data) {
//remove all '\r\n '
PRInt32 pos = -1;
while ((pos = data.Find("\r\n ")) >= 0) {
data.Cut(pos, 3);
}
char src[512] = {0};
char dst[512] = {0};
//Update TZID,
//the exchange will use tz name some times update to TZID
for(size_t i=0;i < TIMEZONES_COUNT; i+=2) {
sprintf(src, "TZID:%s", TIMEZONES[i]);
sprintf(dst, "TZID:%s", TIMEZONES[i + 1]);
while((pos = data.Find(src)) >= 0) {
data.Replace(pos,
strlen(src),
dst,
strlen(dst));
}
sprintf(src, "TZID=\"%s\"", TIMEZONES[i]);
sprintf(dst, "TZID=\"%s\"", TIMEZONES[i + 1]);
while((pos = data.Find(src)) >= 0) {
data.Replace(pos,
strlen(src),
dst,
strlen(dst));
}
}
}
示例9: GetField
bool nsTextAddress::GetField( const char *pLine, PRInt32 maxLen, PRInt32 index, nsCString& field, char delim)
{
bool result = false;
const char *pChar = pLine;
PRInt32 len = 0;
char tab = 9;
field.Truncate();
if (delim == tab)
tab = 0;
while (index && (len < maxLen)) {
while (((*pChar == ' ') || (*pChar == tab)) && (len < maxLen)) {
pChar++;
len++;
}
if (len >= maxLen)
break;
if (*pChar == '"') {
len = -1;
do {
len++;
pChar++;
if (((len + 1) < maxLen) && (*pChar == '"') && (*(pChar + 1) == '"')) {
len += 2;
pChar += 2;
}
} while ((len < maxLen) && (*pChar != '"'));
if (len < maxLen) {
pChar++;
len++;
}
}
if (len >= maxLen)
break;
while ((len < maxLen) && (*pChar != delim)) {
len++;
pChar++;
}
if (len >= maxLen)
break;
index--;
pChar++;
len++;
}
if (len >= maxLen) {
return( result);
}
result = true;
while ((len < maxLen) && ((*pChar == ' ') || (*pChar == tab))) {
len++;
pChar++;
}
const char *pStart = pChar;
PRInt32 fLen = 0;
bool quoted = false;
if (*pChar == '"') {
pStart++;
fLen = -1;
do {
pChar++;
len++;
fLen++;
if (((len + 1) < maxLen) && (*pChar == '"') && (*(pChar + 1) == '"')) {
quoted = true;
len += 2;
pChar += 2;
fLen += 2;
}
} while ((len < maxLen) && (*pChar != '"'));
}
else {
while ((len < maxLen) && (*pChar != delim)) {
pChar++;
len++;
fLen++;
}
}
if (!fLen) {
return( result);
}
field.Append( pStart, fLen);
field.Trim( kWhitespace);
if (quoted) {
PRInt32 offset = field.Find(NS_LITERAL_CSTRING("\"\""));
while (offset != -1) {
field.Cut(offset, 1);
offset = field.Find(NS_LITERAL_CSTRING("\"\""), offset + 1);
}
//.........这里部分代码省略.........