bool BaseParser::ParseBool(const std::string& value, bool& ret) { if(str_i_cmp(value, "true")) { ret = true; return true; } if(str_i_cmp(value, "false")) { ret = false; return true; } return false; }
bool MaterialParser::ParseIdentifier(Lexer* lexer) { Token token = lexer->CurToken(); if(str_i_cmp(token.str, "SamplerState")) { SamplerStateParserPtr pParser = std::make_shared<SamplerStateParser>(this, m_logger); if(pParser->Parse(lexer) == false) { return false; } m_members.push_back(pParser); return true; } if(str_i_cmp(token.str, "RenderState")) { RenderStateParserPtr pParser = std::make_shared<RenderStateParser>(this, m_logger); if(pParser->Parse(lexer) == false) { return false; } m_members.push_back(pParser); return true; } if(str_i_cmp(token.str, "Technique")) { TechniqueParserPtr pParser = std::make_shared<TechniqueParser>(this, m_logger); if(pParser->Parse(lexer, m_rootDir) == false) { return false; } m_members.push_back(pParser); return true; } Error(token.line, "unexpected token: '" + token.str + "'"); return false; }
/** * finds the queue associated with the message's method * (expects rl_lock to be taken) * \return 0 if a nueue was found, -1 otherwise */ static int find_queue(struct sip_msg * msg, int * queue) { str method = msg->first_line.u.request.method; int i; *queue = -1; for (i=0; i<*nqueues; i++) if (! str_i_cmp(queues[i].method, &method)) { *queue = i; return 0; } else if (! str_i_cmp(queues[i].method, &queue_other)) { *queue = i; } if (*queue >= 0) return 0; LM_INFO("no queue matches\n"); return -1; }
bool BaseParser::ValidateEnumValue(const std::string& value, char* list[]) { for(int i = 0; list[i] != 0; ++i) { if(str_i_cmp(value, list[i])) { return true; } } return false; }
bool BaseParser::ParseEnum(const std::string& value, uint32& e, std::pair<std::string, uint32> list[]) { for(int i = 0; list[i] != std::pair<std::string, uint32>(); ++i) { if(str_i_cmp(value, list[i].first)) { e = list[i].second; return true; } } return false; }
bool PassParser::SetState(const std::vector<Token>& func) { if(ValidateEnumValue(func[0].str, StateList) == false) { Error(func[0].line, "undefined function call: '" + func[0].str + "'"); return false; } //"SetVertexShader" if(str_i_cmp(func[0].str, "SetVertexShader")) { if(func.size() != 2 && func.size() != 3) { Error(func[0].line, "SetVertexShader: invalid argment count"); return false; } if(func[1].type != Token::token_string) { Error(func[0].line, "SetVertexShader: arg 0: invalid type, should be string."); return false; } if(func[1].str == "") { _VertexShader = ""; return true; } _VertexShader = m_rootDir / func[1].str; _VertexShaderEntry = ""; if(func.size() == 3) { _VertexShaderEntry = func[2].str; } if(false == boost::filesystem::exists(_VertexShader)) { Error(func[0].line, "SetVertexShader: file not found: '" + _VertexShader.string() + "'"); return false; } return true; } //"SetGeometryShader" if(str_i_cmp(func[0].str, "SetGeometryShader")) { if(func.size() != 2 && func.size() != 3) { Error(func[0].line, "SetGeometryShader: invalid argment count"); return false; } if(func[1].type != Token::token_string) { Error(func[0].line, "SetGeometryShader: arg 0: invalid type, should be string."); return false; } if(func[1].str == "") { _GeometryShader = ""; return true; } _GeometryShader = m_rootDir / func[1].str; _GeometryShaderEntry = ""; if(func.size() == 3) { _GeometryShaderEntry = func[2].str; } if(false == boost::filesystem::exists(_GeometryShader)) { Error(func[0].line, "SetGeometryShader: file not found: '" + _GeometryShader.string() + "'"); return false; } return true; } //"SetPixelShader", if(str_i_cmp(func[0].str, "SetPixelShader")) { if(func.size() != 2 && func.size() != 3) { Error(func[0].line, "SetPixelShader: invalid argment count"); return false; } if(func[1].type != Token::token_string) { Error(func[0].line, "SetPixelShader: arg 0: invalid type, should be string."); return false; } if(func[1].str == "") { _PixelShader = ""; return true; } _PixelShader = m_rootDir / func[1].str; _PixelShaderEntry = ""; if(func.size() == 3) { _PixelShaderEntry = func[2].str; } if(false == boost::filesystem::exists(_PixelShader)) { Error(func[0].line, "SetPixelShader: file not found: '" + _PixelShader.string() + "'"); return false; } return true; } //"SetRenderState" if(str_i_cmp(func[0].str, "SetRenderState")) { if(func.size() != 2) { Error(func[0].line, "SetRenderState: invalid argment count"); return false; } if(func[1].type != Token::token_id) { Error(func[0].line, "SetRenderState: arg 0: invalid type, should be renderstate object."); return false; } if(nullptr == FindSymbol(func[1].str, false)) { Error(func[0].line, "SetRenderState: arg 0: undefined symbol: '" + func[1].str + "'"); return false; } _RenderState = func[1].str; return true; } //"BindSampler" if(str_i_cmp(func[0].str, "BindSampler")) { if(func.size() != 3) { Error(func[0].line, "BindSampler: invalid argment count"); return false; } if(func[1].type != Token::token_string) { Error(func[0].line, "BindSampler: arg 0: invalid type, should be string."); return false; } if(func[2].type != Token::token_id) { Error(func[0].line, "BindSampler: arg 1: invalid type, should be sampler object."); return false; } if(nullptr == FindSymbol(func[2].str, false)) { Error(func[0].line, "BindSampler: arg 1: undefined symbol: '" + func[2].str + "'"); return false; } _SamplerLink.push_back(SamplerLink(func[1].str, func[2].str)); return true; } return false; }