本文整理汇总了C++中nsAutoString::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ nsAutoString::Length方法的具体用法?C++ nsAutoString::Length怎么用?C++ nsAutoString::Length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsAutoString
的用法示例。
在下文中一共展示了nsAutoString::Length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EmptyString
void
nsHtml5Highlighter::Start(const nsAutoString& aTitle)
{
// Doctype
mOpQueue.AppendElement()->Init(nsGkAtoms::html, EmptyString(), EmptyString());
mOpQueue.AppendElement()->Init(STANDARDS_MODE);
nsIContent** root = CreateElement(nsHtml5Atoms::html, nullptr);
mOpQueue.AppendElement()->Init(eTreeOpAppendToDocument, root);
mStack.AppendElement(root);
Push(nsGkAtoms::head, nullptr);
Push(nsGkAtoms::title, nullptr);
// XUL will add the "Source of: " prefix.
uint32_t length = aTitle.Length();
if (length > INT32_MAX) {
length = INT32_MAX;
}
AppendCharacters(aTitle.get(), 0, (int32_t)length);
Pop(); // title
Push(nsGkAtoms::link, nsHtml5ViewSourceUtils::NewLinkAttributes());
mOpQueue.AppendElement()->Init(eTreeOpUpdateStyleSheet, CurrentNode());
Pop(); // link
Pop(); // head
Push(nsGkAtoms::body, nsHtml5ViewSourceUtils::NewBodyAttributes());
nsHtml5HtmlAttributes* preAttrs = new nsHtml5HtmlAttributes(0);
nsString* preId = new nsString(NS_LITERAL_STRING("line1"));
preAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, preId);
Push(nsGkAtoms::pre, preAttrs);
StartCharacters();
mOpQueue.AppendElement()->Init(eTreeOpStartLayout);
}
示例2: ParseValueCharacter
PRBool nsPropertiesParser::ParseValueCharacter(
PRUnichar c, const PRUnichar* cur, const PRUnichar* &tokenStart,
nsAString& oldValue)
{
switch (mSpecialState) {
// the normal state - look for special characters
case eParserSpecial_None:
switch (c) {
case '\\':
if (mHaveMultiLine)
// there is nothing to append to mValue yet
mHaveMultiLine = PR_FALSE;
else
mValue += Substring(tokenStart, cur);
mSpecialState = eParserSpecial_Escaped;
break;
case '\n':
// if we detected multiline and got only "\\\r" ignore next "\n" if any
if (mHaveMultiLine && mMultiLineCanSkipN) {
// but don't allow another '\n' to be skipped
mMultiLineCanSkipN = PR_FALSE;
// Now there is nothing to append to the mValue since we are skipping
// whitespaces at the beginning of the new line of the multiline
// property. Set tokenStart properly to ensure that nothing is appended
// if we find regular line-end or the end of the buffer.
tokenStart = cur+1;
break;
}
// no break
case '\r':
// we're done! We have a key and value
mValue += Substring(tokenStart, cur);
FinishValueState(oldValue);
mHaveMultiLine = PR_FALSE;
break;
default:
// there is nothing to do with normal characters,
// but handle multilines correctly
if (mHaveMultiLine) {
if (c == ' ' || c == '\t') {
// don't allow another '\n' to be skipped
mMultiLineCanSkipN = PR_FALSE;
// Now there is nothing to append to the mValue since we are skipping
// whitespaces at the beginning of the new line of the multiline
// property. Set tokenStart properly to ensure that nothing is appended
// if we find regular line-end or the end of the buffer.
tokenStart = cur+1;
break;
}
mHaveMultiLine = PR_FALSE;
tokenStart = cur;
}
break; // from switch on (c)
}
break; // from switch on (mSpecialState)
// saw a \ character, so parse the character after that
case eParserSpecial_Escaped:
// probably want to start parsing at the next token
// other characters, like 'u' might override this
tokenStart = cur+1;
mSpecialState = eParserSpecial_None;
switch (c) {
// the easy characters - \t, \n, and so forth
case 't':
mValue += PRUnichar('\t');
mMinLength = mValue.Length();
break;
case 'n':
mValue += PRUnichar('\n');
mMinLength = mValue.Length();
break;
case 'r':
mValue += PRUnichar('\r');
mMinLength = mValue.Length();
break;
case '\\':
mValue += PRUnichar('\\');
break;
// switch to unicode mode!
case 'u':
case 'U':
mSpecialState = eParserSpecial_Unicode;
mUnicodeValuesRead = 0;
mUnicodeValue = 0;
break;
// a \ immediately followed by a newline means we're going multiline
case '\r':
case '\n':
mHaveMultiLine = PR_TRUE;
mMultiLineCanSkipN = (c == '\r');
//.........这里部分代码省略.........