当前位置: 首页>>代码示例>>C++>>正文


C++ nsString::AssignLiteral方法代码示例

本文整理汇总了C++中nsString::AssignLiteral方法的典型用法代码示例。如果您正苦于以下问题:C++ nsString::AssignLiteral方法的具体用法?C++ nsString::AssignLiteral怎么用?C++ nsString::AssignLiteral使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nsString的用法示例。


在下文中一共展示了nsString::AssignLiteral方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: switch

void
PopupBoxObject::GetPopupState(nsString& aState)
{
  // set this here in case there's no frame for the popup
  aState.AssignLiteral("closed");

  nsMenuPopupFrame *menuPopupFrame = mContent ? do_QueryFrame(mContent->GetPrimaryFrame()) : nullptr;
  if (menuPopupFrame) {
    switch (menuPopupFrame->PopupState()) {
      case ePopupShown:
        aState.AssignLiteral("open");
        break;
      case ePopupShowing:
      case ePopupOpening:
      case ePopupVisible:
        aState.AssignLiteral("showing");
        break;
      case ePopupHiding:
      case ePopupInvisible:
        aState.AssignLiteral("hiding");
        break;
      case ePopupClosed:
        break;
      default:
        NS_NOTREACHED("Bad popup state");
        break;
    }
  }
}
开发者ID:carriercomm,项目名称:system-addons,代码行数:29,代码来源:PopupBoxObject.cpp

示例2: inString

void
mozTXTToHTMLConv::CompleteAbbreviatedURL(const PRUnichar * aInString, PRInt32 aInLength, 
                                         const PRUint32 pos, nsString& aOutString)
{
  NS_ASSERTION(PRInt32(pos) < aInLength, "bad args to CompleteAbbreviatedURL, see bug #190851");
  if (PRInt32(pos) >= aInLength)
    return;

  if (aInString[pos] == '@')
  {
    // only pre-pend a mailto url if the string contains a .domain in it..
    //i.e. we want to linkify [email protected] but not "let's meet @8pm"
    nsDependentString inString(aInString, aInLength);
    if (inString.FindChar('.', pos) != kNotFound) // if we have a '.' after the @ sign....
    {
      aOutString.AssignLiteral("mailto:");
      aOutString += aInString;
    }
  }
  else if (aInString[pos] == '.')
  {
    if (ItMatchesDelimited(aInString, aInLength,
                           NS_LITERAL_STRING("www.").get(), 4, LT_IGNORE, LT_IGNORE))
    {
      aOutString.AssignLiteral("http://");
      aOutString += aInString;
    }
    else if (ItMatchesDelimited(aInString,aInLength, NS_LITERAL_STRING("ftp.").get(), 4, LT_IGNORE, LT_IGNORE))
    { 
      aOutString.AssignLiteral("ftp://");
      aOutString += aInString;
    }
  }
}
开发者ID:marshall,项目名称:mozilla-central,代码行数:34,代码来源:mozTXTToHTMLConv.cpp

示例3: GetDesc

void
FontFace::GetDesc(nsCSSFontDesc aDescID,
                  nsCSSProperty aPropID,
                  nsString& aResult) const
{
  MOZ_ASSERT(aDescID == eCSSFontDesc_UnicodeRange ||
             aPropID != eCSSProperty_UNKNOWN,
             "only pass eCSSProperty_UNKNOWN for eCSSFontDesc_UnicodeRange");

  nsCSSValue value;
  GetDesc(aDescID, value);

  aResult.Truncate();

  // Fill in a default value for missing descriptors.
  if (value.GetUnit() == eCSSUnit_Null) {
    if (aDescID == eCSSFontDesc_UnicodeRange) {
      aResult.AssignLiteral("U+0-10FFFF");
    } else if (aDescID != eCSSFontDesc_Family &&
               aDescID != eCSSFontDesc_Src) {
      aResult.AssignLiteral("normal");
    }
    return;
  }

  if (aDescID == eCSSFontDesc_UnicodeRange) {
    // Since there's no unicode-range property, we can't use
    // nsCSSValue::AppendToString to serialize this descriptor.
    nsStyleUtil::AppendUnicodeRange(value, aResult);
  } else {
    value.AppendToString(aPropID, aResult, nsCSSValue::eNormalized);
  }
}
开发者ID:bolt-dev,项目名称:gecko-dev,代码行数:33,代码来源:FontFace.cpp

示例4: switch

void
CryptoKey::GetType(nsString& aRetVal) const
{
  uint32_t type = mAttributes & TYPE_MASK;
  switch (type) {
    case PUBLIC:  aRetVal.AssignLiteral(WEBCRYPTO_KEY_TYPE_PUBLIC); break;
    case PRIVATE: aRetVal.AssignLiteral(WEBCRYPTO_KEY_TYPE_PRIVATE); break;
    case SECRET:  aRetVal.AssignLiteral(WEBCRYPTO_KEY_TYPE_SECRET); break;
  }
}
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:10,代码来源:CryptoKey.cpp

示例5:

void
nsPerformanceSnapshot::GetGroupId(JSContext* cx,
                                  uint64_t uid,
                                  nsString& groupId)
{
  JSRuntime* rt = JS_GetRuntime(cx);
  uint64_t runtimeId = reinterpret_cast<uintptr_t>(rt);

  groupId.AssignLiteral("process: ");
  groupId.AppendInt(mProcessId);
  groupId.AssignLiteral(", thread: ");
  groupId.AppendInt(runtimeId);
  groupId.AppendLiteral(", group: ");
  groupId.AppendInt(uid);
}
开发者ID:Bouh,项目名称:gecko-dev,代码行数:15,代码来源:nsPerformanceStats.cpp

示例6: s

void nsEudoraWin32::GetAccountName( const char *pSection, nsString& str)
{
  str.Truncate();

  nsCString s(pSection);

  if (s.Equals(NS_LITERAL_CSTRING("Settings"), nsCaseInsensitiveCStringComparator()))
  {
    str.AssignLiteral("Eudora ");
    str.Append(NS_ConvertASCIItoUTF16(pSection));
  }
  else
  {
    nsCString tStr;
    CopyASCIItoUTF16(pSection, str);
    if (s.Length() > 8)
    {
      s.Left( tStr, 8);
      if (tStr.Equals(NS_LITERAL_CSTRING("Persona-"), nsCaseInsensitiveCStringComparator()))
      {
        s.Right( tStr, s.Length() - 8);
        CopyASCIItoUTF16(tStr, str);
      }
    }
  }
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:26,代码来源:nsEudoraWin32.cpp

示例7: RecipientToString2

void RecipientToString2(ews_recipient * r, int c, nsString & v) {
    std::string vv("");

    RecipientToStdString(r, c, vv);

    v.AssignLiteral(vv.c_str());
}
开发者ID:stonewell,项目名称:exchange-ews-thunderbird,代码行数:7,代码来源:MailEwsMsgUtils.cpp

示例8: getDriverDetails

static void getDriverDetails(nsCString& driverId, nsString& aDriverVersion, nsString& aDriverDate)
{
  HKEY key, subkey;
  LONG result, enumresult;
  DWORD index = 0;
  char subkeyname[64];
  TCHAR value[128];
  DWORD dwcbData = sizeof(subkeyname);
  
  // "{4D36E968-E325-11CE-BFC1-08002BE10318}" is the display class
  result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, 
                        "System\\CurrentControlSet\\Control\\Class\\{4D36E968-E325-11CE-BFC1-08002BE10318}", 
                        0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, &key);
  if (result != ERROR_SUCCESS) {
    return;
  }
  
  nsCString wantedDriverId(driverId);
  normalizeDriverId(wantedDriverId);
  
  while((enumresult = RegEnumKeyEx(key, index, subkeyname, &dwcbData, NULL, NULL, NULL, NULL)) != ERROR_NO_MORE_ITEMS) {
    result = RegOpenKeyEx(key, subkeyname, 0, KEY_QUERY_VALUE, &subkey);
    if (result == ERROR_SUCCESS) {
      dwcbData = sizeof(value);
      result = RegQueryValueEx(subkey, "MatchingDeviceId", 0, NULL, (LPBYTE)value, &dwcbData);
      if (result == ERROR_SUCCESS) {
        nsCString matchingDeviceId(value);
        normalizeDriverId(matchingDeviceId);
        if (wantedDriverId.Equals(matchingDeviceId)) {
          result = RegQueryValueEx(subkey, "DriverVersion", 0, NULL, (LPBYTE)value, &dwcbData);
          if (result == ERROR_SUCCESS) 
            aDriverVersion.AssignLiteral(value);
          result = RegQueryValueEx(subkey, "DriverDate", 0, NULL, (LPBYTE)value, &dwcbData);
          if (result == ERROR_SUCCESS) 
            aDriverDate.AssignLiteral(value);
          break;
        }
      }
      RegCloseKey(subkey);
    }
    index++;
    dwcbData = sizeof(subkeyname);
  }
  
  RegCloseKey(key);
  return;
}
开发者ID:jonallengriffin,项目名称:halreftest,代码行数:47,代码来源:nsSystemInfoWin.cpp

示例9: escapedURL

bool
mozTXTToHTMLConv::CheckURLAndCreateHTML(
     const nsString& txtURL, const nsString& desc, const modetype mode,
     nsString& outputHTML)
{
  // Create *uri from txtURL
  nsCOMPtr<nsIURI> uri;
  nsresult rv;
  // Lazily initialize mIOService
  if (!mIOService)
  {
    mIOService = do_GetIOService();

    if (!mIOService)
      return false;
  }

  // See if the url should be linkified.
  NS_ConvertUTF16toUTF8 utf8URL(txtURL);
  if (!ShouldLinkify(utf8URL))
    return false;

  // it would be faster if we could just check to see if there is a protocol
  // handler for the url and return instead of actually trying to create a url...
  rv = mIOService->NewURI(utf8URL, nsnull, nsnull, getter_AddRefs(uri));

  // Real work
  if (NS_SUCCEEDED(rv) && uri)
  {
    outputHTML.AssignLiteral("<a class=\"moz-txt-link-");
    switch(mode)
    {
    case RFC1738:
      outputHTML.AppendLiteral("rfc1738");
      break;
    case RFC2396E:
      outputHTML.AppendLiteral("rfc2396E");
      break;
    case freetext:
      outputHTML.AppendLiteral("freetext");
      break;
    case abbreviated:
      outputHTML.AppendLiteral("abbreviated");
      break;
    default: break;
    }
    nsAutoString escapedURL(txtURL);
    EscapeStr(escapedURL, true);

    outputHTML.AppendLiteral("\" href=\"");
    outputHTML += escapedURL;
    outputHTML.AppendLiteral("\">");
    outputHTML += desc;
    outputHTML.AppendLiteral("</a>");
    return true;
  }
  else
    return false;
}
开发者ID:marshall,项目名称:mozilla-central,代码行数:59,代码来源:mozTXTToHTMLConv.cpp

示例10:

static void
AssignSourceNameHelper(nsIURI* aSourceURI, nsString& aSourceNameDest)
{
    if (!aSourceURI)
        return;

    if (NS_FAILED(NS_GetSanitizedURIStringFromURI(aSourceURI,
                                                  aSourceNameDest))) {
        aSourceNameDest.AssignLiteral("[nsIURI::GetSpec failed]");
    }
}
开发者ID:marcoscaceres,项目名称:gecko-dev,代码行数:11,代码来源:nsScriptError.cpp

示例11:

/*virtual*/
bool
nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName,
                           gfxFontStyle& aFontStyle)
{
    aFontName.AssignLiteral("\"Droid Sans\"");
    aFontStyle.style = NS_FONT_STYLE_NORMAL;
    aFontStyle.weight = NS_FONT_WEIGHT_NORMAL;
    aFontStyle.stretch = NS_FONT_STRETCH_NORMAL;
    aFontStyle.size = 9.0 * 96.0f / 72.0f;
    aFontStyle.systemFont = true;
    return true;
}
开发者ID:Lynart,项目名称:mozilla-central,代码行数:13,代码来源:nsLookAndFeel.cpp

示例12: switch

void
nsScreen::GetMozOrientation(nsString& aOrientation,
                            CallerType aCallerType) const
{
  switch (mScreenOrientation->DeviceType(aCallerType)) {
  case OrientationType::Portrait_primary:
    aOrientation.AssignLiteral("portrait-primary");
    break;
  case OrientationType::Portrait_secondary:
    aOrientation.AssignLiteral("portrait-secondary");
    break;
  case OrientationType::Landscape_primary:
    aOrientation.AssignLiteral("landscape-primary");
    break;
  case OrientationType::Landscape_secondary:
    aOrientation.AssignLiteral("landscape-secondary");
    break;
  default:
    MOZ_CRASH("Unacceptable screen orientation type.");
  }
}
开发者ID:marcoscaceres,项目名称:gecko-dev,代码行数:21,代码来源:nsScreen.cpp

示例13: CreateViewSourceURL

nsresult CViewSourceHTML::CreateViewSourceURL(const nsAString& linkUrl,
                                              nsString& viewSourceUrl) {
  nsCOMPtr<nsIURI> baseURI;
  nsCOMPtr<nsIURI> hrefURI;
  nsresult rv;

  // Default the view source URL to the empty string in case we fail.
  viewSourceUrl.Truncate();

  // Get the BaseURI.
  rv = GetBaseURI(getter_AddRefs(baseURI));
  NS_ENSURE_SUCCESS(rv, rv);

  // Use the link URL and the base URI to build a URI for the link.  Note that
  // the link URL may have untranslated entities in it.
  nsAutoString expandedLinkUrl;
  ExpandEntities(linkUrl, expandedLinkUrl);
  rv = NS_NewURI(getter_AddRefs(hrefURI), expandedLinkUrl, mCharset.get(), baseURI);
  NS_ENSURE_SUCCESS(rv, rv);

  // Get the absolute URL from the link URI.
  nsCString absoluteLinkUrl;
  hrefURI->GetSpec(absoluteLinkUrl);

  // URLs that execute script (e.g. "javascript:" URLs) should just be
  // ignored.  There's nothing reasonable we can do with them, and allowing
  // them to execute in the context of the view-source window presents a
  // security risk.  Just return the empty string in this case.
  PRBool openingExecutesScript = PR_FALSE;
  rv = NS_URIChainHasFlags(hrefURI, nsIProtocolHandler::URI_OPENING_EXECUTES_SCRIPT,
                           &openingExecutesScript);
  NS_ENSURE_SUCCESS(rv, NS_OK); // if there's an error, return the empty string
  if (openingExecutesScript) {
    return NS_OK;
  }

  // URLs that return data (e.g. "http:" URLs) should be prefixed with
  // "view-source:".  URLs that don't return data should just be returned
  // undecorated.
  PRBool doesNotReturnData = PR_FALSE;
  rv = NS_URIChainHasFlags(hrefURI, nsIProtocolHandler::URI_DOES_NOT_RETURN_DATA,
                           &doesNotReturnData);
  NS_ENSURE_SUCCESS(rv, NS_OK);  // if there's an error, return the empty string
  if (!doesNotReturnData) {
    viewSourceUrl.AssignLiteral("view-source:");    
  }

  viewSourceUrl.AppendWithConversion(absoluteLinkUrl);

  return NS_OK;
}
开发者ID:amyvmiwei,项目名称:firefox,代码行数:51,代码来源:nsViewSourceHTML.cpp

示例14: 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");
  }
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:22,代码来源:MapiApi.cpp

示例15:

ENameValueFlag
XULMenubarAccessible::NativeName(nsString& aName) const
{
  aName.AssignLiteral("Application");
  return eNameOK;
}
开发者ID:escapewindow,项目名称:gecko-dev,代码行数:6,代码来源:XULMenuAccessible.cpp


注:本文中的nsString::AssignLiteral方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。