本文整理汇总了C++中nsSubstring::CountChar方法的典型用法代码示例。如果您正苦于以下问题:C++ nsSubstring::CountChar方法的具体用法?C++ nsSubstring::CountChar怎么用?C++ nsSubstring::CountChar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsSubstring
的用法示例。
在下文中一共展示了nsSubstring::CountChar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteTag
/**
* This method gets called when a tag needs to be sent out
*
* @update gess 3/25/98
* @param
* @return result status
*/
nsresult CViewSourceHTML::WriteTag(PRInt32 aTagType,const nsSubstring & aText,PRInt32 attrCount,PRBool aTagInError) {
nsresult result=NS_OK;
// adjust line number to what it will be after we finish writing this tag
// XXXbz life here sucks. We can't use the GetNewlineCount on the token,
// because Text tokens in <style>, <script>, etc lie through their teeth.
// On the other hand, the parser messes up newline counting in some token
// types (bug 137315). So our line numbers will disagree with the parser's
// in some cases...
// XXXbenjamn Shouldn't we be paying attention to the aCountLines BuildModel
// parameter here?
mLineNumber += aText.CountChar(PRUnichar('\n'));
nsTokenAllocator* theAllocator=mTokenizer->GetTokenAllocator();
NS_ASSERTION(0!=theAllocator,"Error: no allocator");
if(0==theAllocator)
return NS_ERROR_FAILURE;
// Highlight all parts of all erroneous tags.
if (mSyntaxHighlight && aTagInError) {
CStartToken* theTagToken=
static_cast<CStartToken*>
(theAllocator->CreateTokenOfType(eToken_start,
eHTMLTag_span,
NS_LITERAL_STRING("SPAN")));
NS_ENSURE_TRUE(theTagToken, NS_ERROR_OUT_OF_MEMORY);
mErrorNode.Init(theTagToken, theAllocator);
AddAttrToNode(mErrorNode, theAllocator,
NS_LITERAL_STRING("class"),
NS_LITERAL_STRING("error"));
mSink->OpenContainer(mErrorNode);
IF_FREE(theTagToken, theAllocator);
#ifdef DUMP_TO_FILE
if (gDumpFile) {
fprintf(gDumpFile, "<span class=\"error\">");
}
#endif
}
if (kBeforeText[aTagType][0] != 0) {
NS_ConvertASCIItoUTF16 beforeText(kBeforeText[aTagType]);
mITextToken.SetIndirectString(beforeText);
nsCParserNode theNode(&mITextToken, 0/*stack token*/);
mSink->AddLeaf(theNode);
}
#ifdef DUMP_TO_FILE
if (gDumpFile && kDumpFileBeforeText[aTagType][0])
fprintf(gDumpFile, kDumpFileBeforeText[aTagType]);
#endif // DUMP_TO_FILE
if (mSyntaxHighlight && aTagType != kText) {
CStartToken* theTagToken=
static_cast<CStartToken*>
(theAllocator->CreateTokenOfType(eToken_start,
eHTMLTag_span,
NS_LITERAL_STRING("SPAN")));
NS_ENSURE_TRUE(theTagToken, NS_ERROR_OUT_OF_MEMORY);
mStartNode.Init(theTagToken, theAllocator);
AddAttrToNode(mStartNode, theAllocator,
NS_LITERAL_STRING("class"),
NS_ConvertASCIItoUTF16(kElementClasses[aTagType]));
mSink->OpenContainer(mStartNode); //emit <starttag>...
IF_FREE(theTagToken, theAllocator);
#ifdef DUMP_TO_FILE
if (gDumpFile) {
fprintf(gDumpFile, "<span class=\"");
fprintf(gDumpFile, kElementClasses[aTagType]);
fprintf(gDumpFile, "\">");
}
#endif // DUMP_TO_FILE
}
STOP_TIMER();
mITextToken.SetIndirectString(aText); //now emit the tag name...
nsCParserNode theNode(&mITextToken, 0/*stack token*/);
mSink->AddLeaf(theNode);
#ifdef DUMP_TO_FILE
if (gDumpFile) {
fputs(NS_ConvertUTF16toUTF8(aText).get(), gDumpFile);
}
#endif // DUMP_TO_FILE
if (mSyntaxHighlight && aTagType != kText) {
mStartNode.ReleaseAll();
mSink->CloseContainer(eHTMLTag_span); //emit </endtag>...
#ifdef DUMP_TO_FILE
if (gDumpFile)
fprintf(gDumpFile, "</span>");
#endif //DUMP_TO_FILE
}
//.........这里部分代码省略.........