本文整理汇总了C++中nsAString::CharAt方法的典型用法代码示例。如果您正苦于以下问题:C++ nsAString::CharAt方法的具体用法?C++ nsAString::CharAt怎么用?C++ nsAString::CharAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsAString
的用法示例。
在下文中一共展示了nsAString::CharAt方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool
ValidateGLSLString(const nsAString& string, WebGLContext* webgl, const char* funcName)
{
for (size_t i = 0; i < string.Length(); ++i) {
if (!IsValidGLSLCharacter(string.CharAt(i))) {
webgl->ErrorInvalidValue("%s: String contains the illegal character '%d'",
funcName, string.CharAt(i));
return false;
}
}
return true;
}
示例2: HasRTLChars
PRBool HasRTLChars(nsAString& aString)
{
PRInt32 length = aString.Length();
for (PRInt32 i = 0; i < length; i++) {
if ((UCS2_CHAR_IS_BIDI(aString.CharAt(i)) ) ||
((NS_IS_HIGH_SURROGATE(aString.CharAt(i))) &&
(++i < length) &&
(NS_IS_LOW_SURROGATE(aString.CharAt(i))) &&
(UTF32_CHAR_IS_BIDI(SURROGATE_TO_UCS4(aString.CharAt(i-1),
aString.CharAt(i)))))) {
return PR_TRUE;
}
}
return PR_FALSE;
}
示例3: IsValidExpiryYear
bool BasicCardService::IsValidExpiryYear(const nsAString& aExpiryYear) {
// ExpiryYear can only be
// 1. empty string
// 2. 0000 ~ 9999
if (!aExpiryYear.IsEmpty()) {
if (aExpiryYear.Length() != 4) {
return false;
}
for (uint32_t index = 0; index < 4; ++index) {
if (aExpiryYear.CharAt(index) < '0' || aExpiryYear.CharAt(index) > '9') {
return false;
}
}
}
return true;
}
示例4: StringEndsWith
bool
nsMsgLocalStoreUtils::nsShouldIgnoreFile(nsAString& name)
{
PRUnichar firstChar = name.First();
if (firstChar == '.' || firstChar == '#' ||
name.CharAt(name.Length() - 1) == '~')
return true;
if (name.LowerCaseEqualsLiteral("msgfilterrules.dat") ||
name.LowerCaseEqualsLiteral("rules.dat") ||
name.LowerCaseEqualsLiteral("filterlog.html") ||
name.LowerCaseEqualsLiteral("junklog.html") ||
name.LowerCaseEqualsLiteral("rulesbackup.dat"))
return true;
// don't add summary files to the list of folders;
// don't add popstate files to the list either, or rules (sort.dat).
if (StringEndsWith(name, NS_LITERAL_STRING(".snm")) ||
name.LowerCaseEqualsLiteral("popstate.dat") ||
name.LowerCaseEqualsLiteral("sort.dat") ||
name.LowerCaseEqualsLiteral("mailfilt.log") ||
name.LowerCaseEqualsLiteral("filters.js") ||
StringEndsWith(name, NS_LITERAL_STRING(".toc")))
return true;
// ignore RSS data source files
if (name.LowerCaseEqualsLiteral("feeds.rdf") ||
name.LowerCaseEqualsLiteral("feeditems.rdf"))
return true;
// The .mozmsgs dir is for spotlight support
return (StringEndsWith(name, NS_LITERAL_STRING(".mozmsgs")) ||
StringEndsWith(name, NS_LITERAL_STRING(".sbd")) ||
StringEndsWith(name, NS_LITERAL_STRING(SUMMARY_SUFFIX)));
}
示例5: StringBeginsWith
static bool
IsMatchingParameter(const nsAString &aString, const nsAString &aParameterName)
{
// The first two tests ensure aString.Length() > aParameterName.Length()
// so it's then safe to do the third test
return StringBeginsWith(aString, aParameterName) &&
aString.Last() == ')' &&
aString.CharAt(aParameterName.Length()) == '(';
}
示例6: ValidateGLSLString
bool WebGLContext::ValidateGLSLString(const nsAString& string, const char *info)
{
for (PRUint32 i = 0; i < string.Length(); ++i) {
if (!ValidateGLSLCharacter(string.CharAt(i))) {
ErrorInvalidValue("%s: string contains the illegal character '%d'", info, string.CharAt(i));
return false;
}
}
return true;
}
示例7: IsValidExpiryMonth
bool BasicCardService::IsValidExpiryMonth(const nsAString& aExpiryMonth) {
// ExpiryMonth can only be
// 1. empty string
// 2. 01 ~ 12
if (aExpiryMonth.IsEmpty()) {
return true;
}
if (aExpiryMonth.Length() != 2) {
return false;
}
// can only be 00 ~ 09
if (aExpiryMonth.CharAt(0) == '0') {
if (aExpiryMonth.CharAt(1) < '0' || aExpiryMonth.CharAt(1) > '9') {
return false;
}
return true;
}
// can only be 11 or 12
if (aExpiryMonth.CharAt(0) == '1') {
if (aExpiryMonth.CharAt(1) != '1' && aExpiryMonth.CharAt(1) != '2') {
return false;
}
return true;
}
return false;
}
示例8: RegQueryValueExW
/**
* Provides a fallback for getting the path to APPDATA or LOCALAPPDATA by
* querying the registry when the call to SHGetSpecialFolderLocation or
* SHGetPathFromIDListW is unable to provide these paths (Bug 513958).
*/
static nsresult
GetRegWindowsAppDataFolder(bool aLocal, nsAString& _retval)
{
HKEY key;
NS_NAMED_LITERAL_STRING(keyName,
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders");
DWORD res = ::RegOpenKeyExW(HKEY_CURRENT_USER, keyName.get(), 0, KEY_READ,
&key);
if (res != ERROR_SUCCESS) {
_retval.SetLength(0);
return NS_ERROR_NOT_AVAILABLE;
}
DWORD type, size;
res = RegQueryValueExW(key, (aLocal ? L"Local AppData" : L"AppData"),
nullptr, &type, nullptr, &size);
// The call to RegQueryValueExW must succeed, the type must be REG_SZ, the
// buffer size must not equal 0, and the buffer size be a multiple of 2.
if (res != ERROR_SUCCESS || type != REG_SZ || size == 0 || size % 2 != 0) {
::RegCloseKey(key);
_retval.SetLength(0);
return NS_ERROR_NOT_AVAILABLE;
}
// |size| may or may not include room for the terminating null character
DWORD resultLen = size / 2;
_retval.SetLength(resultLen);
nsAString::iterator begin;
_retval.BeginWriting(begin);
if (begin.size_forward() != resultLen) {
::RegCloseKey(key);
_retval.SetLength(0);
return NS_ERROR_NOT_AVAILABLE;
}
res = RegQueryValueExW(key, (aLocal ? L"Local AppData" : L"AppData"),
nullptr, nullptr, (LPBYTE) begin.get(), &size);
::RegCloseKey(key);
if (res != ERROR_SUCCESS) {
_retval.SetLength(0);
return NS_ERROR_NOT_AVAILABLE;
}
if (!_retval.CharAt(resultLen - 1)) {
// It was already null terminated.
_retval.Truncate(resultLen - 1);
}
return NS_OK;
}
示例9: HasRTLChars
PRBool HasRTLChars(const nsAString& aString)
{
// This is used to determine whether to enable bidi if a string has
// right-to-left characters. To simplify things, anything that could be a
// surrogate or RTL presentation form is covered just by testing >= 0xD800).
// It's fine to enable bidi in rare cases where it actually isn't needed.
PRInt32 length = aString.Length();
for (PRInt32 i = 0; i < length; i++) {
PRUnichar ch = aString.CharAt(i);
if (ch >= 0xD800 || IS_IN_BMP_RTL_BLOCK(ch)) {
return PR_TRUE;
}
}
return PR_FALSE;
}
示例10: PromiseFlatString
NS_IMETHODIMP
nsWindowsRegKey::ReadStringValue(const nsAString& aName, nsAString& aResult)
{
if (NS_WARN_IF(!mKey)) {
return NS_ERROR_NOT_INITIALIZED;
}
DWORD type, size;
const nsString& flatName = PromiseFlatString(aName);
LONG rv = RegQueryValueExW(mKey, flatName.get(), 0, &type, nullptr, &size);
if (rv != ERROR_SUCCESS) {
return NS_ERROR_FAILURE;
}
// This must be a string type in order to fetch the value as a string.
// We're being a bit forgiving here by allowing types other than REG_SZ.
if (type != REG_SZ && type != REG_EXPAND_SZ && type != REG_MULTI_SZ) {
return NS_ERROR_FAILURE;
}
// The buffer size must be a multiple of 2.
if (size % 2 != 0) {
return NS_ERROR_UNEXPECTED;
}
if (size == 0) {
aResult.Truncate();
return NS_OK;
}
// |size| may or may not include the terminating null character.
DWORD resultLen = size / 2;
if (!aResult.SetLength(resultLen, mozilla::fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsAString::iterator begin;
aResult.BeginWriting(begin);
rv = RegQueryValueExW(mKey, flatName.get(), 0, &type, (LPBYTE)begin.get(),
&size);
if (!aResult.CharAt(resultLen - 1)) {
// The string passed to us had a null terminator in the final position.
aResult.Truncate(resultLen - 1);
}
// Expand the environment variables if needed
if (type == REG_EXPAND_SZ) {
const nsString& flatSource = PromiseFlatString(aResult);
resultLen = ExpandEnvironmentStringsW(flatSource.get(), nullptr, 0);
if (resultLen > 1) {
nsAutoString expandedResult;
// |resultLen| includes the terminating null character
--resultLen;
if (!expandedResult.SetLength(resultLen, mozilla::fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsAString::iterator begin;
expandedResult.BeginWriting(begin);
resultLen = ExpandEnvironmentStringsW(flatSource.get(),
wwc(begin.get()),
resultLen + 1);
if (resultLen <= 0) {
rv = ERROR_UNKNOWN_FEATURE;
aResult.Truncate();
} else {
rv = ERROR_SUCCESS;
aResult = expandedResult;
}
} else if (resultLen == 1) {
// It apparently expands to nothing (just a null terminator).
aResult.Truncate();
}
}
return (rv == ERROR_SUCCESS) ? NS_OK : NS_ERROR_FAILURE;
}