本文整理匯總了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;
}
示例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;
}
示例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);
}
示例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;
}
}
示例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;
}
示例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;
}
示例7: Array
unique_ptr<QueryRuntimeFilter> Array() {
if (!Consume("["))
Error("[");
kb_.PushArray();
unique_ptr<QueryRuntimeFilter> filter = Bool();
kb_.PopArray();
if (!Consume("]"))
Error("]");
return filter;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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 ();
}
示例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;
}
示例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);
}
示例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;
}