本文整理汇总了C++中skipSpaces函数的典型用法代码示例。如果您正苦于以下问题:C++ skipSpaces函数的具体用法?C++ skipSpaces怎么用?C++ skipSpaces使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了skipSpaces函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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();
}
}
}
示例3: skipNonData
// Skips over intervening non-data elements in a netpbm file
static
void skipNonData(FILE *src)
{
skipSpaces(src);
skipComments(src);
skipSpaces(src);
}
示例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);
}
}
示例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();
}
示例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");
}
示例7: pgm_read_word
static const char PROGMEM *jsonParseArray(char **buffer, const t_json *currentStructure) {
char *buf = *buffer;
jsonHandleEndArray endFunc = (jsonHandleEndArray) pgm_read_word(¤tStructure->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;
}
示例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;
}
示例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 ;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
示例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;
}