本文整理汇总了C++中nsString::Truncate方法的典型用法代码示例。如果您正苦于以下问题:C++ nsString::Truncate方法的具体用法?C++ nsString::Truncate怎么用?C++ nsString::Truncate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsString
的用法示例。
在下文中一共展示了nsString::Truncate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
ENameValueFlag
RootAccessible::Name(nsString& aName)
{
aName.Truncate();
if (mRoleMapEntry) {
Accessible::Name(aName);
if (!aName.IsEmpty())
return eNameOK;
}
nsCOMPtr<nsIDOMDocument> document = do_QueryInterface(mDocument);
NS_ENSURE_TRUE(document, eNameOK);
document->GetTitle(aName);
return eNameOK;
}
示例2: ConvertJSValToStr
void ConvertJSValToStr(nsString& aString,
JSContext* aContext,
jsval aValue)
{
JSString *jsstring;
if ( !JSVAL_IS_NULL(aValue) &&
(jsstring = JS_ValueToString(aContext, aValue)) != nsnull)
{
aString.Assign(reinterpret_cast<const PRUnichar*>(JS_GetStringChars(jsstring)));
}
else
{
aString.Truncate();
}
}
示例3:
ENameValueFlag
HTMLListBulletAccessible::Name(nsString &aName)
{
aName.Truncate();
// Native anonymous content, ARIA can't be used. Get list bullet text.
nsBlockFrame* blockFrame = do_QueryFrame(mContent->GetPrimaryFrame());
if (blockFrame) {
blockFrame->GetBulletText(aName);
// Append space otherwise bullets are jammed up against list text.
aName.Append(' ');
}
return eNameOK;
}
示例4: splitString
static void splitString(nsString& aSource, nsString& aTarget)
{
aTarget.Truncate() ;
PRInt32 offset = aSource.FindChar('\n') ;
if (offset >= 0) {
const PRUnichar *source = aSource.get() + offset + 1 ;
while (*source) {
if (*source == '\n' || *source == '\r') { aTarget.Append(PRUnichar(' ')) ; }
else { aTarget.Append(*source) ; }
++ source ;
}
aSource.SetLength(offset);
}
}
示例5:
void
URL::GetHostname(nsString& aHostname, ErrorResult& aRv) const
{
aHostname.Truncate();
nsAutoCString tmp;
nsresult rv = mURI->GetHost(tmp);
if (NS_SUCCEEDED(rv)) {
if (tmp.FindChar(':') != -1) { // Escape IPv6 address
MOZ_ASSERT(!tmp.Length() ||
(tmp[0] !='[' && tmp[tmp.Length() - 1] != ']'));
tmp.Insert('[', 0);
tmp.Append(']');
}
CopyUTF8toUTF16(tmp, aHostname);
}
}
示例6: switch
void
PopupBoxObject::GetAlignmentPosition(nsString& positionStr)
{
positionStr.Truncate();
// This needs to flush layout.
nsMenuPopupFrame *menuPopupFrame = do_QueryFrame(GetFrame(true));
if (!menuPopupFrame)
return;
int8_t position = menuPopupFrame->GetAlignmentPosition();
switch (position) {
case POPUPPOSITION_AFTERSTART:
positionStr.AssignLiteral("after_start");
break;
case POPUPPOSITION_AFTEREND:
positionStr.AssignLiteral("after_end");
break;
case POPUPPOSITION_BEFORESTART:
positionStr.AssignLiteral("before_start");
break;
case POPUPPOSITION_BEFOREEND:
positionStr.AssignLiteral("before_end");
break;
case POPUPPOSITION_STARTBEFORE:
positionStr.AssignLiteral("start_before");
break;
case POPUPPOSITION_ENDBEFORE:
positionStr.AssignLiteral("end_before");
break;
case POPUPPOSITION_STARTAFTER:
positionStr.AssignLiteral("start_after");
break;
case POPUPPOSITION_ENDAFTER:
positionStr.AssignLiteral("end_after");
break;
case POPUPPOSITION_OVERLAP:
positionStr.AssignLiteral("overlap");
break;
case POPUPPOSITION_AFTERPOINTER:
positionStr.AssignLiteral("after_pointer");
break;
default:
// Leave as an empty string.
break;
}
}
示例7: textBox
void
nsXULTextFieldAccessible::Value(nsString& aValue)
{
aValue.Truncate();
if (NativeRole() == roles::PASSWORD_TEXT) // Don't return password text!
return;
nsCOMPtr<nsIDOMXULTextBoxElement> textBox(do_QueryInterface(mContent));
if (textBox) {
textBox->GetValue(aValue);
return;
}
nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mContent));
if (menuList)
menuList->GetLabel(aValue);
}
示例8: textArea
void
HTMLTextFieldAccessible::Value(nsString& aValue)
{
aValue.Truncate();
if (NativeState() & states::PROTECTED) // Don't return password text!
return;
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mContent));
if (textArea) {
textArea->GetValue(aValue);
return;
}
HTMLInputElement* input = HTMLInputElement::FromContent(mContent);
if (input)
input->GetValue(aValue);
}
示例9: Name
ENameValueFlag XULTreeGridRowAccessible::Name(nsString& aName) const {
aName.Truncate();
// XXX: the row name sholdn't be a concatenation of cell names (bug 664384).
RefPtr<nsTreeColumn> column = nsCoreUtils::GetFirstSensibleColumn(mTree);
while (column) {
if (!aName.IsEmpty()) aName.Append(' ');
nsAutoString cellName;
GetCellName(column, cellName);
aName.Append(cellName);
column = nsCoreUtils::GetNextSensibleColumn(column);
}
return eNameOK;
}
示例10: GetBundle
nsresult
nsParserMsgUtils::GetLocalizedStringByID(const char * aPropFileName, PRUint32 aID, nsString& oVal)
{
oVal.Truncate();
nsCOMPtr<nsIStringBundle> bundle;
nsresult rv = GetBundle(aPropFileName,getter_AddRefs(bundle));
if (NS_SUCCEEDED(rv) && bundle) {
nsXPIDLString valUni;
rv = bundle->GetStringFromID(aID, getter_Copies(valUni));
if (NS_SUCCEEDED(rv) && valUni) {
oVal.Assign(valUni);
}
}
return rv;
}
示例11: Elements
nsresult
CryptoBuffer::ToJwkBase64(nsString& aBase64) const
{
// Shortcut for the empty octet string
if (Length() == 0) {
aBase64.Truncate();
return NS_OK;
}
nsAutoCString base64;
nsresult rv = Base64URLEncode(Length(), Elements(),
Base64URLEncodePaddingPolicy::Omit, base64);
NS_ENSURE_SUCCESS(rv, rv);
CopyASCIItoUTF16(base64, aBase64);
return NS_OK;
}
示例12: Value
void HTMLTextFieldAccessible::Value(nsString& aValue) const {
aValue.Truncate();
if (NativeState() & states::PROTECTED) // Don't return password text!
return;
HTMLTextAreaElement* textArea = HTMLTextAreaElement::FromNode(mContent);
if (textArea) {
textArea->GetValue(aValue);
return;
}
HTMLInputElement* input = HTMLInputElement::FromNode(mContent);
if (input) {
// Pass NonSystem as the caller type, to be safe. We don't expect to have a
// file input here.
input->GetValue(aValue, CallerType::NonSystem);
}
}
示例13: ExtractCharset
void nsEudoraCompose::ExtractCharset(nsString& str)
{
int32_t idx = MsgFind(str, "charset=", true, 0);
if (idx != -1) {
str.Cut(0, idx + 8);
idx = str.FindChar(';');
if (idx != -1)
str.SetLength(idx);
str.Trim(kWhitespace);
if ((str.CharAt(0) == '"') && (str.Length() > 2)) {
str.SetLength(str.Length() - 1);
str.Cut(0, 1);
str.Trim(kWhitespace);
}
}
else
str.Truncate();
}
示例14:
//--------------------------------------------------------
// Return localized string
static nsresult
GetLocalizedString(nsIStringBundle* aStrBundle, const char* aKey, nsString& oVal)
{
NS_ENSURE_ARG_POINTER(aStrBundle);
NS_ENSURE_ARG_POINTER(aKey);
// Determine default label from string bundle
nsXPIDLString valUni;
nsAutoString key;
key.AssignWithConversion(aKey);
nsresult rv = aStrBundle->GetStringFromName(key.get(), getter_Copies(valUni));
if (NS_SUCCEEDED(rv) && valUni) {
oVal.Assign(valUni);
} else {
oVal.Truncate();
}
return rv;
}
示例15: url
void
URL::GetSearch(nsString& aSearch) const
{
aSearch.Truncate();
nsCOMPtr<nsIURL> url(do_QueryInterface(mURI));
if (!url) {
// Do not throw! Not having a valid URI or URL should result in an empty
// string.
return;
}
nsAutoCString search;
nsresult rv = url->GetQuery(search);
if (NS_SUCCEEDED(rv) && !search.IsEmpty()) {
CopyUTF8toUTF16(NS_LITERAL_CSTRING("?") + search, aSearch);
}
}