本文整理汇总了C++中nsString::Last方法的典型用法代码示例。如果您正苦于以下问题:C++ nsString::Last方法的具体用法?C++ nsString::Last怎么用?C++ nsString::Last使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsString
的用法示例。
在下文中一共展示了nsString::Last方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tokenizer
// static
bool
Directory::IsValidRelativePath(const nsString& aPath)
{
// We don't allow empty relative path to access the root.
if (aPath.IsEmpty()) {
return false;
}
// Leading and trailing "/" are not allowed.
if (aPath.First() == FileSystemUtils::kSeparatorChar ||
aPath.Last() == FileSystemUtils::kSeparatorChar) {
return false;
}
NS_NAMED_LITERAL_STRING(kCurrentDir, ".");
NS_NAMED_LITERAL_STRING(kParentDir, "..");
// Split path and check each path component.
nsCharSeparatedTokenizer tokenizer(aPath, FileSystemUtils::kSeparatorChar);
while (tokenizer.hasMoreTokens()) {
nsDependentSubstring pathComponent = tokenizer.nextToken();
// The path containing empty components, such as "foo//bar", is invalid.
// We don't allow paths, such as "../foo", "foo/./bar" and "foo/../bar",
// to walk up the directory.
if (pathComponent.IsEmpty() ||
pathComponent.Equals(kCurrentDir) ||
pathComponent.Equals(kParentDir)) {
return false;
}
}
return true;
}
示例2: ChangeName
void CMapiFolderList::ChangeName( nsString& name)
{
if (name.IsEmpty()) {
name.AssignLiteral("1");
return;
}
PRUnichar lastC = name.Last();
if ((lastC >= '0') && (lastC <= '9')) {
lastC++;
if (lastC > '9') {
lastC = '1';
name.SetCharAt( lastC, name.Length() - 1);
name.AppendLiteral("0");
}
else {
name.SetCharAt( lastC, name.Length() - 1);
}
}
else {
name.AppendLiteral(" 2");
}
}
示例3: if
// XXX Code copied from nsHTMLContentSink. It should be shared.
void
nsRDFParserUtils::StripAndConvert(nsString& aResult)
{
if ( !aResult.IsEmpty() ) {
// Strip quotes if present
PRUnichar first = aResult.First();
if ((first == '"') || (first == '\'')) {
if (aResult.Last() == first) {
aResult.Cut(0, 1);
PRInt32 pos = aResult.Length() - 1;
if (pos >= 0) {
aResult.Cut(pos, 1);
}
} else {
// Mismatched quotes - leave them in
}
}
}
// Reduce any entities
// XXX Note: as coded today, this will only convert well formed
// entities. This may not be compatible enough.
// XXX there is a table in navigator that translates some numeric entities
// should we be doing that? If so then it needs to live in two places (bad)
// so we should add a translate numeric entity method from the parser...
char cbuf[100];
PRUint32 i = 0;
while (i < aResult.Length()) {
// If we have the start of an entity (and it's not at the end of
// our string) then translate the entity into it's unicode value.
if ((aResult.CharAt(i++) == '&') && (i < aResult.Length())) {
PRInt32 start = i - 1;
PRUnichar e = aResult.CharAt(i);
if (e == '#') {
// Convert a numeric character reference
i++;
char* cp = cbuf;
char* limit = cp + sizeof(cbuf) - 1;
PRBool ok = PR_FALSE;
PRUint32 slen = aResult.Length();
while ((i < slen) && (cp < limit)) {
PRUnichar f = aResult.CharAt(i);
if (f == ';') {
i++;
ok = PR_TRUE;
break;
}
if ((f >= '0') && (f <= '9')) {
*cp++ = char(f);
i++;
continue;
}
break;
}
if (!ok || (cp == cbuf)) {
continue;
}
*cp = '\0';
if (cp - cbuf > 5) {
continue;
}
PRInt32 ch = PRInt32( ::atoi(cbuf) );
if (ch > 65535) {
continue;
}
// Remove entity from string and replace it with the integer
// value.
aResult.Cut(start, i - start);
aResult.Insert(PRUnichar(ch), start);
i = start + 1;
}
else if (((e >= 'A') && (e <= 'Z')) ||
((e >= 'a') && (e <= 'z'))) {
// Convert a named entity
i++;
char* cp = cbuf;
char* limit = cp + sizeof(cbuf) - 1;
*cp++ = char(e);
PRBool ok = PR_FALSE;
PRUint32 slen = aResult.Length();
while ((i < slen) && (cp < limit)) {
PRUnichar f = aResult.CharAt(i);
if (f == ';') {
i++;
ok = PR_TRUE;
break;
}
if (((f >= '0') && (f <= '9')) ||
((f >= 'A') && (f <= 'Z')) ||
((f >= 'a') && (f <= 'z'))) {
*cp++ = char(f);
i++;
continue;
}
break;
}
if (!ok || (cp == cbuf)) {
continue;
//.........这里部分代码省略.........