コード例 #1
0
ファイル: RI_RRASM_Parser.cpp プロジェクト: UIKit0/RibTools
//==================================================================
void Parser::doParse( DUT::MemFile &file )
{
	char		lineBuff[1024];
	Section		curSection = SEC_UNDEF;
	int			lineCnt = 0;

	while ( file.ReadTextLine( lineBuff, sizeof(lineBuff) ) )
	{
		char	lineWork[1024];

		strcpy_s( lineWork, lineBuff );

		stripComments( lineWork );

		DUT::StrStripBeginEndWhite( lineWork );

		if NOT( lineWork[0] )
		{
			++lineCnt;
			continue;
		}

		try
		{
			if ( handleShaderTypeDef( lineWork, curSection ) )
			{
				++lineCnt;
				continue;
			}

			if ( 0 == strcasecmp( lineWork, ".data" ) )
				curSection = SEC_DATA;
			else
			if ( 0 == strcasecmp( lineWork, ".code" ) )
				curSection = SEC_CODE;
			else
			if ( curSection == SEC_DATA )
			{
				parseDataLine( lineWork, lineCnt );
			}
			else
			if ( curSection == SEC_CODE )
			{
				parseCodeLine( lineWork, lineCnt );
			}
		}
		catch ( ... )
		{
			printf( "For shader '%s' at line %i\n%i) %s\n", mpName, lineCnt+1, lineCnt+1, lineBuff );
			throw;
		}

		++lineCnt;
	}

	if ( mpShader->mType == SVM::Shader::TYPE_UNKNOWN )
		onError( "Shader type undefined !" );
}
コード例 #2
0
ファイル: my_parser.cpp プロジェクト: orcchg/ChatServer
Response MyParser::parseResponse(char* http, int nbytes) const {
  const char* CRLF = "\r\n";
  std::istringstream iss(http);
  //MSG("Input: %s", iss.str().c_str());
  Response response;

  // code line
  std::string code_line;
  std::getline(iss, code_line);
  //MSG("code=%s", code_line.c_str());
  response.codeline = parseCodeLine(code_line);

  // headers
  std::string header_line;
  std::vector<Header> headers;
  while (true) {
    std::getline(iss, header_line);
    if (isHeader(header_line)) {
      Header header = parseHeader(header_line);
      headers.push_back(header);
      //MSG("header=%s", header_line.c_str());
    } else {
      break;
    }
  }
  response.headers = headers;

  // body
  std::string ending = "";
  response.body = "";
  std::string line;
  while (std::getline(iss, line)) {
    line.erase(std::remove(line.begin(), line.end(), '\r'), line.end());
    response.body.append(ending);
    response.body.append(line);
    ending = "\n";
  }

  return response;
}