nsACString 编辑
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论