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


C++ Consume函数代码示例

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


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

示例1: Consume

    /**
        Check if current item is a "start group" tag with the given name and if so
        consumes that item.

        \param[in] name     Name of start group tag to check for.
        \param[in] dothrow  Should this function throw an exception if current
                            item is not a start group tag with the given name.
        
        \returns   true if current item is a start group tag with the given name,
                   else false.
        \throws    PersistUnexpectedDataException if next input is not the start of
                   expected group.
    */
    bool SCXFilePersistDataReader::ConsumeStartGroup(const std::wstring& name, bool dothrow /*= false*/)
    {
        std::wstreampos pos = m_Stream->tellg();
        try
        {
            Consume(L"<");
            Consume(L"Group");
            Consume(L"Name");
            Consume(L"=");
            ConsumeString(name);
            Consume(L">");
        }
        catch (PersistUnexpectedDataException& e)
        {
            m_Stream->seekg(pos);
            if (dothrow)
            {
                throw e;
            }
            return false;
        }
        
        m_StartedGroups.push_front(name);

        return true;
        
    }
开发者ID:Microsoft,项目名称:SCVMMLinuxGuestAgent,代码行数:40,代码来源:scxfilepersistdatareader.cpp

示例2: Consume

float TokParser::GetFloat()
{
	if(m_eof) { m_error = true; return 0.f; }
	if(m_tokType != T_NUMERIC)
	{
		m_error = true;
		Consume();
		return 0.f;
	}
	float value = (float)atof(m_token);
	Consume();
	// TODO: consider removing this and replacing with fprintf(out, "%1.8e", f)
	if(m_token[0] == ':')
	{
		Consume();
		char* endPtr;
		unsigned long rawValue = strtoul(m_token, &endPtr, 16);
		if(endPtr == m_token)
		{
			m_error = true;
			return 0.f;
		}
		unsigned int rawValue32 = (unsigned int)(rawValue);
		// TODO: correct endian-ness
		memcpy(&value, &rawValue32, sizeof(value));
		Consume();
	}
	return value;
}
开发者ID:lpanian,项目名称:lptoolkit,代码行数:29,代码来源:tokparser.cpp

示例3: Consume

int ConstExpression::P()
{
    Operator *op;
    if(op=GetOperator(Next()->type_id(),1)) // unary
    {
        Consume();
        int q = op->prec;
        int t = Exp(q);
        return MakeNode(op,t,0);
    }
    else if(Next()->type_id()==TKN_L_PAREN)
    {
        Consume();
        int t = Exp(0);
        Expect(TKN_R_PAREN);
        return t;
    }
    else if(Next()->type_id()==TKN_NUMBER)
    {
        int t = atoi(Next()->get_text().c_str());
        Consume();
        return t;
    }
    else
        exit(0);

}
开发者ID:asmwarrior,项目名称:quexparser,代码行数:27,代码来源:ConstExpression.cpp

示例4: switch

std::string PropertyParser::parseUnsigned() {
    switch(+CurrentTok.getKind()) {
    case clang::tok::kw_int:
        Consume();
        return "uint";
        break;
    case clang::tok::kw_long:
        Consume();
        if (Test(clang::tok::kw_int))
            return "unsigned long int";
        else if (Test(clang::tok::kw_long))
            return "unsigned long long";
        else
            return "ulong";
        break;
    case clang::tok::kw_char:
    case clang::tok::kw_short:
        Consume();
        if (Test(clang::tok::kw_int))
            return "unsigned short int";
        return "unsigned " + Spelling();
        break;
    default:
        return "unsigned";
        // do not consume;
    }
}
开发者ID:gmrehbein,项目名称:moc-ng,代码行数:27,代码来源:propertyparser.cpp

示例5: while

    //{
    //   WriteMask 
    //   ReadMask
    //   Ref
    //   Comp
    //   Pass
    //   Fail
    //   ZFail
    // }
    NodePtr Parser::StencilBlock()
    {
        if (!Match(Token::TOK_LEFT_BRACE))
            return nullptr;
        NodePtr stencilNode = std::make_unique<StencilNode>();
        while (!AtEnd()) {
            if (LookAhead(Token::TOK_RIGHT_BRACE)) {
                Consume();
                break;
            }
            auto Next = Consume();
            FnInfix infix = s_StencilExpr[Next.GetType()].second;
            if (infix) {
                stencilNode = (this->*infix)(std::move(stencilNode), Next);
            } else {
                SpawnError("Parsing stencil block failed", "Unexpected token");
                break;
            }

            if (AtEnd()) {
                SpawnError("Unexpected EoF in Stencil block", "'}' expected");
                return nullptr;
            }
        }
        return stencilNode;
    }
开发者ID:TsinStudio,项目名称:kaleido3d,代码行数:35,代码来源:sl_parse_state.cpp

示例6: SCXInvalidStateException

    /**
        Check if current item is an "end group" tag with the given name and if so
        consumes that item.

        \param[in] dothrow  Should this function throw an exception if current
                            item is not an end group tag with expected name.

        \returns   true if current item is an end group tag with the given name,
                   else false.
        \throws SCXInvalidStateException if no group is opened.
        \throws PersistUnexpectedDataException if next tag is not a close tag
                of the currently open group and dothrow is true.
    */
    bool SCXFilePersistDataReader::ConsumeEndGroup(bool dothrow /*= false*/)
    {
        if (m_StartedGroups.empty())
        {
            throw SCXInvalidStateException(L"No open group when calling ConsumeEndGroup.", SCXSRCLOCATION);
        }

        std::wstreampos pos = m_Stream->tellg();
        try
        {
            Consume(L"</");
            Consume(L"Group");
            Consume(L">");
        }
        catch (PersistUnexpectedDataException& e)
        {
            m_Stream->seekg(pos);
            if (dothrow)
            {
                throw e;
            }
            return false;
        }
        
        m_StartedGroups.pop_front();

        return true;
    }
开发者ID:Microsoft,项目名称:SCVMMLinuxGuestAgent,代码行数:41,代码来源:scxfilepersistdatareader.cpp

示例7: Array

 unique_ptr<QueryRuntimeFilter> Array() {
     if (!Consume("["))
         Error("[");
     kb_.PushArray();
     unique_ptr<QueryRuntimeFilter> filter = Bool();
     kb_.PopArray();
     if (!Consume("]"))
         Error("]");
     return filter;
 }
开发者ID:pipedown,项目名称:noisecpp,代码行数:10,代码来源:query.cpp

示例8: Factor

 unique_ptr<QueryRuntimeFilter> Factor() {
     if (Consume("(")) {
         unique_ptr<QueryRuntimeFilter> filter = Bool();
         if (!Consume(")"))
             Error(")");
         return filter;
     } else if (CouldConsume("[")) {
         return Array();
     }
     Error("Missing expression");
     return nullptr;
 }
开发者ID:pipedown,项目名称:noisecpp,代码行数:12,代码来源:query.cpp

示例9: DO

bool TGztParser::ParseGztFileOption(TGztFileDescriptorProto* file) {
  DO(Consume("option"));
  Stroka option_name;
  DO(ConsumeString(&option_name, "Expected an option name."));
  if (option_name == "strip-names" || option_name == "strip_names" || option_name == "strip names")
      file->set_strip_names(true);
  //else if <other option here>
  else {
      AddError(Substitute("Unrecognized option \"$0\".", option_name));
      return false;
  }
  DO(Consume(";"));
  return true;
}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:14,代码来源:gztparser.cpp

示例10: SpawnError

 bool Parser::ParseBlendFactor(ngfx::BlendFactor & src, ngfx::BlendFactor & dst)
 {
     if (!LookAhead(Token::TOK_IDENTIFIER) || !IsBlendFactor(Cur().Str())) {
         SpawnError("Parsing source Blend factor failed", "Unexpected token !");
         return false;
     }
     src = blendFactorKeywords[Consume().Str()];
     if (!LookAhead(Token::TOK_IDENTIFIER) || !IsBlendFactor(Cur().Str()))
     {
         SpawnError("Parsing dest Blend factor failed", "Unexpected token !");
         return false;
     }
     dst = blendFactorKeywords[Consume().Str()];
     return true;
 }
开发者ID:TsinStudio,项目名称:kaleido3d,代码行数:15,代码来源:sl_parse_state.cpp

示例11: memset

ssize_t
DaemonSocketPDU::Send(int aFd)
{
  struct iovec iv;
  memset(&iv, 0, sizeof(iv));
  iv.iov_base = GetData(GetLeadingSpace());
  iv.iov_len = GetSize();

  struct msghdr msg;
  memset(&msg, 0, sizeof(msg));
  msg.msg_iov = &iv;
  msg.msg_iovlen = 1;
  msg.msg_control = nullptr;
  msg.msg_controllen = 0;

  ssize_t res = TEMP_FAILURE_RETRY(sendmsg(aFd, &msg, 0));
  if (res < 0) {
    MOZ_ASSERT(errno != EBADF); /* internal error */
    OnError("sendmsg", errno);
    return -1;
  }

  Consume(res);

  if (mConsumer) {
    // We successfully sent a PDU, now store the
    // result runnable in the consumer.
    mConsumer->StoreUserData(*this);
  }

  return res;
}
开发者ID:paulmadore,项目名称:luckyde,代码行数:32,代码来源:DaemonSocketPDU.cpp

示例12: DoStatement

static void DoStatement (void)
/* Handle the 'do' statement */
{
    /* Get the loop control labels */
    unsigned LoopLabel      = GetLocalLabel ();
    unsigned BreakLabel     = GetLocalLabel ();
    unsigned ContinueLabel  = GetLocalLabel ();

    /* Skip the while token */
    NextToken ();

    /* Add the loop to the loop stack */
    AddLoop (BreakLabel, ContinueLabel);

    /* Define the loop label */
    g_defcodelabel (LoopLabel);

    /* Parse the loop body */
    Statement (0);

    /* Output the label for a continue */
    g_defcodelabel (ContinueLabel);

    /* Parse the end condition */
    Consume (TOK_WHILE, "`while' expected");
    TestInParens (LoopLabel, 1);
    ConsumeSemi ();

    /* Define the break label */
    g_defcodelabel (BreakLabel);

    /* Remove the loop from the loop stack */
    DelLoop ();
}
开发者ID:Aliandrana,项目名称:cc65,代码行数:34,代码来源:stmt.c

示例13: SkipWhite

    std::string TaskFactory::GetNextToken(char const * & text)
    {
        std::string token;

        SkipWhite(text);

        if (*text == '"')
        {
            // Quoted string literal
            ++text;
            while (*text != '"')
            {
                if (*text == '\0')
                {
                    RecoverableError error("Expected closing \" in string literal.");
                    throw error;
                }
                token.push_back(*text);
                ++text;
            }
            Consume(text, '"');
        }
        else if (*text != '\0')
        {
            // Non-quoted literal.
            std::string s;
            while (!IsSpace(*text) && *text != '\0')
            {
                token.push_back(*text);
                ++text;
            }
        }

        return token;
    }
开发者ID:danluu,项目名称:BitFunnel,代码行数:35,代码来源:TaskFactory.cpp

示例14: expect

/**
expect( tok ) is
   if next = tok
       consume
   else
       error
*/
int ConstExpression::Expect(QUEX_TYPE_TOKEN_ID op)
{
    if (Next()->type_id() == op)
        Consume();
    else
        exit(0);

}
开发者ID:asmwarrior,项目名称:quexparser,代码行数:15,代码来源:ConstExpression.cpp

示例15: count

unsigned TimeOutReceiver::TimeOutWait(unsigned expected_message_count,unsigned time_out_in_ms){
	unsigned long long int start=curtick();
	unsigned count(0);
	while(count<expected_message_count&&getMilliSecond(start)<time_out_in_ms){
		count+=Consume(expected_message_count-count);
	}
	return count;
}
开发者ID:NagamineLee,项目名称:Claims,代码行数:8,代码来源:TimeOutReceiver.cpp


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