本文整理汇总了C++中nsCString::FindChar方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCString::FindChar方法的具体用法?C++ nsCString::FindChar怎么用?C++ nsCString::FindChar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsCString
的用法示例。
在下文中一共展示了nsCString::FindChar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/* static */
nsresult
DataStorage::ValidateKeyAndValue(const nsCString& aKey, const nsCString& aValue)
{
if (aKey.IsEmpty()) {
return NS_ERROR_INVALID_ARG;
}
if (aKey.Length() > 256) {
return NS_ERROR_INVALID_ARG;
}
int32_t delimiterIndex = aKey.FindChar('\t', 0);
if (delimiterIndex >= 0) {
return NS_ERROR_INVALID_ARG;
}
delimiterIndex = aKey.FindChar('\n', 0);
if (delimiterIndex >= 0) {
return NS_ERROR_INVALID_ARG;
}
delimiterIndex = aValue.FindChar('\n', 0);
if (delimiterIndex >= 0) {
return NS_ERROR_INVALID_ARG;
}
if (aValue.Length() > 1024) {
return NS_ERROR_INVALID_ARG;
}
return NS_OK;
}
示例2: while
void nsEudoraWin32::ConvertPath( nsCString& str)
{
nsCString temp;
nsCString path;
PRInt32 idx = 0;
PRInt32 start = 0;
nsCString search;
idx = str.FindChar( '\\', idx);
if ((idx == 2) && (str.CharAt( 1) == ':'))
{
str.Left( path, 3);
idx++;
idx = str.FindChar( '\\', idx);
start = 3;
if ((idx == -1) && (str.Length() > 3))
{
str.Right( temp, str.Length() - start);
path.Append( temp);
}
}
WIN32_FIND_DATA findFileData;
while (idx != -1)
{
str.Mid( temp, start, idx - start);
search = path;
search.Append( temp);
HANDLE h = FindFirstFile( search.get(), &findFileData);
if (h == INVALID_HANDLE_VALUE)
return;
path.Append( findFileData.cFileName);
idx++;
start = idx;
idx = str.FindChar( '\\', idx);
FindClose( h);
if (idx != -1)
path.Append( '\\');
else
{
str.Right( temp, str.Length() - start);
path.Append( '\\');
path.Append( temp);
}
}
str = path;
}
示例3: ExtractNoteField
void nsEudoraAddress::ExtractNoteField( nsCString& note, nsCString& value, const char *pFieldName)
{
value.Truncate();
nsCString field("<");
field.Append( pFieldName);
field.Append( ':');
/*
this is a bit of a cheat, but there's no reason it won't work
fine for us, even better than Eudora in some cases!
*/
PRInt32 idx = note.Find( field);
if (idx != -1) {
idx += field.Length();
PRInt32 endIdx = note.FindChar( '>', idx);
if (endIdx == -1)
endIdx = note.Length() - 1;
note.Mid( value, idx, endIdx - idx);
idx -= field.Length();
nsCString tempL;
if (idx)
note.Left( tempL, idx);
nsCString tempR;
note.Right( tempR, note.Length() - endIdx - 1);
note = tempL;
note.Append( tempR);
}
}
示例4: key
static inline bool
CheckHeaderKey(const nsCString &aHeader, const char *aKeyString)
{
nsAutoCString key(StringHead(aHeader, aHeader.FindChar(':')));
key.Trim(" \t");
return key.Equals(aKeyString);
}
示例5: DoErrTest
void DoErrTest(nsCString& aString) {
PRInt32 pos=aString.FindChar(0);
if(kNotFound<pos) {
if(aString.Length()-1!=pos) {
}
}
}
示例6: Substring
void
XRemoteService::FindRestInList(nsCString &aString, nsCString &retString,
PRUint32 *aIndexRet)
{
// init our return
*aIndexRet = 0;
nsCString tempString;
PRInt32 strIndex;
// find out if there's a comma from the start of the string
strIndex = aString.FindChar(',');
// give up now if you can
if (strIndex == kNotFound)
return;
// cut the string down to the first ,
tempString = Substring(aString, strIndex+1, aString.Length());
// strip off leading + trailing whitespace
tempString.Trim(" ", PR_TRUE, PR_TRUE);
// see if we've reduced it to nothing
if (tempString.IsEmpty())
return;
*aIndexRet = strIndex;
// otherwise, return it as a new C string
retString = tempString;
}
示例7: nsUnescapeCount
nsresult
nsGopherContentStream::ParseTypeAndSelector(char &type, nsCString &selector)
{
nsCAutoString buffer;
nsresult rv = mChannel->URI()->GetPath(buffer); // unescaped down below
if (NS_FAILED(rv))
return rv;
// No path given
if (buffer[0] == '\0' || (buffer[0] == '/' && buffer[1] == '\0')) {
type = '1';
selector.Truncate();
} else {
NS_ENSURE_STATE(buffer[1] != '\0');
type = buffer[1]; // Ignore leading '/'
// Do it this way in case selector contains embedded nulls after
// unescaping.
char *sel = buffer.BeginWriting() + 2;
PRInt32 count = nsUnescapeCount(sel);
selector.Assign(sel, count);
// NOTE: FindCharInSet cannot be used to search for a null byte.
if (selector.FindCharInSet("\t\n\r") != kNotFound ||
selector.FindChar('\0') != kNotFound) {
// gopher selectors cannot containt tab, cr, lf, or \0
return NS_ERROR_MALFORMED_URI;
}
}
return NS_OK;
}
示例8: while
/**
* Decodes the given base64 string.
*
* It returns its decoded string in its input.
*
* @param pBufInOut (inout) a buffer of the string
*/
void nsMsgBodyHandler::Base64Decode (nsCString &pBufInOut)
{
char *decodedBody = PL_Base64Decode(pBufInOut.get(), pBufInOut.Length(), nullptr);
if (decodedBody)
pBufInOut.Adopt(decodedBody);
int32_t offset = pBufInOut.FindChar('\n');
while (offset != -1) {
pBufInOut.Replace(offset, 1, ' ');
offset = pBufInOut.FindChar('\n', offset);
}
offset = pBufInOut.FindChar('\r');
while (offset != -1) {
pBufInOut.Replace(offset, 1, ' ');
offset = pBufInOut.FindChar('\r', offset);
}
}
示例9: nsParseImapMessageURI
/* parses ImapMessageURI */
nsresult nsParseImapMessageURI(const char* uri, nsCString& folderURI, PRUint32 *key, char **part)
{
if(!key)
return NS_ERROR_NULL_POINTER;
nsCAutoString uriStr(uri);
PRInt32 folderEnd = -1;
// imap-message uri's can have imap:// url strings tacked on the end,
// e.g., when opening/saving attachments. We don't want to look for '#'
// in that part of the uri, if the attachment name contains '#',
// so check for that here.
if (StringBeginsWith(uriStr, NS_LITERAL_CSTRING("imap-message")))
folderEnd = uriStr.Find("imap://");
PRInt32 keySeparator = MsgRFindChar(uriStr, '#', folderEnd);
if(keySeparator != -1)
{
PRInt32 keyEndSeparator = MsgFindCharInSet(uriStr, "/?&", keySeparator);
nsAutoString folderPath;
folderURI = StringHead(uriStr, keySeparator);
folderURI.Cut(4, 8); // cut out the _message part of imap-message:
// folder uri's don't have fully escaped usernames.
PRInt32 atPos = folderURI.FindChar('@');
if (atPos != -1)
{
nsCString unescapedName, escapedName;
PRInt32 userNamePos = folderURI.Find("//") + 2;
PRUint32 origUserNameLen = atPos - userNamePos;
if (NS_SUCCEEDED(MsgUnescapeString(Substring(folderURI, userNamePos,
origUserNameLen),
0, unescapedName)))
{
// Re-escape the username, matching the way we do it in uris, not the
// way necko escapes urls. See nsMsgIncomingServer::GetServerURI.
MsgEscapeString(unescapedName, nsINetUtil::ESCAPE_XALPHAS, escapedName);
folderURI.Replace(userNamePos, origUserNameLen, escapedName);
}
}
nsCAutoString keyStr;
if (keyEndSeparator != -1)
keyStr = Substring(uriStr, keySeparator + 1, keyEndSeparator - (keySeparator + 1));
else
keyStr = Substring(uriStr, keySeparator + 1);
*key = strtoul(keyStr.get(), nsnull, 10);
if (part && keyEndSeparator != -1)
{
PRInt32 partPos = MsgFind(uriStr, "part=", PR_FALSE, keyEndSeparator);
if (partPos != -1)
{
*part = ToNewCString(Substring(uriStr, keyEndSeparator));
}
}
}
return NS_OK;
}
示例10: while
// convert '"' to """
static void
rdf_EscapeQuotes(nsCString& s)
{
int32_t i = 0;
while ((i = s.FindChar('"', i)) != -1) {
s.Replace(i, 1, quot, sizeof(quot) - 1);
i += sizeof(quot) - 2;
}
}
示例11:
void nsEudoraWin32::GetServerAndUserName( const char *pSection, const char *pIni, nsCString& serverName, nsCString& userName, char *pBuff)
{
DWORD valSize;
int idx;
nsCString tStr;
serverName.Truncate();
userName.Truncate();
valSize = ::GetPrivateProfileString( pSection, "PopServer", "", pBuff, kIniValueSize, pIni);
if (valSize)
serverName = pBuff;
else
{
valSize = ::GetPrivateProfileString( pSection, "POPAccount", "", pBuff, kIniValueSize, pIni);
if (valSize)
{
serverName = pBuff;
idx = serverName.FindChar( '@');
if (idx != -1)
{
serverName.Right( tStr, serverName.Length() - idx - 1);
serverName = tStr;
}
}
}
valSize = ::GetPrivateProfileString( pSection, "LoginName", "", pBuff, kIniValueSize, pIni);
if (valSize)
userName = pBuff;
else
{
valSize = ::GetPrivateProfileString( pSection, "POPAccount", "", pBuff, kIniValueSize, pIni);
if (valSize)
{
userName = pBuff;
idx = userName.FindChar( '@');
if (idx != -1)
{
userName.Left( tStr, idx);
userName = tStr;
}
}
}
}
示例12: ConvertSearchKeyToAttrib
nsresult
nsBeckyFilters::ParseRuleLine(const nsCString &aLine,
nsMsgSearchAttribValue *aSearchAttribute,
nsMsgSearchOpValue *aSearchOperator,
nsString &aSearchKeyword)
{
int32_t firstColonPosition = aLine.FindChar(':');
if (firstColonPosition == -1 ||
(int32_t)aLine.Length() == firstColonPosition - 1) {
return NS_ERROR_FAILURE;
}
int32_t secondColonPosition = aLine.FindChar(':', firstColonPosition + 1);
if (secondColonPosition == -1 ||
(int32_t)aLine.Length() == secondColonPosition - 1) {
return NS_ERROR_FAILURE;
}
int32_t length = secondColonPosition - firstColonPosition - 1;
nsMsgSearchAttribValue searchAttribute;
searchAttribute = ConvertSearchKeyToAttrib(Substring(aLine, firstColonPosition + 1, length));
if (searchAttribute < 0)
return NS_ERROR_FAILURE;
int32_t tabPosition = aLine.FindChar('\t');
if (tabPosition == -1 ||
(int32_t)aLine.Length() == tabPosition - 1) {
return NS_ERROR_FAILURE;
}
nsMsgSearchOpValue searchOperator;
searchOperator = ConvertSearchFlagsToOperator(Substring(aLine, tabPosition + 1));
if (searchOperator < 0)
return NS_ERROR_FAILURE;
*aSearchOperator = searchOperator;
*aSearchAttribute = searchAttribute;
length = tabPosition - secondColonPosition - 1;
CopyUTF8toUTF16(Substring(aLine, secondColonPosition + 1, length), aSearchKeyword);
return NS_OK;
}
示例13: WebCL_parseOpenCLVersion
nsresult WebCL_parseOpenCLVersion (nsCString const& aVersionStr,
int& aVersionMajorOut,
int& aVersionMinorOut,
nsCString& aVendorSpecificInfoOut)
{
D_METHOD_START;
// Sanity check: make sure the OpenCL version string is something valid.
// It must begin with "OpenCL "
PRInt32 m1 = aVersionStr.FindChar (' ');
if (!nsCString(aVersionStr.get(), m1).EqualsLiteral("OpenCL"))
{
D_LOG (LOG_LEVEL_WARNING, "Version string does not begin with \"OpenCL\".");
return NS_ERROR_FAILURE;
}
// Major version
PRInt32 m2 = aVersionStr.FindChar('.', m1 + 1);
nsresult rv;
nsCOMPtr<nsIWritableVariant> variant = do_CreateInstance(NS_VARIANT_CONTRACTID, &rv);
rv = variant->SetAsACString (nsCString(aVersionStr.get() + m1, m2-m1));
NS_ENSURE_SUCCESS (rv, rv);
rv = variant->GetAsInt32 (&aVersionMajorOut);
NS_ENSURE_SUCCESS (rv, rv);
// Minor version
m1 = m2+1;
m2 = aVersionStr.FindChar(' ', m1);
rv = variant->SetAsACString (nsCString(aVersionStr.get() + m1, m2-m1));
NS_ENSURE_SUCCESS (rv, rv);
rv = variant->GetAsInt32 (&aVersionMinorOut);
NS_ENSURE_SUCCESS (rv, rv);
// Vendor specific information
aVendorSpecificInfoOut = nsCString (aVersionStr.get() + m2 + 1);
return NS_OK;
}
示例14:
nsresult
nsBeckyFilters::GetActionTarget(const nsCString &aLine,
nsCString &aTarget)
{
int32_t firstColonPosition = aLine.FindChar(':');
if (firstColonPosition < -1 ||
aLine.Length() == static_cast<uint32_t>(firstColonPosition)) {
return NS_ERROR_FAILURE;
}
aTarget.Assign(Substring(aLine, firstColonPosition + 1));
return NS_OK;
}
示例15: ToLowerCase
nsNullPrincipalURI::nsNullPrincipalURI(const nsCString &aSpec)
{
int32_t dividerPosition = aSpec.FindChar(':');
NS_ASSERTION(dividerPosition != -1, "Malformed URI!");
int32_t n = aSpec.Left(mScheme, dividerPosition);
NS_ASSERTION(n == dividerPosition, "Storing the scheme failed!");
int32_t count = aSpec.Length() - dividerPosition - 1;
n = aSpec.Mid(mPath, dividerPosition + 1, count);
NS_ASSERTION(n == count, "Storing the path failed!");
ToLowerCase(mScheme);
}