• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ IsWhiteSpace函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中IsWhiteSpace函数的典型用法代码示例。如果您正苦于以下问题:C++ IsWhiteSpace函数的具体用法?C++ IsWhiteSpace怎么用?C++ IsWhiteSpace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了IsWhiteSpace函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: VOX_ReadSentenceFile

// Load sentence file into memory, insert null terminators to
// delimit sentence name/sentence pairs.  Keep pointer to each
// sentence name so we can search later.
void VOX_ReadSentenceFile( const char *psentenceFileName )
{
    char	c, *pch, *pFileData;
    char	*pchlast, *pSentenceData;
    int	fileSize;

    // load file
    pFileData = (char *)FS_LoadFile( psentenceFileName, &fileSize, false );

    if( !pFileData )
    {
        MsgDev( D_WARN, "couldn't load %s\n", psentenceFileName );
        return;
    }

    pch = pFileData;
    pchlast = pch + fileSize;

    while( pch < pchlast )
    {
        // only process this pass on sentences
        pSentenceData = NULL;

        // skip newline, cr, tab, space

        c = *pch;
        while( pch < pchlast && IsWhiteSpace( c ))
            c = *(++pch);

        // skip entire line if first char is /
        if( *pch != '/' )
        {
            sentence_t *pSentence = &g_Sentences[g_numSentences++];

            pSentence->pName = pch;
            pSentence->length = 0;

            // scan forward to first space, insert null terminator
            // after sentence name

            c = *pch;
            while( pch < pchlast && c != ' ' )
                c = *(++pch);

            if( pch < pchlast )
                *pch++ = 0;

            // a sentence may have some line commands, make an extra pass
            pSentenceData = pch;
        }

        // scan forward to end of sentence or eof
        while( pch < pchlast && pch[0] != '\n' && pch[0] != '\r' )
            pch++;

        // insert null terminator
        if( pch < pchlast ) *pch++ = 0;

        // If we have some sentence data, parse out any line commands
        if( pSentenceData && pSentenceData < pchlast )
        {
            int	index = g_numSentences - 1;

            // the current sentence has an index of count-1
            VOX_ParseLineCommands( pSentenceData, index );
        }
    }
}
开发者ID:n00ner,项目名称:xash3d,代码行数:71,代码来源:s_vox.c


示例2: switch

BOOL CSZCommandLine::Analyze(LPCTSTR lpszCmdLine)
{
    BOOL    bResult = FALSE;
    int     nParamNamePos  = 0;
    int     nParamValuePos = 0;
    int     nSubCommandPos = 0;
    CString strParamName;
    CString strSubCommand;

    BOOL    bInQuotation   = FALSE;

    EM_CMDLINE_STATUS nStatus = em_Cmd_New_Arg;

    m_mapParams.RemoveAll();

    if (!lpszCmdLine)
        goto Exit0;

    for (int nPos = 0; 0 == nPos || lpszCmdLine[nPos - 1]; ++nPos)
    {
        TCHAR ch = lpszCmdLine[nPos];
        switch (nStatus)
        {
        case em_Cmd_New_Arg:
            bInQuotation = FALSE;
            // no break;

        case em_Cmd_White_Space:

            if (IsWhiteSpace(ch))
            {
                nStatus = em_Cmd_White_Space;
            }
            else if (IsArgNamePrefix(ch))
            {
                nStatus = em_Cmd_Arg_Name_Prefix;
            }
            else if (IsAlpha(ch))
            {   // skip sub command
                nSubCommandPos  = nPos;
                nStatus         = em_Cmd_Sub_Command;
            }
            else if (IsQuotation(ch))
            {
                bInQuotation = TRUE;
                nStatus = em_Cmd_White_Space;
            }
            else
            {
                goto Exit0;
            }

            break;

        case em_Cmd_Sub_Command:

            if (IsWhiteSpace(ch))
            {
                strSubCommand.SetString(lpszCmdLine + nSubCommandPos, nPos - nSubCommandPos);
                AppendSubCommand(strSubCommand);
                nStatus = em_Cmd_New_Arg;
            }
            else if (IsAlpha(ch))
            {   // skip sub command
                nStatus = em_Cmd_Sub_Command;
            }
            else if (IsQuotation(ch))
            {
                strSubCommand.SetString(lpszCmdLine + nSubCommandPos, nPos - nSubCommandPos);
                AppendSubCommand(strSubCommand);
                nStatus = em_Cmd_New_Arg;
            }
            else
            {
                goto Exit0;
            }

            break;

        case em_Cmd_Arg_Name_Prefix:

            if (IsWhiteSpace(ch))
            {
                goto Exit0;
            }
            else if (IsArgNamePrefix(ch))
            {   // Á¬ÐøµÄǰ׺
                nStatus = em_Cmd_Arg_Name_Prefix;
            }
            else
            {
                nParamNamePos = nPos;
                nStatus = em_Cmd_Arg_Name;
            }

            break;

        case em_Cmd_Arg_Name:

            if (IsWhiteSpace(ch))
//.........这里部分代码省略.........
开发者ID:6520874,项目名称:pcmanager,代码行数:101,代码来源:szcmdline.cpp


示例3: while

void TiXmlElement::StreamIn (std::istream * in, TIXML_STRING * tag)
{
    // We're called with some amount of pre-parsing. That is, some of "this"
    // element is in "tag". Go ahead and stream to the closing ">"
    while( in->good() )
    {
        int c = in->get();
        if ( c <= 0 )
        {
            TiXmlDocument* document = GetDocument();
            if ( document )
                document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
            return;
        }
        (*tag) += (char) c ;

        if ( c == '>' )
            break;
    }

    if ( tag->length() < 3 ) return;

    // Okay...if we are a "/>" tag, then we're done. We've read a complete tag.
    // If not, identify and stream.

    if (    tag->at( tag->length() - 1 ) == '>'
            && tag->at( tag->length() - 2 ) == '/' )
    {
        // All good!
        return;
    }
    else if ( tag->at( tag->length() - 1 ) == '>' )
    {
        // There is more. Could be:
        //		text
        //		cdata text (which looks like another node)
        //		closing tag
        //		another node.
        for ( ;; )
        {
            StreamWhiteSpace( in, tag );

            // Do we have text?
            if ( in->good() && in->peek() != '<' )
            {
                // Yep, text.
                TiXmlText text( "" );
                text.StreamIn( in, tag );

                // What follows text is a closing tag or another node.
                // Go around again and figure it out.
                continue;
            }

            // We now have either a closing tag...or another node.
            // We should be at a "<", regardless.
            if ( !in->good() ) return;
            assert( in->peek() == '<' );
            int tagIndex = (int) tag->length();

            bool closingTag = false;
            bool firstCharFound = false;

            for( ;; )
            {
                if ( !in->good() )
                    return;

                int c = in->peek();
                if ( c <= 0 )
                {
                    TiXmlDocument* document = GetDocument();
                    if ( document )
                        document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
                    return;
                }

                if ( c == '>' )
                    break;

                *tag += (char) c;
                in->get();

                // Early out if we find the CDATA id.
                if ( c == '[' && tag->size() >= 9 )
                {
                    size_t len = tag->size();
                    const char* start = tag->c_str() + len - 9;
                    if ( strcmp( start, "<![CDATA[" ) == 0 ) {
                        assert( !closingTag );
                        break;
                    }
                }

                if ( !firstCharFound && c != '<' && !IsWhiteSpace( c ) )
                {
                    firstCharFound = true;
                    if ( c == '/' )
                        closingTag = true;
                }
//.........这里部分代码省略.........
开发者ID:nagyist,项目名称:Figbug-imguru-cmdlineMac,代码行数:101,代码来源:tinyxmlparser.cpp


示例4: while

//------------------------------------------------------------------------------
Tokeniser::tokentype Tokeniser::GetNextToken ()
{
	tokentype TokenType = EMPTY;
	
	while ((TokenType == EMPTY) 
		&& !in.bad() 
		&& !atEOF)
	{
		curChar = GetNextChar ();
		
		//std::cout << curChar << " GetNextChar" << std::endl;

		if (IsWhiteSpace (curChar))
		{
			// skip white space
		}
		else
		{
			if (IsPunctuation (curChar))
			{
				//	std::cout << curChar << " IsPunctuation" << std::endl;
			
 				// classify punctuation token
				switch (curChar)
				{
					case '[': ParseComment (); break;
					case '\'':
						if (ParseString ())
							TokenType = STRING;
						else TokenType = BAD;
						break;
					case '(':
						TokenType = LPAR;
						break;
					case ')':
						TokenType = RPAR;
						break;
					case '{':
						TokenType = LPAR;
						break;
					case '}':
						TokenType = RPAR;
						break;
					case '!':
						TokenType = BANG;
						break;
					case '#':
						TokenType = HASH;
						break;
					case '=':
						TokenType = EQUALS;
						break;
					case ';':
						TokenType = SEMICOLON;
						break;
					case ',':
						TokenType = COMMA;
						break;
					case '*':
						TokenType = ASTERIX;
						break;
					case ':':
						TokenType = COLON;
						break;
					case '-':
						TokenType = MINUS;
						break;
					case '"':
						TokenType = DOUBLEQUOTE;
						break;
					case '/':
						TokenType = BACKSLASH;
						break;
					default:
						TokenType = OTHER;
						break;
				}
			}
			else
			{
            	// It's either a number, or a string
				if (isdigit (curChar))
				{
					TokenType = ParseNumber();
/*					if (ParseNumber ())
                    				TokenType = NUMBER;
                   			else
                    				TokenType = BAD;
*/
				}
				else
                			{
					if (ParseToken ())
						TokenType = STRING;
					else TokenType = BAD;
				}
			}
		}
	}
//.........这里部分代码省略.........
开发者ID:rdmpage,项目名称:mincut-supertree,代码行数:101,代码来源:tokeniser.cpp


示例5: while

void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag)
{
	// We're called with some amount of pre-parsing. That is, some of "this"
	// element is in "tag". Go ahead and stream to the closing ">"
	while( in->good() )
	{
		int c = in->get();
		(*tag) += (TCHAR) c ;
		
		if ( c == '>' )
			break;
	}

	if ( tag->length() < 3 ) return;

	// Okay...if we are a "/>" tag, then we're done. We've read a complete tag.
	// If not, identify and stream.

	if (    tag->at( tag->length() - 1 ) == '>' 
		 && tag->at( tag->length() - 2 ) == '/' )
	{
		// All good!
		return;
	}
	else if ( tag->at( tag->length() - 1 ) == '>' )
	{
		// There is more. Could be:
		//		text
		//		closing tag
		//		another node.
		for ( ;; )
		{
			StreamWhiteSpace( in, tag );

			// Do we have text?
			if ( in->good() && in->peek() != '<' ) 
			{
				// Yep, text.
				TiXmlText text( TEXT("") );
				text.StreamIn( in, tag );

				// What follows text is a closing tag or another node.
				// Go around again and figure it out.
				continue;
			}

			// We now have either a closing tag...or another node.
			// We should be at a "<", regardless.
			if ( !in->good() ) return;
			assert( in->peek() == '<' );
			size_t tagIndex = tag->length();

			bool closingTag = false;
			bool firstCharFound = false;

			for( ;; )
			{
				if ( !in->good() )
					return;

				int c = in->peek();
				
				if ( c == '>' )
					break;

				*tag += (TCHAR)c;
				in->get();

				if ( !firstCharFound && c != '<' && !IsWhiteSpace( c ) )
				{
					firstCharFound = true;
					if ( c == '/' )
						closingTag = true;
				}
			}
			// If it was a closing tag, then read in the closing '>' to clean up the input stream.
			// If it was not, the streaming will be done by the tag.
			if ( closingTag )
			{
				int c = in->get();
				assert( c == '>' );
				*tag += (TCHAR)c;

				// We are done, once we've found our closing tag.
				return;
			}
			else
			{
				// If not a closing tag, id it, and stream.
				const TCHAR* tagloc = tag->c_str() + tagIndex;
				TiXmlNode* node = Identify( tagloc );
				if ( !node )
					return;
				node->StreamIn( in, tag );
				delete node;
				node = 0;

				// No return: go around from the beginning: text, closing tag, or node.
			}
		}
//.........这里部分代码省略.........
开发者ID:AdemMYilmaz,项目名称:notepad-plus-plus,代码行数:101,代码来源:tinyxmlparser.cpp


示例6: PreProcessInput

void FXmlFile::PreProcessInput(TArray<FString>& Input)
{
	// Note: This implementation is written simply and will not handle all cases.  It
	//       is made for the simple cases where FXmlFile is to be used.
	// Assumptions/Misc:
	//       - Well-formatted file with 1 entry per line
	//       - Ignoring versions, encodings, and doctypes

	// Remove white space at the beginning of lines
	for(int32 i = 0; i < Input.Num(); ++i)
	{
		int32 NumWhiteSpace = 0;
		for(int32 j = 0; j < Input[i].Len(); ++j)
		{
			if(!IsWhiteSpace(Input[i][j]))
			{
				break;
			}
			
			++NumWhiteSpace;
		}

		if(NumWhiteSpace > 0)
		{
			Input[i] = Input[i].Mid(NumWhiteSpace);
		}
	}

	// Cull any text that can be removed on a line-based parse
	for(int32 i = 0; i < Input.Num(); ++i)
	{
		// Find <!DOCTYPE or <?xml and remove those lines
		if(Input[i].StartsWith(TEXT("<!DOCTYPE")) || Input[i].StartsWith(TEXT("<?xml")))
		{
			Input[i] = TEXT("");
		}
	}

	// Cull any text inside of comments
	bool bInComment = false;
	int32 CommentLineStart = -1;
	int32 CommentIndexStart = -1;
	for(int32 i = 0; i < Input.Num(); ++i)
	{
		if(Input[i].Len() == 3)
		{
			if(bInComment)
			{
				if(Input[i][0] == TCHAR('-') && Input[i][1] == TCHAR('-') && Input[i][2] == TCHAR('>'))
				{
					// Found comment end, perform removal (simply replace all text with whitespace to be ignored by tokenizer)
					bInComment = false;
					int32 CommentLineEnd = i;
					int32 CommentIndexEnd = 2;
					WhiteOut(Input, CommentLineStart, CommentLineEnd, CommentIndexStart, CommentIndexEnd);
				}
			}
		}

		if(Input[i].Len() < 3)
		{
			continue;
		}

		int32 Indx1 = 0, Indx2 = 1, Indx3 = 2, Indx4 = 3;
		for(; Indx4 < Input[i].Len(); ++Indx1, ++Indx2, ++Indx3, ++Indx4)
		{
			// Looking for the start of a comment
			if(!bInComment)
			{
				if(Input[i][Indx1] == TCHAR('<') && Input[i][Indx2] == TCHAR('!') && Input[i][Indx3] == TCHAR('-') && Input[i][Indx4] == TCHAR('-'))
				{
					// Found comment start, mark it
					bInComment = true;
					CommentLineStart = i;
					CommentIndexStart = Indx1;
				}
			}

			// Looking for the end of a comment
			else
			{
				if( (Input[i][Indx2] == TCHAR('-') && Input[i][Indx3] == TCHAR('-') && Input[i][Indx4] == TCHAR('>')) ||
					(Input[i][Indx1] == TCHAR('-') && Input[i][Indx2] == TCHAR('-') && Input[i][Indx3] == TCHAR('>')) )
				{
					// Found comment end, perform removal (simply replace all text with whitespace to be ignored by tokenizer)
					bInComment = false;
					int32 CommentLineEnd = i;
					int32 CommentIndexEnd = Indx4;
					WhiteOut(Input, CommentLineStart, CommentLineEnd, CommentIndexStart, CommentIndexEnd);
				}
			}
		}
	}
}
开发者ID:SRombauts,项目名称:UE4PlasticPlugin,代码行数:95,代码来源:XmlFile.cpp


示例7: while

	int InPlaceParser::ProcessLine(int lineno,char *line,InPlaceParserInterface *callback)
	{
		int ret = 0;

		const char *argv[MAXARGS];
		int argc = 0;

		char *foo = line;

		while ( !EOS(*foo) && argc < MAXARGS )
		{

			foo = SkipSpaces(foo); // skip any leading spaces

			if ( EOS(*foo) ) break;

			if ( *foo == mQuoteChar ) // if it is an open quote
			{
				foo++;
				if ( argc < MAXARGS )
				{
					argv[argc++] = foo;
				}
				while ( !EOS(*foo) && *foo != mQuoteChar ) foo++;
				if ( !EOS(*foo) )
				{
					*foo = 0; // replace close quote with zero byte EOS
					foo++;
				}
			}
			else
			{

				foo = AddHard(argc,argv,foo); // add any hard separators, skip any spaces

				if ( IsNonSeparator(*foo) )  // add non-hard argument.
				{
					bool quote  = false;
					if ( *foo == mQuoteChar )
					{
						foo++;
						quote = true;
					}

					if ( argc < MAXARGS )
					{
						argv[argc++] = foo;
					}

					if ( quote )
					{
						while (*foo && *foo != mQuoteChar ) foo++;
						if ( *foo ) *foo = 32;
					}

					// continue..until we hit an eos ..
					while ( !EOS(*foo) ) // until we hit EOS
					{
						if ( IsWhiteSpace(*foo) ) // if we hit a space, stomp a zero byte, and exit
						{
							*foo = 0;
							foo++;
							break;
						}
						else if ( IsHard(*foo) ) // if we hit a hard separator, stomp a zero byte and store the hard separator argument
						{
							const char *hard = &mHardString[*foo*2];
							*foo = 0;
							if ( argc < MAXARGS )
							{
								argv[argc++] = hard;
							}
							foo++;
							break;
						}
						foo++;
					} // end of while loop...
				}
			}
		}

		if ( argc )
		{
			ret = callback->ParseLine(lineno, argc, argv );
		}

		return ret;
	}
开发者ID:flair2005,项目名称:PhysXPractice,代码行数:88,代码来源:wavefront.cpp


示例8: Blank

bool TiXmlText::Blank() const {
  for (auto & elem : value)
    if (!IsWhiteSpace(elem)) return false;
  return true;
}
开发者ID:ptitSeb,项目名称:Eldritch,代码行数:5,代码来源:tinyxmlparser.cpp


示例9: while

nsresult nsPropertiesParser::ParseBuffer(const PRUnichar* aBuffer,
                                         PRUint32 aBufferLength)
{
  const PRUnichar* cur = aBuffer;
  const PRUnichar* end = aBuffer + aBufferLength;

  // points to the start/end of the current key or value
  const PRUnichar* tokenStart = nsnull;

  // if we're in the middle of parsing a key or value, make sure
  // the current token points to the beginning of the current buffer
  if (mState == eParserState_Key ||
      mState == eParserState_Value) {
    tokenStart = aBuffer;
  }

  nsAutoString oldValue;

  while (cur != end) {

    PRUnichar c = *cur;

    switch (mState) {
    case eParserState_AwaitingKey:
      if (c == '#' || c == '!')
        EnterCommentState();

      else if (!IsWhiteSpace(c)) {
        // not a comment, not whitespace, we must have found a key!
        EnterKeyState();
        tokenStart = cur;
      }
      break;

    case eParserState_Key:
      if (c == '=' || c == ':') {
        mKey += Substring(tokenStart, cur);
        WaitForValue();
      }
      break;

    case eParserState_AwaitingValue:
      if (IsEOL(c)) {
        // no value at all! mimic the normal value-ending
        EnterValueState();
        FinishValueState(oldValue);
      }

      // ignore white space leading up to the value
      else if (!IsWhiteSpace(c)) {
        tokenStart = cur;
        EnterValueState();

        // make sure to handle this first character
        if (ParseValueCharacter(c, cur, tokenStart, oldValue))
          cur++;
        // If the character isn't consumed, don't do cur++ and parse
        // the character again. This can happen f.e. for char 'X' in sequence
        // "\u00X". This character can be control character and must be
        // processed again.
        continue;
      }
      break;

    case eParserState_Value:
      if (ParseValueCharacter(c, cur, tokenStart, oldValue))
        cur++;
      // See few lines above for reason of doing this
      continue;

    case eParserState_Comment:
      // stay in this state till we hit EOL
      if (c == '\r' || c== '\n')
        WaitForKey();
      break;
    }

    // finally, advance to the next character
    cur++;
  }

  // if we're still parsing the value and are in eParserSpecial_None, then
  // append whatever we have..
  if (mState == eParserState_Value && tokenStart &&
      mSpecialState == eParserSpecial_None) {
    mValue += Substring(tokenStart, cur);
  }
  // if we're still parsing the key, then append whatever we have..
  else if (mState == eParserState_Key && tokenStart) {
    mKey += Substring(tokenStart, cur);
  }

  return NS_OK;
}
开发者ID:Anachid,项目名称:mozilla-central,代码行数:94,代码来源:nsPersistentProperties.cpp


示例10: GetText

void VTextState::Paint(VGraphicsInfo *pGraphics, VWindowBase *pParentWnd, VColorRef iColor)
{
  const char *szText = GetText();
  if (!m_spFont || !szText || !szText[0])
    return;

  VRectanglef vParentRect = pParentWnd->GetClientRect(); // clipping box of parent control

  if(!m_bCachedLinesValid)
  {
    m_lines.Reset();
    m_lineOffsets.Reset();

    float fLineHeight = m_spFont->GetFontHeight() * m_fRelativeFontHeight * m_fFontScaling;

    if(!m_bTextWrap)
    {
      const char* szCurrentLine = szText;
      for (const char* szPtr = szCurrentLine; *szPtr != '\0'; ++szPtr)
      {
        if (*szPtr == '\n')
        {
          VStaticString<512> line;
          line.Set(szCurrentLine, szPtr - szCurrentLine);

          m_lines.Add(line.AsChar());
          szCurrentLine = szPtr + 1;
        }
      }

      // Add the last line
      if(*szCurrentLine)
      {
        m_lines.Add(szCurrentLine);
      }
    }
    else
    {
      float fMaxLineWidth = vParentRect.GetSizeX() / m_fFontScaling;

      // Wrap text into individual lines
      {
        const char *szCurrentLine = szText;
        while (*szCurrentLine)
        {
          // byte offsets
          int iByteOffsetAtWrapPosition;
          int iByteOffsetAfterWrapPosition;

          // search for next newline
          const char *pNextNewLine = strchr(szCurrentLine, '\n');

          // compute automatic wrap character index
          int iCharCount = m_spFont->GetCharacterIndexAtPos(szCurrentLine, fMaxLineWidth, -1, false);
          int iWrapOffset = VString::GetUTF8CharacterOffset(szCurrentLine, iCharCount);

          if (pNextNewLine != NULL && (pNextNewLine - szCurrentLine) <= iWrapOffset)
          {
            // newline occurs before automatic text wrap
            iByteOffsetAtWrapPosition = static_cast<int>(pNextNewLine - szCurrentLine);
            iByteOffsetAfterWrapPosition = iByteOffsetAtWrapPosition + 1;
          }
          else if(strlen(szCurrentLine) <= iWrapOffset)
          {
            // End of text occurs before automatic text wrap
            iByteOffsetAtWrapPosition = strlen(szCurrentLine);
            iByteOffsetAfterWrapPosition = iByteOffsetAtWrapPosition;
          }
          else
          {
            // automatic text wrap
            iByteOffsetAtWrapPosition = iWrapOffset;
            if (iByteOffsetAtWrapPosition > 0)
            {
              // Go backwards and try to find white space
              while (iByteOffsetAtWrapPosition > 0 && !IsWhiteSpace(szCurrentLine[iByteOffsetAtWrapPosition]))
              {
                iByteOffsetAtWrapPosition--;
              }

              // no whitespace found? then wrap inside word
              if (iByteOffsetAtWrapPosition == 0)
              {
                iByteOffsetAtWrapPosition = iWrapOffset;
              }
              else
              {
                // Find end of next word
                int iEndOfWord = iByteOffsetAtWrapPosition + 1;
                while(szCurrentLine[iEndOfWord] && !IsWhiteSpace(szCurrentLine[iEndOfWord]))
                {
                  iEndOfWord++;
                }

                // If the word does not fit into a line by itself, it will be wrapped anyway, so wrap it early to avoid ragged looking line endings
                VRectanglef nextWordSize;
                m_spFont->GetTextDimension(szCurrentLine + iByteOffsetAtWrapPosition, nextWordSize, iEndOfWord - iByteOffsetAtWrapPosition);
                if(nextWordSize.GetSizeX() > fMaxLineWidth)
                {
                  iByteOffsetAtWrapPosition = iWrapOffset;
//.........这里部分代码省略.........
开发者ID:RexBaribal,项目名称:projectanarchy,代码行数:101,代码来源:VControlHelperObjects.cpp


示例11: while

//------------------------------------------------------------------------------
// Parse a number (integer or real).
tokentype Parser::ParseNumber ()
{
	enum {
		start		= 0x0001, // 0
		sign		= 0x0002, // 1
        digit		= 0x0004, // 2
		fraction	= 0x0008, // 3
		expsymbol	= 0x0010, // 4
		expsign		= 0x0020, // 5
        exponent 	= 0x0040, // 6
        bad			= 0x0080,
        done		= 0x0100
    } state;

    tokentype result = BAD;

	token = "";
    state = start;

    char curChar = text[pos]; 

    while (!IsWhiteSpace (curChar)
    	&& !(IsPunctuation (curChar) && (curChar != '-'))
        && (state != bad)
        && (state != done))
    {
    	if (isdigit (curChar))
        {
        	switch (state)
            {
            	case start:
                case sign:
                	state = digit;
                    break;
                case expsymbol:
                case expsign:
                	state = exponent;
                    break;
                default:
                	break;
            }
        }
        else if ((curChar == '-') || (curChar == '+'))
        {
        	switch (state)
            {
            	case start:
                	state = sign;		// sign of number
                    break;
                case digit:
                	state = done;		// minus sign is punctuation, such as 6-10
                	break;
                case expsymbol:
                	state = expsign;	// sign of exponent
                    break;
                default:
                	state = bad;		// syntax error
                    break;
            }
        }
        else if ((curChar == '.') && (state == digit))
        	state = fraction;
        else if (((curChar == 'E') || (curChar == 'e')) && (state & (digit | fraction)))
        	state = expsymbol;
        else
        	state = bad;

        if ((state != bad) && (state != done))
        {
        	token += curChar;
            curChar = GetNextChar ();
        }
    }

    int isNumber =  state & (digit | fraction | exponent | done);
    if (isNumber)
    {
    	// We have a number
		result = NUMBER;

		if (IsPunctuation (curChar))
        {
//        	PutBack (curChar);
//            if (!atEOL)
//            	filecol--;
        }
	}        

	else
    {
		// Not a number, but a string that starts with numbers, such as "00BW0762.1"
//        cout << "Do something!" << endl;
			do {
				if (curChar == '_')
					token += ' ';
				else
					token += curChar;
            	curChar = GetNextChar ();
//.........这里部分代码省略.........
开发者ID:bomeara,项目名称:omearatenure,代码行数:101,代码来源:Parse.cpp


示例12: if

bool TextAreaTextRange::CheckEndPointIsUnitEndpoint(_In_ EndPoint check, _In_ TextUnit unit, _In_ TEXTATTRIBUTEID specificAttribute)
{
    if (unit == TextUnit_Character)
    {
        return true;
    }

    EndPoint next;
    EndPoint prev;
    if (!_control->StepCharacter(check, true, &next) ||
        !_control->StepCharacter(check, false, &prev))
    {
        // If we're at the beginning or end, we're at an endpoint
        return true;
    }

    else if (unit == TextUnit_Word)
    {
        if (IsWhiteSpace(prev) && !IsWhiteSpace(check))
        {
            return true;
        }
        return false;
    }

    else if (unit == TextUnit_Line || unit == TextUnit_Paragraph)
    {
        return check.line != next.line;
    }

    // TextUnit_Page and TextUnit_Document are covered by the initial beginning/end check
    else if (unit == TextUnit_Page || unit == TextUnit_Document)
    {
        return false;
    }

    else if (unit == TextUnit_Format)
    {
        bool matching = true;
        bool checkedLineBoundary = false;
        
        // There are limited attributes that vary in this control
        // If its not one of those attributes, then it is not an Endpoint
        // unless it's the document start or end, which is checked above
        for (int i = 0; i < ARRAYSIZE(lineVariableAttributes); i++)
        {
            if (specificAttribute == 0 || specificAttribute == lineVariableAttributes[i])
            {
                if (!checkedLineBoundary)
                {
                    if (!CheckEndPointIsUnitEndpoint(check, TextUnit_Paragraph, 0))
                    {
                        break;
                    }
                    checkedLineBoundary = true;
                }

                VARIANT varC = _control->GetAttributeAtPoint(check, lineVariableAttributes[i]);
                VARIANT varN = _control->GetAttributeAtPoint(next, lineVariableAttributes[i]);
                HRESULT hr = VarCmp(&varC, &varN, LOCALE_NEUTRAL);
                VariantClear(&varC);
                VariantClear(&varN);
                if (hr != VARCMP_EQ)
                {
                    matching = false;
                    break;
                }
            }
        }

        for (int i = 0; i < ARRAYSIZE(charVariableAttributes); i++)
        {
            if (specificAttribute == 0 || specificAttribute == charVariableAttributes[i])
            {
                int *annotationIds;
                int annotationCount;
                if (GetAnnotationsAtPoint(check, &annotationIds, &annotationCount))
                {
                    int *prevAnnotationIds;
                    int prevAnnotationCount;
                    if (GetAnnotationsAtPoint(prev, &prevAnnotationIds, &prevAnnotationCount))
                    {
                        if (annotationCount != prevAnnotationCount)
                        {
                            matching = false;
                        }
                        // Since all our annotations are the same type, if the number matches,
                        // then the UIA_AnnotationTypesAttributeId all match
                        else if (charVariableAttributes[i] == UIA_AnnotationObjectsAttributeId)
                        {
                            for (int j = 0; j < annotationCount; j++)
                            {
                                if (annotationIds[j] != prevAnnotationIds[j])
                                {
                                    matching = false;
                                }
                            }
                        }
                        delete [] prevAnnotationIds;
                    }
//.........这里部分代码省略.........
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:101,代码来源:TextAreaProvider.cpp


示例13: IsNonSeparator

	bool InPlaceParser::IsNonSeparator(char c)
	{
		if ( !IsHard(c) && !IsWhiteSpace(c) && c != 0 ) return true;
		return false;
	}
开发者ID:flair2005,项目名称:PhysXPractice,代码行数:5,代码来源:wavefront.cpp


示例14: while

bool DTextParser::SearchWordInBlock( lpctstr t_pWord, DTextBlock& Block )
{
	if( !m_pBuffer || t_pWord==NULL || t_pWord[0]==0 ) return false;
	//if( bFromStart )
	{
		m_lBufPosition = Block.Start();
	}

	SString strTemp = t_pWord;
	int iSrcPos=0;
	int iSrcSize = strTemp.Len();

	int iReadWordMode = 0;

	long BufEnd = Block.End();

	while( m_lBufPosition <= BufEnd )
	{
		// 한줄주석처리 ';'가 나오면 리턴문자가 올 때까지 모든 문자를Skip한다.
		if( m_pBuffer[m_lBufPosition]==';' )
		{
			// reset state
			//iReadWordMode = 0;
			//iSrcPos = 0;
			// go to the end of line
			m_lBufPosition++;
			while( m_lBufPosition < BufEnd && m_pBuffer[m_lBufPosition] != '\r' && m_pBuffer[m_lBufPosition] != '\n' )
					m_lBufPosition++;
		}

		if( iReadWordMode==0 )
		{// Word에 진입하지 않은 상태
			//소스 첫글자와 대상현재위치의 단어가 같다면 WordMode=1
			if( t_pWord[0]==m_pBuffer[m_lBufPosition] )
			{
				iSrcPos = 1;
				iReadWordMode = 1;
			}
			++m_lBufPosition;
		}
		else if( iReadWordMode==1 )
		{// Word에 진입하여 검사중인 상태
			// WhiteSpace가 나오거나, 틀리면 Mode=0, 그 외에는 SrcPos를 증가
			if( t_pWord[iSrcPos]==m_pBuffer[m_lBufPosition] )
			{
				++iSrcPos;
			}
			else if( IsWhiteSpace(m_pBuffer[m_lBufPosition]) )
			{// 단어검사중에 단어의 끝을 만났다면 현재까지 검사된 단어의 길이를 보고
				//맞는 단어를 찾았는지 검사한다.
				if( iSrcPos>=iSrcSize ) return true;//found!
			}
			else
			{// 그저 틀린 문자를 발견했다면, Mode=0
				iReadWordMode = 0;
				iSrcPos = 0;
			}
			++m_lBufPosition;
		}
	}

	return false;
}
开发者ID:RaoMiao,项目名称:freestyle,代码行数:63,代码来源:DTextParser.cpp


示例15: SkipWhiteSpace

const char* TiXmlAttribute::Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding)
{
	p = SkipWhiteSpace(p, encoding);
	if (!p || !*p) return 0;

	int tabsize = 4;
	if (document)
		tabsize = document->TabSize();

	if (data)
	{
		data->Stamp(p, encoding);
		location = data->Cursor();
	}
	// Read the name, the '=' and the value.
	const char* pErr = p;
	p = ReadName(p, &name, encoding);
	if (!p || !*p)
	{
		if (document) document->SetError(TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding);
		return 0;
	}
	p = SkipWhiteSpace(p, encoding);
	if (!p || !*p || *p != '=')
	{
		if (document) document->SetError(TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding);
		return 0;
	}

	++p;	// skip '='
	p = SkipWhiteSpace(p, encoding);
	if (!p || !*p)
	{
		if (document) document->SetError(TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding);
		return 0;
	}
	
	const char* end;

	if (*p == '\'')
	{
		++p;
		end = "\'";
		p = ReadText(p, &value, false, end, false, encoding);
	}
	else if (*p == '"')
	{
		++p;
		end = "\"";
		p = ReadText(p, &value, false, end, false, encoding);
	}
	else
	{
		// All attribute values should be in single or double quotes.
		// But this is such a common error that the parser will try
		// its best, even without them.
		value = "";
		while (   p && *p										// existence
				&& !IsWhiteSpace(*p) && *p != '\n' && *p != '\r'	// whitespace
				&& *p != '/' && *p != '>')						// tag end
		{
			value += *p;
			++p;
		}
	}
	return p;
}
开发者ID:sub77,项目名称:hobbycode,代码行数:67,代码来源:tinyxmlparser.cpp


示例16: Blank

bool TiXmlText::Blank() const {
    for ( unsigned i=0; i<value.length(); i++ )
        if ( !IsWhiteSpace( value[i] ) )
            return false;
    return true;
}
开发者ID:Codiscope-Research,项目名称:ykt4sungard,代码行数:6,代码来源:tinyxmlparser.cpp


示例17: conv

void conv(RR& x, const char *s)
{
   long c;
   long cval;
   long sign;
   ZZ a, b;
   long i = 0;

   if (!s) Error("bad RR input");


   c = s[i];
   while (IsWhiteSpace(c)) {
      i++;
      c = s[i];
   }

   if (c == '-') {
      sign = -1;
      i++;
      c = s[i];
   }
   else
      sign = 1;

   long got1 = 0;
   long got_dot = 0;
   long got2 = 0;

   a = 0;
   b = 1;

   cval = CharToIntVal(c);

   if (cval >= 0 && cval <= 9) {
      got1 = 1;

      while (cval >= 0 && cval <= 9) {
         mul(a, a, 10);
         add(a, a, cval);
         i++;
         c = s[i];
         cval = CharToIntVal(c);
      }
   }

   if (c == '.') {
      got_dot = 1;

      i++;
      c = s[i];
      cval = CharToIntVal(c);

      if (cval >= 0 && cval <= 9) {
         got2 = 1;

         while (cval >= 0 && cval <= 9) {
            mul(a, a, 10);
            add(a, a, cval);
            mul(b, b, 10);
            i++;
            c = s[i];
            cval = CharToIntVal(c);
         }
      }
   }

   if (got_dot && !got1 && !got2)  Error("bad RR input");

   ZZ e;

   long got_e = 0;
   long e_sign;

   if (c == 'e' || c == 'E') {
      got_e = 1;

      i++;
      c = s[i];

      if (c == '-') {
         e_sign = -1;
         i++;
         c = s[i];
      }
      else if (c == '+') {
         e_sign = 1;
         i++;
         c = s[i];
      }
      else
         e_sign = 1;


      cval = CharToIntVal(c);

      if (cval < 0 || cval > 9) Error("bad RR input");

      e = 0;
      while (cval >= 0 && cval <= 9) {
//.........这里部分代码省略.........
开发者ID:Macaulay2,项目名称:Singular,代码行数:101,代码来源:RR.c


示例18: TRACEBEGIN

/*
 *	CRchTxtPtr::ChangeCase(cch, Type, publdr)
 *	
 *	@mfunc
 *		Change case of cch chars starting at this text ptr according to Type,
 *		which has the possible values:
 *
 *		tomSentenceCase	= 0: capitalize first letter of each sentence
 *		tomLowerCase	= 1: change all letters to lower case
 *		tomUpperCase	= 2: change all letters to upper case
 *		tomTitleCase	= 3: capitalize the first letter of each word
 *		tomToggleCase	= 4: toggle the case of each letter
 *	
 *	@rdesc
 *		TRUE iff a change occurred
 *
 *	@devnote
 *		Since this routine only changes the case of characters, it has no
 *		effect on rich-text formatting.  However it is part of the CRchTxtPtr
 *		class in order to notify the display of changes.  CTxtRanges are also
 *		notified just in case the text blocks are modified.
 */
BOOL CRchTxtPtr::ChangeCase (
	LONG		  cch,			//@parm # chars to change case for
	LONG		  Type,			//@parm Type of change case command
	IUndoBuilder *publdr)		//@parm UndoBuilder to receive anti-event
								//  	for any replacements
{
	TRACEBEGIN(TRCSUBSYSBACK, TRCSCOPEINTERN, "CRchTxtPtr::ChangeCase");
	_TEST_INVARIANT_

#define	BUFFERLEN	256

	LONG	cchChunk, cchFirst, cchGet, cchLast;
	BOOL	fAlpha, fToUpper, fUpper;			// Flags controling case change
	BOOL	fChange = FALSE;					// No change yet
	BOOL	fStart = TRUE;						// Start of Word/Sentence
	TCHAR *	pch;								// Ptr to walk rgCh with
	WORD *	pType;								// Ptr to walk rgType with
	TCHAR	rgCh[BUFFERLEN];					// Char buffer to work in
	WORD	rgType[BUFFERLEN];					// C1_TYPE array for rgCh

	if( GetCp() )
	{
		if( Type == tomSentenceCase )
		{
			fStart = _rpTX.IsAtBOSentence();
		}
		else if( Type == tomTitleCase )
		{
			// check to see if we are at the beginning of
			// a word.  This is the case if the character preceeding
			// our current position is white space.
			fStart = IsWhiteSpace(_rpTX.PrevChar());
			_rpTX.AdvanceCp(1);
		}
	}
	while(cch > 0)								// Do 'em all (or as many as
	{											//  in story)
		cchChunk = min(BUFFERLEN, cch);			// Get next bufferful
		cch -= cchChunk;						// Decrement the count
		cchGet = _rpTX.GetText(cchChunk, rgCh);	// Manipulate chars in buffer
		if(cchGet < cchChunk)					//  (for undo, need to use
		{										//  ReplaceRange())
			cch = 0;							// No more chars in story,
			if(!cchGet)							//  so we'll be done
				break;							// We're done already
			cchChunk = cchGet;					// Something in this chunk
		}

		GetStringTypeEx(0, CT_CTYPE1, rgCh,		// Find out whether chars are
						cchChunk, rgType);		//  UC, LC, or neither
		
		cchLast = 0;							// Default nothing to replace
		cchFirst = -1;
		for(pch = rgCh, pType = rgType;			// Process buffered chars
			cchChunk;
			cchChunk--, pch++, pType++)
		{
			fAlpha = *pType & (C1_UPPER | C1_LOWER); // Nonzero if UC or LC
			fUpper = (*pType & C1_UPPER) != 0;	// TRUE if UC
			fToUpper = fStart ? TRUE : fUpper;	// capitalize first letter of a
												// sentence
			switch(Type)
			{									// Decide whether to change
			case tomLowerCase:					//  case and determine start
				fToUpper = FALSE;				//  of word/sentence for title
				break;							//  and sentence cases

			case tomUpperCase:
				fToUpper = TRUE;
				break;

			case tomToggleCase:
				fToUpper = !fUpper;
				break;

			case tomSentenceCase:
				if(*pch == TEXT('.'))			// If sentence terminator,
					fStart = TRUE;				//  capitalize next alpha
//.........这里部分代码省略.........
开发者ID:achellies,项目名称:DUI_LIb,代码行数:101,代码来源:rtext.cpp


示例19: SkipWhiteSpace

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ IsWinNT函数代码示例发布时间:2022-05-30
下一篇:
C++ IsVisible函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap