• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ skipSpaces函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: parsePointList

vector< pair<int,int> > parsePointList(string::const_iterator& p, const string::const_iterator& end) {
	vector< pair<int,int> > result;

	skipSpaces(p, end);
	if (p == end) {
		return vector< pair<int,int> >();  // error
	}

	if (*p == '[') {
		++p;
	} else {
		return vector< pair<int,int> >();  // error
	}

	while(p != end) {
		const pair<int,int>& pt = parsePoint(p, end);
		result.push_back(pt);

		skipSpaces(p, end);
		if (p == end) {
			return vector< pair<int,int> >();  // error
		}

		if (*p == ',') {
			++p;
		} else if (*p == ']') {
			++p;
			skipSpaces(p, end);  // read to end
		} else {
			return vector< pair<int,int> >();  // error
		}
	}

	return result;
}
开发者ID:rgoulter,项目名称:cs5237-VoronoiArt,代码行数:35,代码来源:pointsetio.cpp


示例2: JSONParser

	JSONParser( const std::string& jsonStr ) : std::map< std::string, std::string >() {
		m_jsonStr = jsonStr;
		pos = 1;
		skipSpaces();

		long keyCount = 0;
		std::string key;
		while ( pos < m_jsonStr.length() ) {
			if ( ( m_jsonStr[ 0 ] == '[' ) || keyCount ) {
				key = numToStr( keyCount++ );
			}
			else {
				key = findKey();
			}
			if ( pos >= m_jsonStr.length() ) {
				return;
			}
			std::string value = findValue( keyCount != 0 );
			insert( std::pair< std::string, std::string >( key, value ) );
			if ( keyCount && ( m_jsonStr[ pos ] == ',' || m_jsonStr[ pos ] == ']' ) ) {
				++pos;
				skipSpaces();
			}
			else {
				moveToEndChar();
            }
		}
	}
开发者ID:fast01,项目名称:jrtti,代码行数:28,代码来源:jsonparser.hpp


示例3: skipNonData

// Skips over intervening non-data elements in a netpbm file
static
void skipNonData(FILE *src)
{
    skipSpaces(src);
    skipComments(src);
    skipSpaces(src);
}
开发者ID:KhronosGroup,项目名称:KTX,代码行数:8,代码来源:image.cpp


示例4: skipSpaces

double Calculator::parseSymbol(std::string_view &ref)
{
	double value = 0;
	skipSpaces(ref);
	if (!ref.empty() && ref[0] == '(')
	{
		ref.remove_prefix(1);
		value = parseExprSum(ref);
		skipSpaces(ref);
		if (!ref.empty() && ref[0] == ')')
		{
			ref.remove_prefix(1);
			return value;
		}
		else
		{
			return std::numeric_limits<double>::quiet_NaN();
		}
	}
	else if (!ref.empty() && !std::isdigit(ref[0]) && ref[0] != '-')
	{
		return parseFunction(ref);
	}
	else
	{
		return parseDouble(ref);
	}
}
开发者ID:alisa-teplouhova,项目名称:Calc,代码行数:28,代码来源:Calculator.cpp


示例5: isSpace

void 
XmlUniformiser::copyElementAttributes()
{
  do
  {
    bool hadSpace = isSpace();
    skipSpaces();
    if ( startsWith( ">" ) )
      break;

    if ( hadSpace )
      m_stripped += ' ';

    copyAttributeName();
    skipSpaces();
    if ( startsWith( "=" ) )
    {
      copyNext();
      copyAttributeValue();
    }
    else    // attribute should always be valued, ne ?
      m_stripped += ' ';
  }
  while ( isValidIndex() );
  copyNext();
}
开发者ID:asir6,项目名称:Colt,代码行数:26,代码来源:XmlUniformiser.cpp


示例6: parseArray

		void parseArray(const char* json, JsonArray& array)
		{
			RIO_ASSERT_NOT_NULL(json);

			if (*json == '[')
			{
				json = getNext(json, '[');
				json = skipSpaces(json);

				if (*json == ']')
				{
					json = getNext(json, ']');
					return;
				}

				while (*json)
				{
					ArrayFn::pushBack(array, json);

					json = skipValue(json);
					json = skipSpaces(json);

					if (*json == ']')
					{
						json = getNext(json, ']');
						return;
					}

					json = skipSpaces(json);
				}
			}

			RIO_FATAL("Bad array");
		}
开发者ID:XoDeR,项目名称:RE,代码行数:34,代码来源:Rjson.cpp


示例7: pgm_read_word

static const char PROGMEM *jsonParseArray(char **buffer, const t_json *currentStructure) {
    char *buf =  *buffer;
    jsonHandleEndArray endFunc = (jsonHandleEndArray) pgm_read_word(&currentStructure->handleEndArray);
    if (currentStructure && !endFunc) {
        return PSTR("Unexpected array");
    }
    uint8_t count = 0;
    do {
        buf = skipSpaces(&buf[1]); // skip '[' and then ',' on each loop
        if (buf[0] == ']') {
        	break;
        }
        const char PROGMEM *res = jsonParseValue(&buf, currentStructure, count);
        if (res) {
            return res;
        }
//        DEBUG_PRINT(">>>S>");
//        DEBUG_PRINT(buf[0]);
//        DEBUG_PRINTLN(buf[1]);
        buf = skipSpaces(buf);
        count++;
    } while (buf[0] == ',');
    buf = skipSpaces(buf);
    if (buf[0] != ']') { // end of object
        return JSON_ERROR_NO_ARRAY_END;
    }

    const char PROGMEM *res = endFunc(count);
    if (res) {
        return res;
    }
    buf = skipSpaces(&buf[1]); // going out of array
    *buffer = buf;
    return 0;
}
开发者ID:housecream,项目名称:restmcu,代码行数:35,代码来源:json.cpp


示例8: parseCommands

static std::vector<AlterMetaDataCommand> parseCommands( const std::string& source)
{
	std::vector<AlterMetaDataCommand> rt;
	std::string::const_iterator si = source.begin(), se = source.end();

	for (si = skipSpaces( si, se); si != se; si = skipSpaces( si, se))
	{
		std::string cmd( parseIdentifier( si, se, _TXT("command name")));
		if (strus::utils::caseInsensitiveEquals( cmd, "Alter"))
		{
			std::string name( parseIdentifier( si, se, _TXT("old element name")));
			std::string newname( parseIdentifier( si, se, _TXT("new element name")));
			std::string type( parseIdentifier( si, se, _TXT("new element type")));

			rt.push_back( AlterMetaDataCommand::AlterElement( name, newname, type));
		}
		else if (strus::utils::caseInsensitiveEquals( cmd, "Add"))
		{
			std::string name( parseIdentifier( si, se, _TXT("element name")));
			std::string type( parseIdentifier( si, se, _TXT("element type name")));

			rt.push_back( AlterMetaDataCommand::AddElement( name, type));
		}
		else if (strus::utils::caseInsensitiveEquals( cmd, "Rename"))
		{
			std::string name( parseIdentifier( si, se, _TXT("old element name")));
			std::string newname( parseIdentifier( si, se, _TXT("new element name")));

			rt.push_back( AlterMetaDataCommand::RenameElement( name, newname));
		}
		else if (strus::utils::caseInsensitiveEquals( cmd, "Delete"))
		{
			std::string name( parseIdentifier( si, se, _TXT("element name")));

			rt.push_back( AlterMetaDataCommand::DeleteElement( name));
		}
		else if (strus::utils::caseInsensitiveEquals( cmd, "Clear"))
		{
			std::string name( parseIdentifier( si, se, _TXT("element name")));
			
			rt.push_back( AlterMetaDataCommand::ClearValue( name));
		}
		si = skipSpaces( si, se);
		if (si == se)
		{
			break;
		}
		else if (*si == ';')
		{
			++si;
		}
		else
		{
			std::string str( si, si+30);
			throw strus::runtime_error( _TXT( "semicolon expected as separator of commands at '..."), str.c_str());
		}
	}
	return rt;
}
开发者ID:andreasbaumann,项目名称:strusUtilities,代码行数:59,代码来源:strusAlterMetaData.cpp


示例9: fopen

static struct reglist_t const *registerDefs(void){
	static struct reglist_t *regs = 0 ;
	if( 0 == regs ){
		struct reglist_t *head = 0, *tail = 0 ;
		FILE *fDefs = fopen(devregsPath, "rt");
		if( fDefs ){
			char inBuf[256];
			int lineNum = 0 ;
			while( fgets(inBuf,sizeof(inBuf),fDefs) ){
				lineNum++ ;
				// skip unprintables
                                char *next = skipSpaces(inBuf);
				if( *next && ('#' != *next) ){
					trimCtrl(next);
					printf( "<%s>\n", next );
				} // not blank or comment
				if(isalpha(*next)){
					char *start = next++ ;
					while(isalnum(*next) || ('_' == *next)){
						next++ ;
					}
					if(isspace(*next)){
						char *end=next-1 ;
						next=skipSpaces(next);
						if(isxdigit(*next)){
							char *addrEnd ;
							unsigned long addr = strtoul(next,&addrEnd,16);
							if('\0'==*addrEnd){
								unsigned namelen = end-start ;
								char *name = (char *)malloc(namelen+1);
								memcpy(name,start,namelen);
								name[namelen] = '\0' ;
                                                                struct reglist_t *newone = new reglist_t ;
								newone->address=addr ;
								newone->reg = new registerDescription_t ;
								newone->reg->name = name ;
								newone->reg->fields = newone->fields = 0 ;
								if(tail){
									tail->next = newone ;
								} else
									head = newone ;
								tail = newone ;
								continue;
							}
						}
					}
					fprintf(stderr, "%s: syntax error on line %u\n", devregsPath, lineNum );
				} else if(tail){
				}
			}
			fclose(fDefs);
			regs = head ;
		}
		else
			perror(devregsPath);
	}
	return regs ;
}
开发者ID:boundarydevices,项目名称:bdScript,代码行数:58,代码来源:devregs.cpp


示例10: while

static wchar_t *parseItem (TCollection *dc, wchar_t * &line, wchar_t *kwd, wchar_t *value)
{
	if (IsCharAlpha (*skipSpaces (line)))
	{
		wchar_t	*k = kwd;
		while (*line && IsCharAlpha (*line)) *k++ = *line++;
		*k = *value = 0;
		if (*skipSpaces (line) == L'=')
		{
			line++;
			if (!dc)
			{
				getWord (line, value);
			}
			else
			{
				wchar_t	buf[MAX_STR_LEN], *pv = value;
				getWord (line, buf);
				for (wchar_t *pch = buf; *pch;)
				{
					if (L'&' != *pch)
					{
						*pv++ = *pch++;
					}
					else
					{
						++pch;						//skip '&'
						wchar_t	name[MAX_STR_LEN], *pname = name;
						while (*pch && *pch != L';') *pname++ = *pch++;
						*pname = 0;

						//if (!*pch) complain about entity reference syntax;
						if (*pch) ++pch;	//skip
															///';
															///'
						for (size_t i = 0; i < dc->getCount (); ++i)
						{
							TDefine *d = (TDefine *) ((*dc)[i]);
							if (0 == wcscmp (d->name, name))
							{
								for (const wchar_t *pdv = d->value; *pdv;) *pv++ = *pdv++;
								break;
							}
						}

						//if (i == dc->getCount()) complain about undefined entity;
					}
				}

				*pv = 0;
			}
		}

		return (line);
	}

	return (NULL);
}
开发者ID:Kildor,项目名称:TrueTemplate,代码行数:58,代码来源:parse.cpp


示例11: switch

KviKvsTreeNodeExpression * KviKvsParser::parseExpressionOperand(char terminator)
{
	switch(KVSP_curCharUnicode)
	{
		case 0:
		case '\r':
		case '\n':
			error(KVSP_curCharPointer, __tr2qs_ctx("Unexpected end of script in expression", "kvs"));
			return nullptr;
			break;
		case '(':
			KVSP_skipChar;
			skipSpaces();
			return parseExpression(')'); // sub expression
			break;
		case '-':
		{
			KVSP_skipChar;
			skipSpaces();
			KviKvsTreeNodeExpression * d = parseExpressionOperand(terminator);
			if(!d)
				return nullptr;
			return new KviKvsTreeNodeExpressionUnaryOperatorNegate(d->location(), d);
		}
		break;
		case '!':
		{
			KVSP_skipChar;
			skipSpaces();
			KviKvsTreeNodeExpression * d = parseExpressionOperand(terminator);
			if(!d)
				return nullptr;
			return new KviKvsTreeNodeExpressionUnaryOperatorLogicalNot(d->location(), d);
		}
		break;
		case '~':
		{
			KVSP_skipChar;
			skipSpaces();
			KviKvsTreeNodeExpression * d = parseExpressionOperand(terminator);
			if(!d)
				return nullptr;
			return new KviKvsTreeNodeExpressionUnaryOperatorBitwiseNot(d->location(), d);
		}
		break;
		default:
			// anything else at this point is an operand core
			return parseExpressionOperandCore(terminator);
			break;
	}

	// not reached
	KVSP_ASSERT(false);
	return nullptr;
}
开发者ID:CardinalSins,项目名称:KVIrc,代码行数:55,代码来源:KviKvsParser_expression.cpp


示例12: parseContentType

bool parseContentType(const String& contentType, ReceiverType& receiver)
{
    unsigned index = 0;
    unsigned contentTypeLength = contentType.length();
    skipSpaces(contentType, index);
    if (index >= contentTypeLength)  {
        WTF_LOG_ERROR("Invalid Content-Type string '%s'", contentType.ascii().data());
        return false;
    }

    // There should not be any quoted strings until we reach the parameters.
    size_t semiColonIndex = contentType.find(';', index);
    if (semiColonIndex == kNotFound) {
        receiver.setContentType(SubstringRange(index, contentTypeLength - index));
        return true;
    }

    receiver.setContentType(SubstringRange(index, semiColonIndex - index));
    index = semiColonIndex + 1;
    while (true) {
        skipSpaces(contentType, index);
        SubstringRange keyRange = parseParameterPart(contentType, index);
        if (!keyRange.second || index >= contentTypeLength) {
            WTF_LOG_ERROR("Invalid Content-Type parameter name. (at %i)", index);
            return false;
        }

        // Should we tolerate spaces here?
        if (contentType[index++] != '=' || index >= contentTypeLength) {
            WTF_LOG_ERROR("Invalid Content-Type malformed parameter (at %i).", index);
            return false;
        }

        // Should we tolerate spaces here?
        SubstringRange valueRange = parseParameterPart(contentType, index);

        if (!valueRange.second) {
            WTF_LOG_ERROR("Invalid Content-Type, invalid parameter value (at %i, for '%s').", index, substringForRange(contentType, keyRange).stripWhiteSpace().ascii().data());
            return false;
        }

        // Should we tolerate spaces here?
        if (index < contentTypeLength && contentType[index++] != ';') {
            WTF_LOG_ERROR("Invalid Content-Type, invalid character at the end of key/value parameter (at %i).", index);
            return false;
        }

        receiver.setContentTypeParameter(keyRange, valueRange);

        if (index >= contentTypeLength)
            return true;
    }

    return true;
}
开发者ID:Jamesducque,项目名称:mojo,代码行数:55,代码来源:ParsedContentType.cpp


示例13: while

// parse EPD from buffer
// note that this is not a real EPD parser, just a simplified one!
bool EPDFile::parse( const char *ptr )
{
	cheng4::Board b;
	while (ptr && *ptr)
	{
		skipSpaces( ptr );
		const char *res = b.fromFEN( ptr );
		if ( !res )
		{
			skipUntilEOL(ptr);
			continue;
		}
		EPDPosition pos;
		pos.fen = b.toFEN();
		ptr = res;
		for (;;)
		{
			skipSpaces( ptr );
			if ( isToken( ptr, "bm" ) )
			{
				// parse best moves
				for (;;)
				{
					skipSpaces(ptr);
					Move m = b.fromSAN(ptr);
					if ( m == mcNone )
						break;
					pos.best.push_back(m);
				}
				continue;
			}
			if ( isToken( ptr, "am" ) )
			{
				// parse avoid moves
				for (;;)
				{
					skipSpaces(ptr);
					Move m = b.fromSAN(ptr);
					if ( m == mcNone )
						break;
					pos.avoid.push_back(m);
				}
				continue;
			}
			if ( *ptr == 13 || *ptr == 10 || *ptr == ';')
			{
				skipUntilEOL( ptr );
				break;
			}
		}
		positions.push_back( pos );
	}
	return 1;
}
开发者ID:kmar,项目名称:cheng4,代码行数:56,代码来源:epd.cpp


示例14: read_lvl

 parse_result read_lvl(string input, int from, int lvl) {
     from = skipSpaces(input,from);
     if (from >= (int)input.length()) {
         throw "End of input reached before the parsing finished";
     }
     if (lvl <= 0) { // parens or variable
         if (input[from] == '(') {
             parse_result pr = read_lvl(input,from+1,START_LVL);
             pr.idx = skipSpaces(input, pr.idx);
             if (pr.idx >= (int)input.length()) {
                 throw "End of input reached before the parsing finished";
             } else if (input[pr.idx] != ')') {
                 throw "'(' at character "+pr.idx;
             }
             pr.idx = pr.idx+1;
             return pr;
         } else {
             return read_var(input, from);
         }
     } else {
         operateur op = operateur_for_level(lvl);
         string s_op = operateur2string(op);
         if (is_binary(op)) {
             parse_result pr1 = read_lvl(input,from,lvl-1);
             pr1.idx = skipSpaces(input,pr1.idx);
             if ( input.compare(pr1.idx, s_op.length(), s_op) == 0 ) {
                 parse_result pr2 = read_lvl(input,pr1.idx+(int)s_op.length(), lvl);
                 parse_result res;
                 res.f = new formule();
                 res.f -> op = op;
                 res.f -> arg1 = pr1.f;
                 res.f -> arg2 = pr2.f;
                 res.idx = pr2.idx;
                 return res;
             } else {
                 return pr1;
             }
         } else {
             if ( input.compare(from, s_op.length(), s_op) == 0 )  {
                 parse_result pr = read_lvl(input,from + (int)s_op.length(),lvl);
                 parse_result res;
                 res.idx = pr.idx;
                 res.f = new formule();
                 res.f->op = op;
                 res.f->arg = pr.f;
                 return res;
             } else {
                 return read_lvl(input,from,lvl-1);
             }
         }
     }
 }
开发者ID:Fourure,项目名称:SAT,代码行数:52,代码来源:Parsers.cpp


示例15: parseCommandLine

static int parseCommandLine(char *command, char *arguments[], int len) {
  command = skipSpaces(command);
  int count = 0;
  while (count < len - 1 && *command != '\0') {
    arguments[count++] = command;
    char *found = strchr(command, ' ');
    if (found == NULL) break;
    *found = '\0';
    command = found + 1;
    command = skipSpaces(command);
  }
  arguments[count] = NULL;
  return count;
}
开发者ID:kumar-abhishek,项目名称:interview-questions-1,代码行数:14,代码来源:simplesh.c


示例16: matchCommand

bool matchCommand(const char *src, const char *pattern)
{
   const char **par;
   for (par = params; par < params + MAX_PARAMS; par++)
   {
      *par = "";
   }
   for (src = skipSpaces(src); src != NULL && *pattern != '\0'; pattern++)
   {
      src = isupper(*pattern)
               ? matchParam(src, paramByLetter(*pattern), pattern[1] == '\0')
               : matchTerminal(src, *pattern);
   }
   return src != NULL && *skipSpaces(src) == '\0';
}
开发者ID:helderman,项目名称:htpataic,代码行数:15,代码来源:match.c


示例17: countSpaces

Wt::WString TopicWidget::reindent(const Wt::WString& text)
{
  std::vector<std::string> lines;
  std::string s = text.toUTF8();
  boost::split(lines, s, boost::is_any_of("\n"));

  std::string result;
  int indent = -1;
  int newlines = 0;
  for (unsigned i = 0; i < lines.size(); ++i) {
    const std::string& line = lines[i];

    if (line.empty()) {
      ++newlines;
    } else {
      if (indent == -1) {
        indent = countSpaces(line);
      } else {
        for (int j = 0; j < newlines; ++j)
          result += '\n';
      }

      newlines = 0;

      if (!result.empty())
        result += '\n';

      result += skipSpaces(line, indent);
    }
  }
  return Wt::WString::fromUTF8(result);
}
开发者ID:913862627,项目名称:wt,代码行数:32,代码来源:TopicWidget.C


示例18: skipSpaces

// load EPD file
bool EPDFile::load( const char *fnm )
{
	skipSpaces(fnm);
	positions.clear();
	streampos fsz;
	ifstream ifs( fnm, ios::binary );
	if ( !ifs )
		return 0;
	ifs.seekg( 0, ios::end );
	fsz = ifs.tellg();
	ifs.seekg( 0, ios::beg );
	char *buf = new (std::nothrow) char[ (size_t)(fsz+streampos(1)) ];
	if ( !buf )
		return 0;
	ifs.read( buf, fsz );
	if ( !ifs )
	{
		delete[] buf;
		return 0;
	}
	buf[ (size_t)fsz ] = 0;
	bool res = parse( buf );
	delete[] buf;
	return res;
}
开发者ID:kmar,项目名称:cheng4,代码行数:26,代码来源:epd.cpp


示例19: parseSymbol

double Calculator::parseExprMul(std::string_view &ref)
{
	double value = parseSymbol(ref);
	while (true)
	{
		skipSpaces(ref);
		if (!ref.empty() && ref[0] == '*')
		{
			ref.remove_prefix(1);
			value *= parseSymbol(ref);
			m_printStrategy->printMultiplication();
		}
		else if (!ref.empty() && ref[0] == '/')
		{
			ref.remove_prefix(1);
			value /= parseSymbol(ref);
			m_printStrategy->printDivision();
		}
		else
		{
			break;
		}
	}

	return value;
}
开发者ID:alisa-teplouhova,项目名称:Calc,代码行数:26,代码来源:Calculator.cpp


示例20: parseExprMul

double Calculator::parseExprSum(std::string_view &ref)
{
	double value = parseExprMul(ref);
	while (true)
	{
		skipSpaces(ref);
		if (!ref.empty() && ref[0] == '+')
		{
			ref.remove_prefix(1);
			value += parseExprMul(ref);
			m_printStrategy->printAddition();
		}
		else if (!ref.empty() && ref[0] == '-')
		{
			ref.remove_prefix(1);
			value -= parseExprMul(ref);
			m_printStrategy->printSubstraction();
		}
		else
		{
			break;
		}
	}

	return value;
}
开发者ID:alisa-teplouhova,项目名称:Calc,代码行数:26,代码来源:Calculator.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ skipWhite函数代码示例发布时间:2022-05-30
下一篇:
C++ skipSpace函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap