当前位置: 首页>>代码示例>>C++>>正文


C++ IsWhiteSpace函数代码示例

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


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


注:本文中的IsWhiteSpace函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。