本文整理汇总了C++中skipWhiteSpace函数的典型用法代码示例。如果您正苦于以下问题:C++ skipWhiteSpace函数的具体用法?C++ skipWhiteSpace怎么用?C++ skipWhiteSpace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了skipWhiteSpace函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: poco_assert_dbg
Var Var::parseObject(const std::string& val, std::string::size_type& pos)
{
poco_assert_dbg (val[pos] == '{');
++pos;
skipWhiteSpace(val, pos);
DynamicStruct aStruct;
while (val[pos] != '}' && pos < val.size())
{
std::string key = parseString(val, pos);
skipWhiteSpace(val, pos);
if (val[pos] != ':')
throw DataFormatException("Incorrect object, must contain: key : value pairs");
++pos; // skip past :
Var value = parse(val, pos);
aStruct.insert(key, value);
skipWhiteSpace(val, pos);
if (val[pos] == ',')
{
++pos;
skipWhiteSpace(val, pos);
}
}
if (val[pos] != '}')
throw DataFormatException("Unterminated object");
++pos;
return aStruct;
}
开发者ID:Chingliu,项目名称:poco,代码行数:27,代码来源:Var.cpp
示例2: skipOpen
/**
* Skips the opening "{" or "{#" depending upon the ending flag
* @param str Pointer to a string structure
* @param ending Flag indicating if it is an ending structure to expect a '#'
* @return Returns 0 on failure, 1 on success
**/
int skipOpen( pstring str, int ending )
{
if (str == NULL ) {
return 0;
}
skipWhiteSpace(str);
if ( !atChar( str, '{' ) ) {
return 0;
}
/// Skip the opening brace
if ( incChar(str) == -1 ) {
return 0;
}
/// Skip to the element id value or '#' if it is an end
skipWhiteSpace(str);
if ( ending ) {
if (!atChar( str, '#') ) {
return 0;
}
if ( incChar( str ) == -1 ) {
return 0;
}
}
return 1;
}
开发者ID:trailofbits,项目名称:cb-multios,代码行数:37,代码来源:cityParsers.c
示例3: skipWhiteSpace
WebVTTParser::ParseState WebVTTParser::collectTimingsAndSettings(const String& line)
{
// 4.8.10.13.3 Collect WebVTT cue timings and settings.
// 1-3 - Let input be the string being parsed and position be a pointer into input
unsigned position = 0;
skipWhiteSpace(line, &position);
// 4-5 - Collect a WebVTT timestamp. If that fails, then abort and return failure. Otherwise, let cue's text track cue start time be the collected time.
m_currentStartTime = collectTimeStamp(line, &position);
if (m_currentStartTime == malformedTime)
return BadCue;
if (position >= line.length())
return BadCue;
skipWhiteSpace(line, &position);
// 6-9 - If the next three characters are not "-->", abort and return failure.
if (line.find("-->", position) == kNotFound)
return BadCue;
position += 3;
if (position >= line.length())
return BadCue;
skipWhiteSpace(line, &position);
// 10-11 - Collect a WebVTT timestamp. If that fails, then abort and return failure. Otherwise, let cue's text track cue end time be the collected time.
m_currentEndTime = collectTimeStamp(line, &position);
if (m_currentEndTime == malformedTime)
return BadCue;
skipWhiteSpace(line, &position);
// 12 - Parse the WebVTT settings for the cue (conducted in TextTrackCue).
m_currentSettings = line.substring(position, line.length()-1);
return CueText;
}
开发者ID:halton,项目名称:blink-crosswalk,代码行数:35,代码来源:WebVTTParser.cpp
示例4: skipWhiteSpace
SingleClauseArgs::SingleClauseArgs(std::string setClause, std::string argsStr) {
clause = setClause;
int index = skipWhiteSpace(argsStr, 0);
if (clause == "if") { // Single argument always
args.push_back(argsStr);
} else {
while (index < argsStr.size()) {
int start = index;
int end = seekPastToken(argsStr, index);
std::string token = argsStr.substr(start, end - start);
args.push_back(token);
const int delimiterIndex = skipWhiteSpace(argsStr, end);
if (!(delimiterIndex == argsStr.size() ||
argsStr.at(delimiterIndex) == ',' ||
argsStr.at(delimiterIndex) == ':')) {
std::cerr << "Unexpected delimiter '" <<
argsStr.at(delimiterIndex) << "' in args '" << argsStr << "'" <<
std::endl;
exit(1);
}
index = skipWhiteSpace(argsStr, delimiterIndex + 1);
}
}
}
开发者ID:agrippa,项目名称:omp-to-x,代码行数:27,代码来源:SingleClauseArgs.cpp
示例5: parseHTTPRefresh
bool parseHTTPRefresh(const String& refresh, bool fromHttpEquivMeta, double& delay, String& url)
{
unsigned len = refresh.length();
unsigned pos = 0;
if (!skipWhiteSpace(refresh, pos, fromHttpEquivMeta))
return false;
while (pos != len && refresh[pos] != ',' && refresh[pos] != ';')
++pos;
if (pos == len) { // no URL
url = String();
bool ok;
delay = refresh.stripWhiteSpace().toDouble(&ok);
return ok;
} else {
bool ok;
delay = refresh.left(pos).stripWhiteSpace().toDouble(&ok);
if (!ok)
return false;
++pos;
skipWhiteSpace(refresh, pos, fromHttpEquivMeta);
unsigned urlStartPos = pos;
if (refresh.find("url", urlStartPos, false) == urlStartPos) {
urlStartPos += 3;
skipWhiteSpace(refresh, urlStartPos, fromHttpEquivMeta);
if (refresh[urlStartPos] == '=') {
++urlStartPos;
skipWhiteSpace(refresh, urlStartPos, fromHttpEquivMeta);
} else
urlStartPos = pos; // e.g. "Refresh: 0; url.html"
}
unsigned urlEndPos = len;
if (refresh[urlStartPos] == '"' || refresh[urlStartPos] == '\'') {
UChar quotationMark = refresh[urlStartPos];
urlStartPos++;
while (urlEndPos > urlStartPos) {
urlEndPos--;
if (refresh[urlEndPos] == quotationMark)
break;
}
// https://bugs.webkit.org/show_bug.cgi?id=27868
// Sometimes there is no closing quote for the end of the URL even though there was an opening quote.
// If we looped over the entire alleged URL string back to the opening quote, just go ahead and use everything
// after the opening quote instead.
if (urlEndPos == urlStartPos)
urlEndPos = len;
}
url = refresh.substring(urlStartPos, urlEndPos - urlStartPos).stripWhiteSpace();
return true;
}
}
开发者ID:Channely,项目名称:know-your-chrome,代码行数:58,代码来源:HTTPParsers.cpp
示例6: loadSettingsFile
void loadSettingsFile (const std::string& file, CategorySettingValueMap& settings)
{
mFile = file;
boost::filesystem::ifstream stream;
stream.open(boost::filesystem::path(file));
std::cout << "Loading settings file: " << file << std::endl;
std::string currentCategory;
mLine = 0;
while (!stream.eof() && !stream.fail())
{
++mLine;
std::string line;
std::getline( stream, line );
size_t i = 0;
if (!skipWhiteSpace(i, line))
continue;
if (line[i] == '#') // skip comment
continue;
if (line[i] == '[')
{
size_t end = line.find(']', i);
if (end == std::string::npos)
fail("unterminated category");
currentCategory = line.substr(i+1, end - (i+1));
boost::algorithm::trim(currentCategory);
i = end+1;
}
if (!skipWhiteSpace(i, line))
continue;
if (currentCategory.empty())
fail("empty category name");
size_t settingEnd = line.find('=', i);
if (settingEnd == std::string::npos)
fail("unterminated setting name");
std::string setting = line.substr(i, (settingEnd-i));
boost::algorithm::trim(setting);
size_t valueBegin = settingEnd+1;
std::string value = line.substr(valueBegin);
boost::algorithm::trim(value);
if (settings.insert(std::make_pair(std::make_pair(currentCategory, setting), value)).second == false)
fail(std::string("duplicate setting: [" + currentCategory + "] " + setting));
}
}
开发者ID:trymnilsen,项目名称:openmw,代码行数:53,代码来源:settings.cpp
示例7: parseHTTPRefresh
bool parseHTTPRefresh(const String& refresh, bool fromHttpEquivMeta, double& delay, String& url)
{
int len = refresh.length();
int pos = 0;
if (!skipWhiteSpace(refresh, pos, fromHttpEquivMeta))
return false;
while (pos != len && refresh[pos] != ',' && refresh[pos] != ';')
++pos;
if (pos == len) { // no URL
url = String();
bool ok;
delay = refresh.stripWhiteSpace().toDouble(&ok);
return ok;
} else {
bool ok;
delay = refresh.left(pos).stripWhiteSpace().toDouble(&ok);
if (!ok)
return false;
++pos;
skipWhiteSpace(refresh, pos, fromHttpEquivMeta);
int urlStartPos = pos;
if (refresh.find("url", urlStartPos, false) == urlStartPos) {
urlStartPos += 3;
skipWhiteSpace(refresh, urlStartPos, fromHttpEquivMeta);
if (refresh[urlStartPos] == '=') {
++urlStartPos;
skipWhiteSpace(refresh, urlStartPos, fromHttpEquivMeta);
} else
urlStartPos = pos; // e.g. "Refresh: 0; url.html"
}
int urlEndPos = len;
if (refresh[urlStartPos] == '"' || refresh[urlStartPos] == '\'') {
UChar quotationMark = refresh[urlStartPos];
urlStartPos++;
while (urlEndPos > urlStartPos) {
urlEndPos--;
if (refresh[urlEndPos] == quotationMark)
break;
}
}
url = refresh.substring(urlStartPos, urlEndPos - urlStartPos).stripWhiteSpace();
return true;
}
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:51,代码来源:HTTPParsers.cpp
示例8: doSyslogName
/* parse a syslog name from the string. This is the generic code that is
* called by the facility/severity functions. Note that we do not check the
* validity of numerical values, something that should probably change over
* time (TODO). -- rgerhards, 2008-02-14
*/
static rsRetVal
doSyslogName(uchar **pp, rsRetVal (*pSetHdlr)(void*, int),
void *pVal, syslogName_t *pNameTable)
{
DEFiRet;
cstr_t *pStrB;
int iNewVal;
ASSERT(pp != NULL);
ASSERT(*pp != NULL);
CHKiRet(getWord(pp, &pStrB)); /* get word */
iNewVal = decodeSyslogName(cstrGetSzStr(pStrB), pNameTable);
if(pSetHdlr == NULL) {
/* we should set value directly to var */
*((int*)pVal) = iNewVal; /* set new one */
} else {
/* we set value via a set function */
CHKiRet(pSetHdlr(pVal, iNewVal));
}
skipWhiteSpace(pp); /* skip over any whitespace */
finalize_it:
if(pStrB != NULL)
rsCStrDestruct(&pStrB);
RETiRet;
}
开发者ID:Werkov,项目名称:rsyslog,代码行数:35,代码来源:cfsysline.c
示例9: getToken
UCHAR
getToken(
unsigned n, // size of s[]
UCHAR expected // STRING means get line
) // w/o checking for #;:=
{
char *s;
char *end;
int c;
s = buf;
end = buf + n;
if (firstToken) { // global var
++line;
firstToken = FALSE; // parser needs to see some kind of
c = lgetc(); // newline to initialize it
if ((colZero = (BOOL) !WHITESPACE(c))) {
if (c == EOF)
return(determineTokenFor(c,s,end));
else
UngetTxtChr(c,file);
return(NEWLINE);
}
return(NEWLINESPACE);
}
if (expected == STRING || expected == VALUE) { // get everything up to \n
getString(expected,s,end);
return(expected);
} // were/are we
c = skipWhiteSpace(FROMLOCAL); // past col 0?
*s++ = (char) c; // save the letter
*s = '\0'; // terminate s
return(determineTokenFor(c,s,end));
}
开发者ID:fstudio,项目名称:nmake,代码行数:35,代码来源:lexer.cpp
示例10: doGetChar
/* parse a character from the config line
* added 2007-07-17 by rgerhards
* TODO: enhance this function to handle different classes of characters
* HINT: check if char is ' and, if so, use 'c' where c may also be things
* like \t etc.
*/
static rsRetVal doGetChar(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal)
{
DEFiRet;
assert(pp != NULL);
assert(*pp != NULL);
skipWhiteSpace(pp); /* skip over any whitespace */
/* if we are not at a '\0', we have our new char - no validity checks here... */
if(**pp == '\0') {
errmsg.LogError(0, RS_RET_NOT_FOUND, "No character available");
iRet = RS_RET_NOT_FOUND;
} else {
if(pSetHdlr == NULL) {
/* we should set value directly to var */
*((uchar*)pVal) = **pp;
} else {
/* we set value via a set function */
CHKiRet(pSetHdlr(pVal, **pp));
}
++(*pp); /* eat processed char */
}
finalize_it:
RETiRet;
}
开发者ID:Werkov,项目名称:rsyslog,代码行数:33,代码来源:cfsysline.c
示例11: skipWhiteSpace
int* ITFReader::decodeEnd(Ref<BitArray> row) {
// For convenience, reverse the row and then
// search from 'the start' for the end block
row->reverse();
int* endPattern = 0;
try {
int endStart = skipWhiteSpace(row);
endPattern = findGuardPattern(row, endStart, END_PATTERN_REVERSED, END_PATTERN_REVERSED_LEN);
// The start & end patterns must be pre/post fixed by a quiet zone. This
// zone must be at least 10 times the width of a narrow line.
// ref: http://www.barcode-1.net/i25code.html
validateQuietZone(row, endPattern[0]);
// Now recalculate the indices of where the 'endblock' starts & stops to
// accommodate
// the reversed nature of the search
int temp = endPattern[0];
endPattern[0] = (int)(row->getSize() - endPattern[1]);
endPattern[1] = (int)(row->getSize() - temp);
row->reverse();
return endPattern;
} catch (ReaderException const& re) {
delete [] endPattern;
row->reverse();
throw re;
}
}
开发者ID:jijixi,项目名称:dynamicapp,代码行数:29,代码来源:ITFReader.cpp
示例12: skipWhiteSpace
void THtmlParser::parseCloseTag()
{
++pos;
skipWhiteSpace();
QString tag = parseWord();
skipUpTo(">");
// Finds corresponding open element
int i = lastIndex();
while (i > 0) {
if (!tag.isEmpty() && at(i).tag.toLower() == tag.toLower() && !isElementClosed(i)) {
break;
}
i = at(i).parent;
}
if (i > 0) {
at(i).tagClosed = true;
} else {
// Can't find a corresponding open element
last().text += QLatin1String("</");
last().text += tag;
last().text += QLatin1Char('>');
return;
}
// Append a empty element for next entry
int p = at(i).parent;
appendNewElement(p);
}
开发者ID:deniskin82,项目名称:treefrog-framework,代码行数:30,代码来源:thtmlparser.cpp
示例13: doParseOnOffOption
/* Parse and interpret an on/off inside a config file line. This is most
* often used for boolean options, but of course it may also be used
* for other things. The passed-in pointer is updated to point to
* the first unparsed character on exit. Function emits error messages
* if the value is neither on or off. It returns 0 if the option is off,
* 1 if it is on and another value if there was an error.
* rgerhards, 2007-07-15
*/
static int doParseOnOffOption(uchar **pp)
{
uchar *pOptStart;
uchar szOpt[32];
assert(pp != NULL);
assert(*pp != NULL);
pOptStart = *pp;
skipWhiteSpace(pp); /* skip over any whitespace */
if(getSubString(pp, (char*) szOpt, sizeof(szOpt), ' ') != 0) {
errmsg.LogError(0, NO_ERRCODE, "Invalid $-configline - could not extract on/off option");
return -1;
}
if(!strcmp((char*)szOpt, "on")) {
return 1;
} else if(!strcmp((char*)szOpt, "off")) {
return 0;
} else {
errmsg.LogError(0, NO_ERRCODE, "Option value must be on or off, but is '%s'", (char*)pOptStart);
return -1;
}
}
开发者ID:Werkov,项目名称:rsyslog,代码行数:33,代码来源:cfsysline.c
示例14: readValue
/*
* returns string containing the value; 0 when out of memory; empty string when no value found
* allocates memory for value on heap
*/
static char* readValue(char* line)
{
char* temp;
char* value = NULL;
temp = line;
/* move after option name (next whitespace) */
for(; *temp!='\0' && *temp!='\n' && *temp!='\r' && *temp!=' ' && *temp!='\t'; temp++)
;
temp = skipWhiteSpace(temp);
stripSpaceAtEnd(temp);
if(*temp)
{
value = malloc(strlen(temp) + 1);
if(!value) /* out of memory */
return NULL;
strcpy(value, temp);
return value;
}
else
{
value = calloc(1, sizeof(char));
if(!value) /* out of memory */
return NULL;
return value;
}
}
开发者ID:acplt,项目名称:rte,代码行数:32,代码来源:ov_options.c
示例15: getWord
/* parse a whitespace-delimited word from the provided string. This is a
* helper function for a number of syntaxes. The parsed value is returned
* in ppStrB (which must be provided by caller).
* rgerhards, 2008-02-14
*/
static rsRetVal
getWord(uchar **pp, cstr_t **ppStrB)
{
DEFiRet;
uchar *p;
ASSERT(pp != NULL);
ASSERT(*pp != NULL);
ASSERT(ppStrB != NULL);
CHKiRet(cstrConstruct(ppStrB));
skipWhiteSpace(pp); /* skip over any whitespace */
/* parse out the word */
p = *pp;
while(*p && !isspace((int) *p)) {
CHKiRet(cstrAppendChar(*ppStrB, *p++));
}
CHKiRet(cstrFinalize(*ppStrB));
*pp = p;
finalize_it:
RETiRet;
}
开发者ID:Werkov,项目名称:rsyslog,代码行数:32,代码来源:cfsysline.c
示例16: facilityHdlr
/* ugly workaround to handle facility numbers; values
* derived from names need to be eight times smaller,
* i.e.: 0..23
*/
static rsRetVal facilityHdlr(uchar **pp, void *pVal)
{
DEFiRet;
char *p;
skipWhiteSpace(pp);
p = (char *) *pp;
if (isdigit((int) *p)) {
*((int *) pVal) = (int) strtol(p, (char **) pp, 10);
} else {
int len;
syslogName_t *c;
for (len = 0; p[len] && !isspace((int) p[len]); len++)
/* noop */;
for (c = syslogFacNames; c->c_name; c++) {
if (!strncasecmp(p, (char *) c->c_name, len)) {
*((int *) pVal) = LOG_FAC(c->c_val);
break;
}
}
*pp += len;
}
RETiRet;
}
开发者ID:Altiscale,项目名称:rsyslog,代码行数:31,代码来源:imjournal.c
示例17: doGetWord
/* Parse and a word config line option. A word is a consequtive
* sequence of non-whitespace characters. pVal must be
* a pointer to a string which is to receive the option
* value. The returned string must be freed by the caller.
* rgerhards, 2007-09-07
* To facilitate multiple instances of the same command line
* directive, doGetWord() now checks if pVal is already a
* non-NULL pointer. If so, we assume it was created by a previous
* incarnation and is automatically freed. This happens only when
* no custom handler is defined. If it is, the customer handler
* must do the cleanup. I have checked and this was al also memory
* leak with some code. Obviously, not a large one. -- rgerhards, 2007-12-20
* Just to clarify: if pVal is parsed to a custom handler, this handler
* is responsible for freeing pVal. -- rgerhards, 2008-03-20
*/
static rsRetVal doGetWord(uchar **pp, rsRetVal (*pSetHdlr)(void*, uchar*), void *pVal)
{
DEFiRet;
cstr_t *pStrB = NULL;
uchar *pNewVal;
ASSERT(pp != NULL);
ASSERT(*pp != NULL);
CHKiRet(getWord(pp, &pStrB));
CHKiRet(cstrConvSzStrAndDestruct(&pStrB, &pNewVal, 0));
DBGPRINTF("doGetWord: get newval '%s' (len %d), hdlr %p\n",
pNewVal, (int) ustrlen(pNewVal), pSetHdlr);
/* we got the word, now set it */
if(pSetHdlr == NULL) {
/* we should set value directly to var */
if(*((uchar**)pVal) != NULL)
free(*((uchar**)pVal)); /* free previous entry */
*((uchar**)pVal) = pNewVal; /* set new one */
} else {
/* we set value via a set function */
CHKiRet(pSetHdlr(pVal, pNewVal));
}
skipWhiteSpace(pp); /* skip over any whitespace */
finalize_it:
if(iRet != RS_RET_OK) {
if(pStrB != NULL)
cstrDestruct(&pStrB);
}
RETiRet;
}
开发者ID:Werkov,项目名称:rsyslog,代码行数:50,代码来源:cfsysline.c
示例18: skipWhiteSpace
/**
* If the first none space character is a quotation mark, returns the string
* between two quotation marks, else returns the content before the first comma.
* Updates *p_cur.
*/
static char *nextTok(char **p_cur)
{
char *ret = NULL;
skipWhiteSpace(p_cur);
if (*p_cur == NULL) {
ret = NULL;
} else if (**p_cur == '"') {
enum State {END, NORMAL, ESCAPE} state = NORMAL;
(*p_cur)++;
ret = *p_cur;
while (state != END) {
switch (state) {
case NORMAL:
switch (**p_cur) {
case '\\':
state = ESCAPE;
break;
case '"':
state = END;
break;
case '\0':
/*
* Error case, parsing string is not quoted by ending
* double quote, e.g. "bla bla, this function expects input
* string to be NULL terminated, so that the loop can exit.
*/
ret = NULL;
goto exit;
default:
/* Stays in normal case. */
break;
}
break;
case ESCAPE:
state = NORMAL;
break;
default:
/* This should never happen. */
break;
}
if (state == END) {
**p_cur = '\0';
}
(*p_cur)++;
}
skipNextComma(p_cur);
} else {
ret = strsep(p_cur, ",");
}
exit:
return ret;
}
开发者ID:Adamj311,项目名称:android_device_malata_smba_common,代码行数:65,代码来源:at_tok.c
示例19: isComment
static int isComment(const char* line)
{
line = skipWhiteSpace(line);
if(*line == '#')
return 1;
else
return 0;
}
开发者ID:acplt,项目名称:rte,代码行数:8,代码来源:ov_options.c
示例20: parseNumber
void parseNumber() {
skipWhiteSpace();
while (!eof() && !isWhiteSpace() &&
(isSign() || isDot() || isDigit())) {
put();
next();
}
}
开发者ID:Guard96,项目名称:2014,代码行数:8,代码来源:lab02.cpp
注:本文中的skipWhiteSpace函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论