本文整理汇总了C++中nsAutoString类的典型用法代码示例。如果您正苦于以下问题:C++ nsAutoString类的具体用法?C++ nsAutoString怎么用?C++ nsAutoString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了nsAutoString类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1:
NS_IMETHODIMP
nsHTMLFormatConverter::ConvertFromHTMLToAOLMail(const nsAutoString & aFromStr,
nsAutoString & aToStr)
{
aToStr.AssignLiteral("<HTML>");
aToStr.Append(aFromStr);
aToStr.AppendLiteral("</HTML>");
return NS_OK;
}
开发者ID:abhishekvp,项目名称:gecko-dev,代码行数:10,代码来源:nsHTMLFormatConverter.cpp
示例2: textSink
//
// ConvertFromHTMLToUnicode
//
// Takes HTML and converts it to plain text but in unicode.
//
NS_IMETHODIMP
nsHTMLFormatConverter::ConvertFromHTMLToUnicode(const nsAutoString & aFromStr, nsAutoString & aToStr)
{
// create the parser to do the conversion.
aToStr.SetLength(0);
nsresult rv;
nsCOMPtr<nsIParser> parser = do_CreateInstance(kCParserCID, &rv);
if ( !parser )
return rv;
// convert it!
nsCOMPtr<nsIContentSink> sink;
sink = do_CreateInstance(NS_PLAINTEXTSINK_CONTRACTID);
NS_ENSURE_TRUE(sink, NS_ERROR_FAILURE);
nsCOMPtr<nsIHTMLToTextSink> textSink(do_QueryInterface(sink));
NS_ENSURE_TRUE(textSink, NS_ERROR_FAILURE);
textSink->Initialize(&aToStr, nsIDocumentEncoder::OutputSelectionOnly
| nsIDocumentEncoder::OutputAbsoluteLinks, 0);
parser->SetContentSink(sink);
parser->Parse(aFromStr, 0, NS_LITERAL_CSTRING("text/html"), PR_TRUE, eDTDMode_fragment);
return NS_OK;
} // ConvertFromHTMLToUnicode
开发者ID:amyvmiwei,项目名称:firefox,代码行数:33,代码来源:nsHTMLFormatConverter.cpp
示例3: textSink
//
// ConvertFromHTMLToUnicode
//
// Takes HTML and converts it to plain text but in unicode.
//
NS_IMETHODIMP
nsHTMLFormatConverter::ConvertFromHTMLToUnicode(const nsAutoString & aFromStr, nsAutoString & aToStr)
{
// create the parser to do the conversion.
aToStr.SetLength(0);
nsresult rv;
nsCOMPtr<nsIParser> parser = do_CreateInstance(kCParserCID, &rv);
if ( !parser )
return rv;
// convert it!
nsCOMPtr<nsIContentSink> sink;
sink = do_CreateInstance(NS_PLAINTEXTSINK_CONTRACTID);
NS_ENSURE_TRUE(sink, NS_ERROR_FAILURE);
nsCOMPtr<nsIHTMLToTextSink> textSink(do_QueryInterface(sink));
NS_ENSURE_TRUE(textSink, NS_ERROR_FAILURE);
// We set OutputNoScriptContent and OutputNoFramesContent unconditionally
// here because |aFromStr| is already filtered based on user preferences.
PRUint32 flags =
nsIDocumentEncoder::OutputSelectionOnly |
nsIDocumentEncoder::OutputAbsoluteLinks |
nsIDocumentEncoder::OutputNoScriptContent |
nsIDocumentEncoder::OutputNoFramesContent;
textSink->Initialize(&aToStr, flags, 0);
parser->SetContentSink(sink);
parser->Parse(aFromStr, 0, NS_LITERAL_CSTRING("text/html"), PR_TRUE, eDTDMode_fragment);
return NS_OK;
} // ConvertFromHTMLToUnicode
开发者ID:mbrubeck,项目名称:mozilla-central,代码行数:39,代码来源:nsHTMLFormatConverter.cpp
示例4: AppendValue
nsresult
mozSqlResultMysql::AppendKeys(Row* aRow, nsAutoString& aKeys)
{
PRInt32 i;
for (i = 0; i < mColumnInfo.Count(); i++) {
if (((ColumnInfo*)mColumnInfo[i])->mIsPrimaryKey){
if (i){
aKeys.Append(NS_LITERAL_STRING(" AND "));
}
aKeys.Append(((ColumnInfo*)mColumnInfo[i])->mName);
aKeys.Append(PRUnichar('='));
Cell* cell = aRow->mCells[i];
AppendValue(cell, aKeys);
}
}
return NS_OK;
}
开发者ID:EdgarChen,项目名称:mozilla-cvs-history,代码行数:19,代码来源:mozSqlResultMysql.cpp
示例5: 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);
}
开发者ID:AshishNamdev,项目名称:mozilla-central,代码行数:42,代码来源:nsHtml5Highlighter.cpp
示例6: LaunchHelper
nsresult LaunchHelper(nsAutoString& aPath, nsAutoString& aParams) {
SHELLEXECUTEINFOW executeInfo = {0};
executeInfo.cbSize = sizeof(SHELLEXECUTEINFOW);
executeInfo.hwnd = NULL;
executeInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
executeInfo.lpDirectory = NULL;
executeInfo.lpFile = aPath.get();
executeInfo.lpParameters = aParams.get();
executeInfo.nShow = SW_SHOWNORMAL;
if (ShellExecuteExW(&executeInfo))
// Block until the program exits
WaitForSingleObject(executeInfo.hProcess, INFINITE);
else
return NS_ERROR_ABORT;
// We're going to ignore errors here since there's nothing we can do about
// them, and helper.exe seems to return non-zero ret on success.
return NS_OK;
}
开发者ID:mozilla,项目名称:releases-comm-central,代码行数:21,代码来源:nsWindowsShellService.cpp
示例7:
bool
nsTreeSanitizer::SanitizeStyleRule(mozilla::css::StyleRule *aRule,
nsAutoString &aRuleText)
{
bool didSanitize = false;
aRuleText.Truncate();
mozilla::css::Declaration* style = aRule->GetDeclaration();
if (style) {
didSanitize = style->HasProperty(eCSSProperty_binding);
style->RemoveProperty(eCSSProperty_binding);
style->ToString(aRuleText);
}
return didSanitize;
}
开发者ID:ehsan,项目名称:mozilla-central-cdouble,代码行数:14,代码来源:nsTreeSanitizer.cpp
示例8: if
/* returns true if aText represented a valid direction
*/
PRBool
nsResizerFrame::EvalDirection(nsAutoString& aText,eDirection& aDir)
{
PRBool aResult = PR_TRUE;
if( aText.Equals( NS_LITERAL_STRING("topleft") ) )
{
aDir = topleft;
}
else if( aText.Equals( NS_LITERAL_STRING("top") ) )
{
aDir = top;
}
else if( aText.Equals( NS_LITERAL_STRING("topright") ) )
{
aDir = topright;
}
else if( aText.Equals( NS_LITERAL_STRING("left") ) )
{
aDir = left;
}
else if( aText.Equals( NS_LITERAL_STRING("right") ) )
{
aDir = right;
}
else if( aText.Equals( NS_LITERAL_STRING("bottomleft") ) )
{
aDir = bottomleft;
}
else if( aText.Equals( NS_LITERAL_STRING("bottom") ) )
{
aDir = bottom;
}
else if( aText.Equals( NS_LITERAL_STRING("bottomright") ) )
{
aDir = bottomright;
}
else
{
aResult = PR_FALSE;
}
return aResult;
}
开发者ID:ahadzi,项目名称:celtx,代码行数:46,代码来源:nsResizerFrame.cpp
示例9: NS_ERROR
nsresult
nsNSSCertificate::FormatUIStrings(const nsAutoString &nickname, nsAutoString &nickWithSerial, nsAutoString &details)
{
if (!NS_IsMainThread()) {
NS_ERROR("nsNSSCertificate::FormatUIStrings called off the main thread");
return NS_ERROR_NOT_SAME_THREAD;
}
nsresult rv = NS_OK;
nsCOMPtr<nsINSSComponent> nssComponent(do_GetService(kNSSComponentCID, &rv));
if (NS_FAILED(rv) || !nssComponent) {
return NS_ERROR_FAILURE;
}
nsAutoString info;
nsAutoString temp1;
nickWithSerial.Append(nickname);
if (NS_SUCCEEDED(nssComponent->GetPIPNSSBundleString("CertInfoIssuedFor", info))) {
details.Append(info);
details.Append(PRUnichar(' '));
if (NS_SUCCEEDED(GetSubjectName(temp1)) && !temp1.IsEmpty()) {
details.Append(temp1);
}
details.Append(PRUnichar('\n'));
}
if (NS_SUCCEEDED(GetSerialNumber(temp1)) && !temp1.IsEmpty()) {
details.AppendLiteral(" ");
if (NS_SUCCEEDED(nssComponent->GetPIPNSSBundleString("CertDumpSerialNo", info))) {
details.Append(info);
details.AppendLiteral(": ");
}
details.Append(temp1);
nickWithSerial.AppendLiteral(" [");
nickWithSerial.Append(temp1);
nickWithSerial.Append(PRUnichar(']'));
details.Append(PRUnichar('\n'));
}
nsCOMPtr<nsIX509CertValidity> validity;
rv = GetValidity(getter_AddRefs(validity));
if (NS_SUCCEEDED(rv) && validity) {
details.AppendLiteral(" ");
if (NS_SUCCEEDED(nssComponent->GetPIPNSSBundleString("CertInfoValid", info))) {
details.Append(info);
}
if (NS_SUCCEEDED(validity->GetNotBeforeLocalTime(temp1)) && !temp1.IsEmpty()) {
details.Append(PRUnichar(' '));
if (NS_SUCCEEDED(nssComponent->GetPIPNSSBundleString("CertInfoFrom", info))) {
details.Append(info);
details.Append(PRUnichar(' '));
}
details.Append(temp1);
}
if (NS_SUCCEEDED(validity->GetNotAfterLocalTime(temp1)) && !temp1.IsEmpty()) {
details.Append(PRUnichar(' '));
if (NS_SUCCEEDED(nssComponent->GetPIPNSSBundleString("CertInfoTo", info))) {
details.Append(info);
details.Append(PRUnichar(' '));
}
details.Append(temp1);
}
details.Append(PRUnichar('\n'));
}
if (NS_SUCCEEDED(GetKeyUsagesString(mCert, nssComponent, temp1)) && !temp1.IsEmpty()) {
details.AppendLiteral(" ");
if (NS_SUCCEEDED(nssComponent->GetPIPNSSBundleString("CertDumpKeyUsage", info))) {
details.Append(info);
details.AppendLiteral(": ");
}
details.Append(temp1);
details.Append(PRUnichar('\n'));
}
nsAutoString firstEmail;
const char *aWalkAddr;
for (aWalkAddr = CERT_GetFirstEmailAddress(mCert)
;
aWalkAddr
;
aWalkAddr = CERT_GetNextEmailAddress(mCert, aWalkAddr))
{
NS_ConvertUTF8toUTF16 email(aWalkAddr);
if (email.IsEmpty())
continue;
if (firstEmail.IsEmpty()) {
/*
* If the first email address from the subject DN is also present
* in the subjectAltName extension, GetEmailAddresses() will return
//.........这里部分代码省略.........
开发者ID:at13,项目名称:mozilla-central,代码行数:101,代码来源:nsNSSCertificate.cpp
示例10: content
bool
SVGTests::PassesConditionalProcessingTests(const nsString *aAcceptLangs) const
{
// Required Features
if (mStringListAttributes[FEATURES].IsExplicitlySet()) {
if (mStringListAttributes[FEATURES].IsEmpty()) {
return false;
}
nsCOMPtr<nsIContent> content(
do_QueryInterface(const_cast<SVGTests*>(this)));
for (uint32_t i = 0; i < mStringListAttributes[FEATURES].Length(); i++) {
if (!nsSVGFeatures::HasFeature(content, mStringListAttributes[FEATURES][i])) {
return false;
}
}
}
// Required Extensions
//
// The requiredExtensions attribute defines a list of required language
// extensions. Language extensions are capabilities within a user agent that
// go beyond the feature set defined in the SVG specification.
// Each extension is identified by a URI reference.
// For now, claim that mozilla's SVG implementation supports XHTML and MathML.
if (mStringListAttributes[EXTENSIONS].IsExplicitlySet()) {
if (mStringListAttributes[EXTENSIONS].IsEmpty()) {
return false;
}
for (uint32_t i = 0; i < mStringListAttributes[EXTENSIONS].Length(); i++) {
if (!nsSVGFeatures::HasExtension(mStringListAttributes[EXTENSIONS][i])) {
return false;
}
}
}
if (aAcceptLangs == kIgnoreSystemLanguage) {
return true;
}
// systemLanguage
//
// Evaluates to "true" if one of the languages indicated by user preferences
// exactly equals one of the languages given in the value of this parameter,
// or if one of the languages indicated by user preferences exactly equals a
// prefix of one of the languages given in the value of this parameter such
// that the first tag character following the prefix is "-".
if (mStringListAttributes[LANGUAGE].IsExplicitlySet()) {
if (mStringListAttributes[LANGUAGE].IsEmpty()) {
return false;
}
// Get our language preferences
const nsAutoString acceptLangs(aAcceptLangs ? *aAcceptLangs :
Preferences::GetLocalizedString("intl.accept_languages"));
if (acceptLangs.IsEmpty()) {
NS_WARNING("no default language specified for systemLanguage conditional test");
return false;
}
const nsDefaultStringComparator defaultComparator;
for (uint32_t i = 0; i < mStringListAttributes[LANGUAGE].Length(); i++) {
nsCharSeparatedTokenizer languageTokenizer(acceptLangs, ',');
while (languageTokenizer.hasMoreTokens()) {
if (nsStyleUtil::DashMatchCompare(mStringListAttributes[LANGUAGE][i],
languageTokenizer.nextToken(),
defaultComparator)) {
return true;
}
}
}
return false;
}
return true;
}
开发者ID:carriercomm,项目名称:gecko-dev,代码行数:78,代码来源:SVGTests.cpp
示例11: Serialize
void Serialize(const nsCString& aInput)
{
const unsigned char* p = (const unsigned char*) aInput.get();
while (p && *p) {
// ' ' to '+'
if (*p == 0x20) {
mValue.Append(0x2B);
// Percent Encode algorithm
} else if (*p == 0x2A || *p == 0x2D || *p == 0x2E ||
(*p >= 0x30 && *p <= 0x39) ||
(*p >= 0x41 && *p <= 0x5A) || *p == 0x5F ||
(*p >= 0x61 && *p <= 0x7A)) {
mValue.Append(*p);
} else {
mValue.AppendPrintf("%%%X", *p);
}
++p;
}
}
开发者ID:ConradIrwin,项目名称:gecko-dev,代码行数:21,代码来源:URLSearchParams.cpp
示例12: 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');
//.........这里部分代码省略.........
开发者ID:Akin-Net,项目名称:mozilla-central,代码行数:101,代码来源:nsPersistentProperties.cpp
注:本文中的nsAutoString类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论