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


C++ skipWhitespace函数代码示例

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


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

示例1: parseFile

void
parseFile(FILE *file)
{
    char *line, c;
    int len, lineNumber;
    
    line = malloc(MAXLINE+1);
    lineNumber = 1;
    
    skipWhitespace(file);
    
    while (!feof(file)) {
	c = peekf(file);
	if (c == '#' || c == '/') {
	    len = getLineThru(file, line, '\n', MAXLINE);
	    if (c == '#')
		fprintf(ofile, line);
	} else {
	    len = getLineThru(file, line, ';', MAXLINE);
	    parseLine(line);
	}
	skipWhitespace(file);
    }
    free(line);
}
开发者ID:aosm,项目名称:boot,代码行数:25,代码来源:sig.c

示例2: name

/**
 * Throws: std::invalid_argument upon invalid argument
 * and other std::exceptions's from string methods. 
 */
Http::Cookie::Cookie(const char *cookieStr) 
    : name(), value()
{
    const char *ptr;
    bool parsed = false;

    ptr = cookieStr;
    while (isToken(*ptr)) {
	ptr += 1;
    }

    if (ptr > cookieStr) {
	name.append(cookieStr, ptr - cookieStr);
	ptr = skipWhitespace(ptr);
	if ('=' == *ptr) {
	    const char *startPtr;

	    ptr = skipWhitespace(ptr + 1);
	    startPtr = ptr;
	    while (*ptr && ';' != *ptr) { 
		ptr += 1;
	    }
	    if (ptr > startPtr) {
		value.append(startPtr, ptr - startPtr);
		parsed = true;
	    }
	}
    }

    if (! parsed) {
	throw std::invalid_argument(cookieStr);
    }
}
开发者ID:JonathanFu,项目名称:OpenAM-1,代码行数:37,代码来源:http.cpp

示例3: skipWhitespace

bool CssParser::parseBlock (TokenList* tokens) {
  if (tokenizer->getTokenType() != Token::BRACKET_OPEN)
    return false;

  tokens->push(tokenizer->getToken()->clone());
  tokenizer->readNextToken();
  skipWhitespace();
  
  while (true) {
    if (!(parseAny(tokens) || parseBlock(tokens))) {
      if (tokenizer->getTokenType() == Token::ATKEYWORD) {
        tokens->push(tokenizer->getToken()->clone());
        tokenizer->readNextToken();
        parseWhitespace(tokens);
      } else if (tokenizer->getTokenType() == Token::DELIMITER) {
        tokens->push(tokenizer->getToken()->clone());
        tokenizer->readNextToken();
        skipWhitespace();
      } else
        break;
    }
  }

  if (tokenizer->getTokenType() != Token::BRACKET_CLOSED) {
    throw new ParseException(tokenizer->getToken()->str,
                             "end of block ('}')");
  }
  tokens->push(tokenizer->getToken()->clone());
  tokenizer->readNextToken();
  skipWhitespace();
  return true;
}
开发者ID:smalyshev,项目名称:clessc,代码行数:32,代码来源:CssParser.cpp

示例4: skipWhitespace

	ObjectPtr Object::fromJson(std::istream& is) {
		int next_ch = skipWhitespace(is);
		if (next_ch == -1)
			throw runtime_error(
			"JsonXObject::read(): Premature end of file");
		if (next_ch != '{')
			throw runtime_error(
			"Character '{' expected. Got: '" +
			to_string(static_cast<char>(next_ch)) + "'");
		unique_ptr<ObjectValue> pv{ new ObjectValue() };
		readChar(is);;
		next_ch = skipWhitespace(is);
		if (next_ch != '}') {
			while (true) {
				string key{ String::fromJsonRaw(is) };
				next_ch = skipWhitespace(is);
				if (next_ch != ':')
					throw runtime_error(
					"Expected ':'. Got: '" +
					to_string(static_cast<char>(next_ch)) + "'");
				readChar(is);
				pv.get()->push_back(ObjectEntry{ key, Value::fromJson(is) });
				next_ch = skipWhitespace(is);
				if (next_ch == '}')
					break;
				if (next_ch != ',')
					throw runtime_error(
					"Expected ',' or '}'. Got: '" +
					to_string(static_cast<char>(next_ch)) + "'");
				readChar(is);
			} // end while //
		}
		readChar(is);
		return Object::make(pv);
	}
开发者ID:df9ry,项目名称:libJsonX,代码行数:35,代码来源:Deserialize.cpp

示例5: skipWhitespace

bool LessParser::parseVariable (TokenList &value) {
  if (tokenizer->getTokenType() != Token::COLON)
    return false;
  
  tokenizer->readNextToken();
  skipWhitespace();
    
  if (parseValue(value) == false || value.size() == 0) {
    throw new ParseException(tokenizer->getToken(),
                             "value for variable",
                             tokenizer->getLineNumber(),
                             tokenizer->getColumn(),
                             tokenizer->getSource());
  }
  if (tokenizer->getTokenType() != Token::DELIMITER) {
    throw new ParseException(tokenizer->getToken(),
                             "delimiter (';') at end of @-rule",
                             tokenizer->getLineNumber(),
                             tokenizer->getColumn(),
                             tokenizer->getSource());
  }
  tokenizer->readNextToken();
  skipWhitespace();

  return true;
}
开发者ID:trav-c,项目名称:clessc,代码行数:26,代码来源:LessParser.cpp

示例6: skipWhitespace

/**
 * Checks if the cursor is at a valid type cast expression, after encountering
 * a left parenthesis. If it is, determine the signedness and bit width of the
 * type cast. If not, move the cursor back to the left parenthesis.
 *
 * @param[out] isSigned: the signedness of the resulting typecast
 * @param[out] bitWidth: the bit width of the resulting typecast
 *
 * @return: if the typecast expression is valid
 */
bool
MacroScanner::validTypeCast(bool *isSigned, size_t *bitWidth)
{
	char const *const savedCursor = _cursor;

	if (!atSymbol(LPAREN)) {
		return false;
	}

	skipWhitespace();

	const char *start = _cursor;
	const char *end = start;

	while (isalpha(*_cursor)) {
		do {
			_cursor += 1;
		} while (('_' == *_cursor) || isalnum(*_cursor));

		end = _cursor;

		skipWhitespace();
	}

	if (!atSymbol(RPAREN)) {
		_cursor = savedCursor;
		return false;
	}

	return Type::isStandardType(start, (size_t)(end - start), isSigned, bitWidth);
}
开发者ID:LinHu2016,项目名称:omr,代码行数:41,代码来源:Macro.cpp

示例7: parser

byte parser(
  char       *message,
  byte        length,
  bytecode_t *bytecode) {

  byte errorCode = 0;
  byte position = 0;

  skipWhitespace(message, length, & position);

  command_t *command;

  errorCode = parseCommand(message, length, & position, & command);

  if (errorCode == 0) {
    skipWhitespace(message, length, & position);

    errorCode =
      (command->parser)(message, length, & position, command, bytecode);

    if (errorCode == 0) {
      skipWhitespace(message, length, & position);
    }
  }

  return(errorCode);
}
开发者ID:dunk8888,项目名称:Cube4,代码行数:27,代码来源:parser.cpp

示例8: parseCommandSphere

byte parseCommandSphere(
  char       *message,
  byte        length,
  byte       *position,
  command_t  *command,
  bytecode_t *bytecode) {

  byte positionX1;
  byte positionY1;
  byte positionZ1;
  byte size;
  byte errorCode = 0;
  bytecode->executer = command->executer;

  skipWhitespace(message, length, position);
  errorCode = parsePosition(message, length, position, & positionX1, & positionY1, & positionZ1);
  skipWhitespace(message, length, position);
  errorCode = parseOffset(message, length, position, & size);
  skipWhitespace(message, length, position);
  errorCode = parseRGB(message, length, position, & bytecode->u.lit.colorFrom);
  skipWhitespace(message, length, position);
  errorCode = parseRGB(message, length, position, & bytecode->u.lit.colorTo);
  if (errorCode) {
    errorCode = 0;
    bytecode->u.lit.colorTo = BLACK;
  }

  if (errorCode == 0) cubeSphere( positionX1, positionY1, positionZ1, size, bytecode->u.lit.colorFrom, bytecode->u.lit.colorTo);

  return(errorCode);
};
开发者ID:dunk8888,项目名称:Cube4,代码行数:31,代码来源:parser.cpp

示例9: parseCommandMoveplane

byte parseCommandMoveplane(
  char       *message,
  byte        length,
  byte       *position,
  command_t  *command,
  bytecode_t *bytecode) {

  byte axis;
  byte offset;
  byte destination;
  rgb_t rgb;
  byte errorCode = 0;
  bytecode->executer = command->executer;

  skipWhitespace(message, length, position);
  errorCode = parseAxis(message, length, position, & axis);
  skipWhitespace(message, length, position);
  errorCode = parseOffset(message, length, position, & offset);
  skipWhitespace(message, length, position);
  errorCode = parseOffset(message, length, position, & destination);
  skipWhitespace(message, length, position);
  errorCode = parseRGB(message, length, position, & rgb);

  if (errorCode == 0) cubeMoveplane(axis, offset, destination, rgb);

  return(errorCode);
};
开发者ID:dunk8888,项目名称:Cube4,代码行数:27,代码来源:parser.cpp

示例10: parseCommandLine

byte parseCommandLine(
  char       *message,
  byte        length,
  byte       *position,
  command_t  *command,
  bytecode_t *bytecode) {

  byte positionX1;
  byte positionY1;
  byte positionZ1;
  byte positionX2;
  byte positionY2;
  byte positionZ2;
  byte errorCode = 0;
  bytecode->executer = command->executer;

  skipWhitespace(message, length, position);
  errorCode = parsePosition(message, length, position, & positionX1, & positionY1, & positionZ1);
  skipWhitespace(message, length, position);
  errorCode = parsePosition(message, length, position, & positionX2, & positionY2, & positionZ2);
  skipWhitespace(message, length, position);
  errorCode = parseRGB(message, length, position, & bytecode->u.lit.colorFrom);

  if (errorCode == 0) cubeLine( positionX1, positionY1, positionZ1, positionX2, positionY2, positionZ2, bytecode->u.lit.colorFrom);

  return(errorCode);
};
开发者ID:dunk8888,项目名称:Cube4,代码行数:27,代码来源:parser.cpp

示例11: skipWhitespace

int Parser::getNextToken()
{
    int saveIndex = m_index;

    skipWhitespace();
    if (isdigit(nextChar())) {
        // At this point we know that there is a valid number in the
        // string.  The only question now, is whether it is an int or a
        // float.

        parseInt(&m_intVal);

        skipWhitespace();
        if (nextChar() == '.') {
            m_index = saveIndex;

            // No need to check since we already know it is correct.
            (void) parseSimpleFloat(&m_floatVal);
            m_nextToken = FLOAT_TOKEN;
        } else {
            m_nextToken = INT_TOKEN;
        }
    } else if (nextChar() != -1) {
        // Any character.
        m_nextToken = nextChar();
        getNextChar();
    } else {
        // End of string.
        m_nextToken = -1;
    }

    return m_nextToken;
}
开发者ID:Anumittal,项目名称:Kalzium,代码行数:33,代码来源:parser.cpp

示例12: skipWhitespace

void InText::readString(std::string& value, PhysicalInStream& stream)
{
  value = "";
  skipWhitespace(stream);
  bool containsSpaces = theChar == '"';
  if(containsSpaces && !isEof(stream))
    nextChar(stream);
  while(!isEof(stream) && (containsSpaces || !isWhitespace()) && (!containsSpaces || theChar != '"'))
  {
    if(theChar == '\\')
    {
      nextChar(stream);
      if(theChar == 'n')
        theChar = '\n';
      else if(theChar == 'r')
        theChar = '\r';
      else if(theChar == 't')
        theChar = '\t';
    }
    value += theChar;
    if(!isEof(stream))
      nextChar(stream);
  }
  if(containsSpaces && !isEof(stream))
    nextChar(stream);
  skipWhitespace(stream);
}
开发者ID:Yanzqing,项目名称:BHumanCodeRelease,代码行数:27,代码来源:InStreams.cpp

示例13: SCPI_Input

/**
 * Interface to the application. Adds data to system buffer and try to search
 * command line termination. If the termination is found or if len=0, command
 * parser is called.
 * 
 * @param context
 * @param data - data to process
 * @param len - length of data
 * @return 
 */
int SCPI_Input(scpi_t * context, const char * data, size_t len) {
    int result = 0;
    const char * cmd_term;
    if (len == 0) {
        context->buffer.data[context->buffer.position] = 0;
        result = SCPI_Parse(context, context->buffer.data, context->buffer.position);
        context->buffer.position = 0;
    } else {
        size_t buffer_free;
        int ws;
        buffer_free = context->buffer.length - context->buffer.position;
        if (len > (buffer_free - 1)) {
            return -1;
        }
        memcpy(&context->buffer.data[context->buffer.position], data, len);
        context->buffer.position += len;
        context->buffer.data[context->buffer.position] = 0;

        ws = skipWhitespace(context->buffer.data, context->buffer.position);
        cmd_term = cmdlineTerminator(context->buffer.data + ws, context->buffer.position - ws);
        while (cmd_term != NULL) {
            int curr_len = cmd_term - context->buffer.data;
            result = SCPI_Parse(context, context->buffer.data + ws, curr_len - ws);
            memmove(context->buffer.data, cmd_term, context->buffer.position - curr_len);
            context->buffer.position -= curr_len;
    
            ws = skipWhitespace(context->buffer.data, context->buffer.position);
            cmd_term = cmdlineTerminator(context->buffer.data + ws, context->buffer.position - ws);
        }
    }

    return result;
}
开发者ID:WCP52,项目名称:gpha,代码行数:43,代码来源:parser.c

示例14: findProxyClient

AtomListPtr
findProxyClient(char *line)
{
    AtomListPtr alv;
    AtomPtr name, value;
    int i=0;
    alv = makeAtomList(NULL, 0);
    if(alv == NULL) {
        do_log(L_ERROR, "couldn't allocate atom list.\n");
        return NULL;
    }
    while(1) {
        i = parseAtom1(line, i, &value,1);
        //if(i < 0) goto syntax;
        if(!value) {
            do_log(L_ERROR, "couldn't allocate atom.\n");
            return NULL;
        }
        //printf("%s\n",value->string);
        atomListCons(value, alv);
        i = skipWhitespace(line, i);
        if(line[i] == '\n' || line[i] == '\0' || line[i] == '#')
            break;
        if(line[i] != ',') {
            destroyAtomList(alv);
            //goto syntax;
        }
        i = skipWhitespace(line, i + 1);
    }
    return alv;
}
开发者ID:bigbadnad,项目名称:socialproxy,代码行数:31,代码来源:social.c

示例15: skipWhitespace

bool ValueProcessor::validateCondition(const TokenList &value,
                                       const ValueScope &scope,
                                       bool defaultVal) const {
  TokenList::const_iterator i = value.begin();
  TokenList::const_iterator end = value.end();
  bool negate = false;
  bool ret;

  skipWhitespace(i, end);

  if (*i == "not") {
    negate = true;
    i++;
  }
    
  ret = validateValue(i, end, scope, defaultVal);

  skipWhitespace(i, end);

  while (ret == true && i != value.end() && *i == "and") {
    i++;

    skipWhitespace(i, end);

    ret = validateValue(i, end, scope, defaultVal);

    skipWhitespace(i, end);
  }

  return negate ? !ret : ret;
}
开发者ID:BramvdKroef,项目名称:clessc,代码行数:31,代码来源:ValueProcessor.cpp


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