本文整理汇总了C++中nsString::FindChar方法的典型用法代码示例。如果您正苦于以下问题:C++ nsString::FindChar方法的具体用法?C++ nsString::FindChar怎么用?C++ nsString::FindChar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsString
的用法示例。
在下文中一共展示了nsString::FindChar方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoErrTest
void DoErrTest(nsString& aString) {
int32_t pos=aString.FindChar(0);
if(kNotFound<pos) {
if(aString.Length()-1!=pos) {
}
}
}
示例2: if
nsresult
nsRDFParserUtils::GetQuotedAttributeValue(const nsString& aSource,
const nsString& aAttribute,
nsString& aValue)
{
static const char kQuote = '\"';
static const char kApostrophe = '\'';
PRInt32 offset;
PRInt32 endOffset = -1;
nsresult result = NS_OK;
offset = aSource.Find(aAttribute, 0);
if (-1 != offset) {
offset = aSource.FindChar('=', offset);
PRUnichar next = aSource.CharAt(++offset);
if (kQuote == next) {
endOffset = aSource.FindChar(kQuote, ++offset);
}
else if (kApostrophe == next) {
endOffset = aSource.FindChar(kApostrophe, ++offset);
}
if (-1 != endOffset) {
aSource.Mid(aValue, offset, endOffset-offset);
}
else {
// Mismatched quotes - return an error
result = NS_ERROR_FAILURE;
}
}
else {
aValue.Truncate();
}
return result;
}
示例3: 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);
}
}
示例4: ReadWhile
/**
* Consume chars as long as they are <i>in</i> the
* given validSet of input chars.
*
* @update gess 3/25/98
* @param aString will contain the result of this method
* @param aValidSet is an ordered string that contains the
* valid characters
* @return error code
*/
nsresult nsScanner::ReadWhile(nsString& aString,
nsString& aValidSet,
PRBool addTerminal){
if (!mSlidingBuffer) {
return kEOF;
}
PRUnichar theChar=0;
nsresult result=Peek(theChar);
nsScannerIterator origin, current, end;
origin = mCurrentPosition;
current = origin;
end = mEndPosition;
while(current != end) {
theChar=*current;
if (theChar == '\0') {
ReplaceCharacter(current, sInvalid);
theChar = sInvalid;
}
if(theChar) {
PRInt32 pos=aValidSet.FindChar(theChar);
if(kNotFound==pos) {
if(addTerminal)
++current;
AppendUnicodeTo(origin, current, aString);
break;
}
}
++current;
}
SetPosition(current);
if (current == end) {
AppendUnicodeTo(origin, current, aString);
return FillBuffer();
}
//DoErrTest(aString);
return result;
}
示例5: 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();
}
示例6: ExtractType
void nsEudoraCompose::ExtractType(nsString& str)
{
nsString tStr;
int32_t 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);
}
// if multipart then ignore it since no outlook message body is ever
// valid multipart!
if (StringBeginsWith(str, NS_LITERAL_STRING("multipart/"), nsCaseInsensitiveStringComparator()))
str.Truncate();
}
示例7: SkipTo
/**
* Skip over chars until they're in aValidSet
*
* @update gess 3/25/98
* @param aValid set is an ordered string that
* contains chars you're looking for
* @return error code
*/
nsresult nsScanner::SkipTo(nsString& aValidSet){
if (!mSlidingBuffer) {
return kEOF;
}
PRUnichar ch=0;
nsresult result=NS_OK;
while(NS_OK==result) {
result=Peek(ch);
if(NS_OK == result) {
PRInt32 pos=aValidSet.FindChar(ch);
if(kNotFound!=pos) {
break;
}
GetChar(ch);
}
else break;
} //while
return result;
}
示例8:
// See if the string has any lines longer than longLineLen:
// if so, we presume formatting is wonky (e.g. the node has been edited)
// and we'd better rewrap the whole text node.
bool
nsXHTMLContentSerializer::HasLongLines(const nsString& text, int32_t& aLastNewlineOffset)
{
uint32_t start=0;
uint32_t theLen = text.Length();
bool rv = false;
aLastNewlineOffset = kNotFound;
for (start = 0; start < theLen; ) {
int32_t eol = text.FindChar('\n', start);
if (eol < 0) {
eol = text.Length();
}
else {
aLastNewlineOffset = eol;
}
if (int32_t(eol - start) > kLongLineLen)
rv = true;
start = eol + 1;
}
return rv;
}
示例9:
// See if the string has any lines longer than longLineLen:
// if so, we presume formatting is wonky (e.g. the node has been edited)
// and we'd better rewrap the whole text node.
PRBool
nsXHTMLContentSerializer::HasLongLines(const nsString& text, PRInt32& aLastNewlineOffset)
{
PRUint32 start=0;
PRUint32 theLen = text.Length();
PRBool rv = PR_FALSE;
aLastNewlineOffset = kNotFound;
for (start = 0; start < theLen; ) {
PRInt32 eol = text.FindChar('\n', start);
if (eol < 0) {
eol = text.Length();
}
else {
aLastNewlineOffset = eol;
}
if (PRInt32(eol - start) > kLongLineLen)
rv = PR_TRUE;
start = eol + 1;
}
return rv;
}
示例10: SkipOver
/**
* Skip over chars as long as they're in aSkipSet
*
* @update gess 3/25/98
* @param aSkipSet is an ordered string.
* @return error code
*/
nsresult nsScanner::SkipOver(nsString& aSkipSet){
if (!mSlidingBuffer) {
return kEOF;
}
PRUnichar theChar=0;
nsresult result=NS_OK;
while(NS_OK==result) {
result=Peek(theChar);
if(NS_OK == result) {
PRInt32 pos=aSkipSet.FindChar(theChar);
if(kNotFound==pos) {
break;
}
GetChar(theChar);
}
else break;
} //while
return result;
}
示例11: ExtractType
void nsEudoraCompose::ExtractType( nsString& str)
{
nsString tStr;
PRInt32 idx = str.FindChar( ';');
if (idx != -1) {
str.Left( tStr, idx);
str = tStr;
}
str.Trim( kWhitespace);
if ((str.CharAt( 0) == '"') && (str.Length() > 2)) {
str.Mid( tStr, 1, str.Length() - 2);
str = tStr;
str.Trim( kWhitespace);
}
// if multipart then ignore it since no outlook message body is ever
// valid multipart!
if (str.Length() > 10) {
str.Left( tStr, 10);
if (tStr.LowerCaseEqualsLiteral("multipart/"))
str.Truncate();
}
}
示例12: rest
void
mozTXTToHTMLConv::ScanHTML(nsString& aInString, PRUint32 whattodo, nsString &aOutString)
{
// some common variables we were recalculating
// every time inside the for loop...
PRInt32 lengthOfInString = aInString.Length();
const PRUnichar * uniBuffer = aInString.get();
#ifdef DEBUG_BenB_Perf
PRTime parsing_start = PR_IntervalNow();
#endif
// Look for simple entities not included in a tags and scan them.
/* Skip all tags ("<[...]>") and content in an a tag ("<a[...]</a>")
or in a tag ("<!--[...]-->").
Unescape the rest (text between tags) and pass it to ScanTXT. */
for (PRInt32 i = 0; i < lengthOfInString;)
{
if (aInString[i] == '<') // html tag
{
PRUint32 start = PRUint32(i);
if (nsCRT::ToLower((char)aInString[PRUint32(i) + 1]) == 'a')
// if a tag, skip until </a>
{
i = aInString.Find("</a>", true, i);
if (i == kNotFound)
i = lengthOfInString;
else
i += 4;
}
else if (aInString[PRUint32(i) + 1] == '!' && aInString[PRUint32(i) + 2] == '-' &&
aInString[PRUint32(i) + 3] == '-')
//if out-commended code, skip until -->
{
i = aInString.Find("-->", false, i);
if (i == kNotFound)
i = lengthOfInString;
else
i += 3;
}
else // just skip tag (attributes etc.)
{
i = aInString.FindChar('>', i);
if (i == kNotFound)
i = lengthOfInString;
else
i++;
}
aOutString.Append(&uniBuffer[start], PRUint32(i) - start);
}
else
{
PRUint32 start = PRUint32(i);
i = aInString.FindChar('<', i);
if (i == kNotFound)
i = lengthOfInString;
nsString tempString;
tempString.SetCapacity(PRUint32((PRUint32(i) - start) * growthRate));
UnescapeStr(uniBuffer, start, PRUint32(i) - start, tempString);
ScanTXT(tempString.get(), tempString.Length(), whattodo, aOutString);
}
}
#ifdef DEBUG_BenB_Perf
printf("ScanHTML time: %d ms\n", PR_IntervalToMilliseconds(PR_IntervalNow() - parsing_start));
#endif
}
示例13: if
void
mozTXTToHTMLConv::ScanHTML(nsString& aInString, uint32_t whattodo, nsString &aOutString)
{
// some common variables we were recalculating
// every time inside the for loop...
int32_t lengthOfInString = aInString.Length();
const char16_t * uniBuffer = aInString.get();
#ifdef DEBUG_BenB_Perf
PRTime parsing_start = PR_IntervalNow();
#endif
// Look for simple entities not included in a tags and scan them.
// Skip all tags ("<[...]>") and content in an a link tag ("<a [...]</a>"),
// comment tag ("<!--[...]-->"), style tag, script tag or head tag.
// Unescape the rest (text between tags) and pass it to ScanTXT.
for (int32_t i = 0; i < lengthOfInString;)
{
if (aInString[i] == '<') // html tag
{
int32_t start = i;
if (Substring(aInString, i + 1, 2).LowerCaseEqualsASCII("a "))
// if a tag, skip until </a>.
// Make sure there's a space after, not to match "abbr".
{
i = aInString.Find("</a>", true, i);
if (i == kNotFound)
i = lengthOfInString;
else
i += 4;
}
else if (Substring(aInString, i + 1, 3).LowerCaseEqualsASCII("!--"))
// if out-commended code, skip until -->
{
i = aInString.Find("-->", false, i);
if (i == kNotFound)
i = lengthOfInString;
else
i += 3;
}
else if (Substring(aInString, i + 1, 5).LowerCaseEqualsASCII("style") &&
(aInString.CharAt(i + 6) == ' ' || aInString.CharAt(i + 6) == '>'))
// if style tag, skip until </style>
{
i = aInString.Find("</style>", true, i);
if (i == kNotFound)
i = lengthOfInString;
else
i += 8;
}
else if (Substring(aInString, i + 1, 6).LowerCaseEqualsASCII("script") &&
(aInString.CharAt(i + 7) == ' ' || aInString.CharAt(i + 7) == '>'))
// if script tag, skip until </script>
{
i = aInString.Find("</script>", true, i);
if (i == kNotFound)
i = lengthOfInString;
else
i += 9;
}
else if (Substring(aInString, i + 1, 4).LowerCaseEqualsASCII("head") &&
(aInString.CharAt(i + 5) == ' ' || aInString.CharAt(i + 5) == '>'))
// if head tag, skip until </head>
// Make sure not to match <header>.
{
i = aInString.Find("</head>", true, i);
if (i == kNotFound)
i = lengthOfInString;
else
i += 7;
}
else // just skip tag (attributes etc.)
{
i = aInString.FindChar('>', i);
if (i == kNotFound)
i = lengthOfInString;
else
i++;
}
aOutString.Append(&uniBuffer[start], i - start);
}
else
{
uint32_t start = uint32_t(i);
i = aInString.FindChar('<', i);
if (i == kNotFound)
i = lengthOfInString;
nsString tempString;
tempString.SetCapacity(uint32_t((uint32_t(i) - start) * growthRate));
UnescapeStr(uniBuffer, start, uint32_t(i) - start, tempString);
ScanTXT(tempString.get(), tempString.Length(), whattodo, aOutString);
}
}
#ifdef DEBUG_BenB_Perf
printf("ScanHTML time: %d ms\n", PR_IntervalToMilliseconds(PR_IntervalNow() - parsing_start));
#endif
}