⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parser.cpp.tmp

📁 upnpsdk-1.0.4.tar.gz Intel UPnP SDK Source
💻 TMP
📖 第 1 页 / 共 3 页
字号:
    		bool bReadContent = true;    		while (bReadContent)    		{    			while (!char_match (*pEndContent, LESSTHAN) && *pEndContent)    				pEndContent++;    			if (!strncmp (pEndContent, BEGIN_COMMENT, strlen (BEGIN_COMMENT)))    				skipUntilString (&pEndContent, END_COMMENT);    			else    				bReadContent = false;    			if (!(*pEndContent))    				bReadContent = false;    		}    		TokenLength = pEndContent - CurrPtr;    	}	}	// Check for '>' token	else if (char_match (*CurrPtr, GREATERTHAN))	{		// Equals found, so return it as a token		TokenLength = strlen(GREATERTHAN);		SavePtr=CurrPtr; // Saving this ptr for not ignoring the leading and trailing spaces.		TagVal=true;	}	// Check for Content e.g.  <tag>content</tag>	else if (TagVal)	{		TagVal=false;		CurrPtr=SavePtr+1;//SavePtr whould not have have already moved.		char *pEndContent = CurrPtr;		// Read content until a < is found that is not a comment <!--		bool bReadContent = true;		while (bReadContent)		{			while (!char_match (*pEndContent, LESSTHAN) && *pEndContent)				pEndContent++;			if (!strncmp (pEndContent, BEGIN_COMMENT, strlen (BEGIN_COMMENT)))				skipUntilString (&pEndContent, END_COMMENT);			else				bReadContent = false;			if (!(*pEndContent))				bReadContent = false;		}		TokenLength = pEndContent - CurrPtr;	}    // Check for name tokens    else if (isnamech(toint(CurrPtr,&tlen),false)){        // Name found, so find out how long it is        int iIndex=tlen;        while (isnamech(toint(CurrPtr+iIndex,&tlen),true))            iIndex+=tlen;        TokenLength=iIndex;    };	// Copy the token to the return string    if (TokenLength > 0){		//if (!copy_token (TokenBuff, CurrPtr, TokenLength))        //if (!copy_token (CurrPtr, TokenLength))        //    return 1;        if (!copy_token (CurrPtr, TokenLength))	{		printf("=================== Check 999 - 5 \n");            return 1;	}    }    else if (*CurrPtr == '\0') {        TokenLength = 0;        clearTokBuf();        return 0;    }	else	{		// return the unrecognized token for error information		TokenLength = 1;        //copy_token (TokenBuff, CurrPtr, TokenLength);        appendTokBuf(*CurrPtr);	printf("=================== Check 999 - Last \n");        return 1;	}	CurrPtr = CurrPtr+TokenLength;	return 0;}//Will return a handle to the tree structure//The tree structure indicates to which parent the node belongs.int Parser::getNextNode(NODE_TYPE &NodeType, char **NodeName, char **NodeValue, bool &IsEnd,  bool IgnoreWhiteSpace){	while(*CurrPtr!='\0')	{		//printf("%c", *CurrPtr); 			printf("=================== getToBuf 888 ---> %s \n", getTokBuf());		if(IgnoreWhiteSpace)			IgnoreWhiteSpaces();		if(getNextToken()!=0)		{			*NodeValue=NULL;			*NodeName=NULL;			NodeType=INVALID_NODE;			IsEnd=false;			printf("=================== getToBuf 999 ---> %s \n", getTokBuf());			return 1;		}		//if(!strcmp(TokenBuff, LESSTHAN))        if(!strcmp(getTokBuf(), LESSTHAN))		{			if(IgnoreWhiteSpace)				IgnoreWhiteSpaces();			TagName=true;			if(getNextToken()!=0)			{				*NodeValue=NULL;				*NodeName=NULL;				NodeType=INVALID_NODE;				IsEnd=false;				return 1;			}			TagName=false;			//if(TokenBuff==NULL)			//	throw DOMException(DOMException::FATAL_ERROR_DURING_PARSING);			//if(*TokenBuff=='\0')			//	throw DOMException(DOMException::FATAL_ERROR_DURING_PARSING);            if (getTokBufLength() == 0)                throw DOMException(DOMException::FATAL_ERROR_DURING_PARSING);			//*NodeName=(char *)malloc(strlen(TokenBuff)+1);            *NodeName=(char *)malloc(getTokBufLength()+1);			//strcpy(*NodeName,TokenBuff);            strcpy(*NodeName,getTokBuf());			//strcpy(LastElement,TokenBuff);            setLastElem(getTokBuf());			*NodeValue=NULL;			NodeType=ELEMENT_NODE;			attrFound=true;			atLeastOneAttrFound=false;			IsEnd=false;		}		//else if(!strcmp(TokenBuff, GREATERTHAN))        else if(!strcmp(getTokBuf(), GREATERTHAN))		{			attrFound=false;			if(atLeastOneAttrFound)//forget the greater than			{				atLeastOneAttrFound=false;				continue;			}			else			{				printf("=================== getToBuf ---> %s \n", getTokBuf());				printf("=================== Check 1 \n");				return 0;			}		}		//else if(!strcmp(TokenBuff, ENDTAG))        else if(!strcmp(getTokBuf(), ENDTAG))		{			if(IgnoreWhiteSpace)				IgnoreWhiteSpaces();			if(getNextToken()!=0)			{				*NodeValue=NULL;				*NodeName=NULL;				NodeType=INVALID_NODE;				IsEnd=false;				return 1;			}			//if(TokenBuff==NULL)			//	throw DOMException(DOMException::FATAL_ERROR_DURING_PARSING);			//if(*TokenBuff=='\0')			//	throw DOMException(DOMException::FATAL_ERROR_DURING_PARSING);            if (getTokBufLength() == 0)                throw DOMException(DOMException::FATAL_ERROR_DURING_PARSING);			//*NodeName=(char *)malloc(strlen(TokenBuff)+1);            *NodeName=(char *)malloc(getTokBufLength()+1);			//strcpy(*NodeName,TokenBuff);            strcpy(*NodeName,getTokBuf());			*NodeValue=NULL;			NodeType=ELEMENT_NODE;			IsEnd=true;		}		//else if(!strcmp(TokenBuff, COMPLETETAG))        else if(!strcmp(getTokBuf(), COMPLETETAG))		{			if(NodeType==ELEMENT_NODE || (NodeType==ATTRIBUTE_NODE))			{				IsEnd=false;				//rewindCurrentPtr(strlen(TokenBuff));                rewindCurrentPtr(getTokBufLength());				printf("=================== Check 2 \n");				return 0;			}			//store the last element tag and return back as end element node			//*NodeName=(char *)malloc(strlen(LastElement)+1);            *NodeName=(char *)malloc(getLastElemLength()+1);			//strcpy(*NodeName,LastElement);            strcpy(*NodeName,getLastElem());			*NodeValue=NULL;			NodeType=ELEMENT_NODE;			attrFound=true;			atLeastOneAttrFound=false;			IsEnd=true;			printf("=================== Check 3 \n");				return 0;		}		//else if(TokenBuff[0] == '\0')        else if (getTokBufLength() == 0)		{			IsEnd=false;			continue;		}		else if(!attrFound)		{            //if (TokenBuff != NULL)			//{			//	if(*TokenBuff!='\0')			//	{			//		*NodeValue=(char *)malloc(strlen(TokenBuff)+1);			//		strcpy(*NodeValue,TokenBuff);			//	}    		//}            if (getTokBufLength() != 0){                *NodeValue=(char *)malloc(getTokBufLength()+1);                strcpy(*NodeValue,getTokBuf());				printf("=================== NodeValue ---> %s \n", *NodeValue);            }			*NodeName=(char *)malloc(strlen("#text")+1);			strcpy(*NodeName,"#text");			NodeType=TEXT_NODE;			IsEnd=false;			printf("=================== Check 4 \n");			return 0;		}		else		{			//if(TokenBuff==NULL)			//	throw DOMException(DOMException::FATAL_ERROR_DURING_PARSING);			//if(*TokenBuff=='\0')			//	throw DOMException(DOMException::FATAL_ERROR_DURING_PARSING);            if (getTokBufLength() == 0)                throw DOMException(DOMException::FATAL_ERROR_DURING_PARSING);			if(NodeType==ELEMENT_NODE)			{				//rewindCurrentPtr(strlen(TokenBuff)+1);                rewindCurrentPtr(getTokBufLength()+1);				printf("=================== Check 5 \n");				return 0;			}			//*NodeName=(char *)malloc(strlen(TokenBuff)+1);            *NodeName=(char *)malloc(getTokBufLength()+1);			//strcpy(*NodeName,TokenBuff);            strcpy(*NodeName,getTokBuf());			if(IgnoreWhiteSpace) 				IgnoreWhiteSpaces(); 			//gets rid of equals			if(getNextToken()!=0)			{				*NodeValue=NULL;				*NodeName=NULL;				NodeType=INVALID_NODE;				IsEnd=false;				return 1;			}			if(IgnoreWhiteSpace)				IgnoreWhiteSpaces(); 			if(getNextToken()!=0)			{				*NodeValue=NULL;				*NodeName=NULL;				NodeType=INVALID_NODE;				IsEnd=false;				return 1;			}			//gets rid of beginning quotes						inAttrib=true;			if(getNextToken()!=0)			{				*NodeValue=NULL;				*NodeName=NULL;				NodeType=INVALID_NODE;				IsEnd=false;				return 1;			}			inAttrib=false;			//if(TokenBuff==NULL)			//	throw DOMException(DOMException::FATAL_ERROR_DURING_PARSING);			//if(*TokenBuff=='\0')			//	throw DOMException(DOMException::FATAL_ERROR_DURING_PARSING);            if (getTokBufLength() == 0)                throw DOMException(DOMException::FATAL_ERROR_DURING_PARSING);			//*NodeValue=(char *)malloc(strlen(TokenBuff)+1);            *NodeValue=(char *)malloc(getTokBufLength()+1);			//strcpy(*NodeValue,TokenBuff);            strcpy(*NodeValue,getTokBuf());			// gets rid of ending quotes			if(getNextToken()!=0)			{				*NodeValue=NULL;				*NodeName=NULL;				NodeType=INVALID_NODE;				IsEnd=false;				return 1;			}			NodeType=ATTRIBUTE_NODE;			IsEnd=false;			atLeastOneAttrFound=true;			printf("=================== Check 6 \n");			return 0;		}	}	printf("=================== Check 7 \n");	return 0;}#endif							

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -