nsACString 编辑

« XPCOM API Reference

Summary

The nsACString abstract class represents a character string composed of single-byte storage units. This class is typically used to represent ASCII or UTF-8 character arrays.

#include "nsStringAPI.h"

  class nsACString { ... };

Typedefs

char_type [char]
Storage unit for this class.
self_type [nsACString]
An alias for the type of this class.
size_type [PRUint32]
Type used to represent the number of bytes stored in the string.
index_type [PRUint32]
Type used to represent an offset into the string.

Methods

BeginReading
The BeginReading function returns a const pointer to the first element of the string's internal buffer.
EndReading
The EndReading function returns a const char_type pointer to the element just beyond the last element of the string's internal buffer.
Length
The Length function returns the number of storage units in the string's internal buffer (not including the null-terminator if present).
Assign
The Assign family of functions sets the value of a string's internal buffer.
Replace
The Replace family of functions sets the value of a string's internal buffer.
Append
The Append family of functions appends a value to the end of a string's internal buffer.
Insert
The Insert family of functions inserts a value into a string's internal buffer.
Cut
The Cut function removes a section of the string's internal buffer.

Operators

operator=
This operator is a shortcut for the Assign family of functions.
operator+=
This operator is a shortcut for the Append family of functions.

Remarks

The nsACString class is never instantiated directly. It should be instantiated using a subclass, such as nsEmbedCString.

nsACString corresponds to the ACString and AUTF8String XPIDL data types. nsACString by itself does not imply a particular character encoding. That is, it may be used to store UTF-8 characters, ASCII characters, or any random binary data. The character encoding in use for a particular nsACString instance depends on the context in which it is used. If used with XPIDL, then the character encodings of the corresponding XPIDL data types applies.

nsACString may even hold data with embedded null bytes. Thus, the length of the data contained in the nsACString should be determined by calling the nsACString::Length() method.

The methods defined on nsACString are implemented as inline wrappers around the XPCOM string functions, prefixed with NS_CString. See, for example, NS_CStringGetData.

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:44 次

字数:4871

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文