本文整理汇总了C++中skipws函数的典型用法代码示例。如果您正苦于以下问题:C++ skipws函数的具体用法?C++ skipws怎么用?C++ skipws使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了skipws函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: die
static struct test *read_tests(void) {
char *fname;
FILE *fp;
char line[BUFSIZ];
struct test *result = NULL, *t = NULL;
int lc = 0;
bool append_cmd = true;
if (asprintf(&fname, "%s/tests/run.tests", abs_top_srcdir) < 0)
die("asprintf fname");
if ((fp = fopen(fname, "r")) == NULL)
die("fopen run.tests");
while (fgets(line, BUFSIZ, fp) != NULL) {
lc += 1;
char *s = skipws(line);
if (*s == '#' || *s == '\0')
continue;
if (*s == ':')
s += 1;
char *eos = s + strlen(s) - 2;
if (eos >= s && *eos == ':') {
*eos++ = '\n';
*eos = '\0';
}
if (looking_at(s, KW_TEST)) {
if (ALLOC(t) < 0)
die_oom();
list_append(result, t);
append_cmd = true;
s = token(s + strlen(KW_TEST), &(t->name));
s = inttok(s, &t->result);
s = errtok(s, &t->errcode);
} else if (looking_at(s, KW_PRINTS)) {
s = skipws(s + strlen(KW_PRINTS));
t->out_present = looking_at(s, KW_SOMETHING);
append_cmd = false;
} else if (looking_at(s, KW_USE)) {
if (t->module !=NULL)
die("Can use at most one module in a test");
s = token(s + strlen(KW_USE), &(t->module));
} else {
char **buf = append_cmd ? &(t->cmd) : &(t->out);
if (*buf == NULL) {
*buf = strdup(s);
if (*buf == NULL)
die_oom();
} else {
if (REALLOC_N(*buf, strlen(*buf) + strlen(s) + 1) < 0)
die_oom();
strcat(*buf, s);
}
}
if (t->out != NULL)
t->out_present = true;
}
return result;
}
示例2: skipws
void netlist_parser::netdev_device(const pstring &dev_type)
{
pstring devname;
netlist_device_t *dev;
int cnt;
skipws();
devname = getname2(',', ')');
dev = m_setup.factory().new_device_by_name(dev_type, m_setup);
m_setup.register_dev(dev, devname);
NL_VERBOSE_OUT(("Parser: IC: %s\n", devname.cstr()));
cnt = 0;
while (getc() != ')')
{
skipws();
pstring output_name = getname2(',', ')');
pstring alias = pstring::sprintf("%s.[%d]", devname.cstr(), cnt);
NL_VERBOSE_OUT(("Parser: ID: %s %s\n", output_name.cstr(), alias.cstr()));
m_setup.register_link(alias, output_name);
skipws();
cnt++;
}
/*
if (cnt != dev->m_terminals.count() && !dev->variable_input_count())
fatalerror("netlist: input count mismatch for %s - expected %d found %d\n", devname.cstr(), dev->m_terminals.count(), cnt);
if (dev->variable_input_count())
{
NL_VERBOSE_OUT(("variable inputs %s: %d\n", dev->name().cstr(), cnt));
}
*/
}
示例3: skipws
TInt DWinsKeyboard::DefineAlias(const char* aValue)
//
// The character string terminates in a ';' or a '\0'
//
{
//get the alias name
const char* beg = skipws(aValue);
const char* end = skiptok(beg);
TPtrC8 alias((const TUint8*)beg, end-beg);
//get the real name
beg = skipws(end);
end = skiptok(beg);
TPtrC8 name((const TUint8*)beg, end-beg);
//prevent an alias being made of an alias
if (iAliasedKeys[name] != NULL)
return KErrArgument;
// ensure this is valid name
TInt r = GetEPOCKeyCode(name);
if (r == KErrNotFound)
return r;
//now we need to record the alias name and the real key name
return iAliasedKeys.Add(alias, name);
}
示例4: skipws
pstring netlist_parser::getstring()
{
skipws();
check_char('"');
pstring ret = getname2_ext('"', 0, NULL);
check_char('"');
skipws();
return ret;
}
示例5: parsepair
static int
parsepair(Parser *p, JSON *parent, JSON **kprev, JSON **vprev)
{
must(*p->s == '"');
must(parsestring(p, parent, kprev));
skipws(p);
must(consume(p, ":"));
skipws(p);
must(parsevalue(p, parent, vprev));
return 1;
}
示例6: get_to_sep
void record_enum::parse(proto_info &, cursor &c) {
pimpl->name = get_to_sep(c, ' ', enum_body_open_char, enum_type_separator);
// if enum has specified underlying type
skipws(c);
if ( curch(c) == enum_type_separator ) {
check_next(c, enum_type_separator);
cursor c1 = c;
const std::string type = get_to_sep(c, ' ', enum_body_open_char);
pimpl->type = type_id_by_name(type);
if ( pimpl->type == type_id::type_unknown )
YARMI_THROW(
"enum underlying type error: '%s' in %s"
,type
,c1.format()
);
}
check_next(c, enum_body_open_char);
for ( ;; ) {
skipws(c);
// if enum don't have any members
char cc = curch(c);
if ( cc == enum_body_close_char ) {
check_next(c, enum_body_close_char);
check_next(c, enum_body_close_dotcomma_char);
return;
}
const std::string n = get_to_sep(c, ',', ' ', enum_assign_char, enum_body_close_char);
skipws(c);
cc = curch(c);
// without init value
if ( cc == ',' ) {
nextch(c);
pimpl->elems.push_back({n, ""});
// with init value
} else if ( cc == enum_assign_char ) {
nextch(c);
const std::string v = get_to_sep(c, ' ', ',', enum_body_close_char);
pimpl->elems.push_back({n, v});
// error
} else {
YARMI_THROW(
"syntax error: '%c' in %s"
,cc
,c.format()
);
}
}
}
示例7: while
void netlist_parser::parse(const char *buf)
{
m_px = buf;
m_line_ptr = buf;
m_line = 1;
while (!eof())
{
pstring n;
skipws();
if (eof()) break;
n = getname('(');
NL_VERBOSE_OUT(("Parser: Device: %s\n", n.cstr()));
if (n == "NET_ALIAS")
net_alias();
else if (n == "NET_C")
net_c();
else if (n == "NETDEV_PARAM")
netdev_param();
else if ((n == "NET_MODEL"))
net_model();
else if (n == "NETLIST_START")
netdev_netlist_start();
else if (n == "NETLIST_END")
netdev_netlist_end();
else
netdev_device(n);
}
}
示例8: join
PROC
join(int count)
{
bool ok;
int lp, first;
if (lend < bufmax) { /* are we in the buffer? */
disp = lend; /* start redraw here */
newc = lend;
do { /* join until.. */
first = lend;
lp = skipws(1+first);
ok = delete_to_undo(&undo, 1+first, lp-(1+first));
if (ok) {
ok = move_to_undo(&undo, first, 1);
core[first] = ' '; /* spaces between lines */
}
count--;
lend = fseekeol(first);
} while (ok && count > 0);
endY = MAGICNUMBER;
newend = lend;
if (!ok)
error();
}
else
error();
}
示例9: scroll
PROC
scroll(bool down)
{
int i;
if (count <= 0)
count = dofscroll;
strput(CURoff);
if (down) {
curr = min(bufmax-1, nextline(TRUE, curr, count));
i = min(bufmax-1, nextline(TRUE, pend, count));
if (i > pend)
scrollforward(i);
}
else {
curr = bseekeol(max(0,nextline(FALSE, curr, count)));
i = bseekeol(max(0,nextline(FALSE, ptop, count)));
if (i < ptop)
if (canUPSCROLL)
scrollback(i);
else {
ptop = i;
setend();
redisplay(TRUE);
}
}
strput(CURon);
setpos(skipws(curr)); /* initialize new position - first nonwhite */
yp = setY(curr);
mvcur(yp, xp); /* go there */
}
示例10: tech_fix
void tech_fix(dbref player, void *data, char *buffer)
{
MECH *mech = data;
int n = atoi(buffer);
int low, high;
int isds;
skipws(buffer);
TECHCOMMANDC;
if (unit_is_fixable(mech))
make_damage_table(mech);
else
make_scrap_table(mech);
DOCHECK(!damage_last &&
MechType(mech) == CLASS_MECH,
"The 'mech is in pristine condition!");
DOCHECK(!damage_last, "It's in pristine condition!");
if (sscanf(buffer, "%d-%d", &low, &high) == 2) {
DOCHECK(low < 1 || low > damage_last, "Invalid low #!");
DOCHECK(high < 1 || high > damage_last, "Invalid high #!");
for (n = low; n <= high; n++)
fix_entry(player, mech, n);
return;
}
DOCHECK(n < 1 || n > damage_last, "Invalid #!");
fix_entry(player, mech, n);
}
示例11: while
void netlist_parser::parse(const char *buf)
{
m_px = buf;
while (!eof())
{
pstring n;
skipws();
if (eof()) break;
n = getname('(');
NL_VERBOSE_OUT(("Parser: Device: %s\n", n.cstr()));
if (n == "NET_ALIAS")
net_alias();
else if (n == "NET_C")
net_c();
else if (n == "NETDEV_PARAM")
netdev_param();
else if (n == "NETDEV_R")
netdev_device(n, "R");
else if (n == "NETDEV_C")
netdev_device(n, "C");
else if (n == "NETDEV_POT")
netdev_device(n, "R");
else if (n == "NETDEV_D")
netdev_device(n, "model", true);
else if ((n == "NETDEV_TTL_CONST") || (n == "NETDEV_ANALOG_CONST"))
netdev_const(n);
else
netdev_device(n);
}
}
示例12: parse_headers
static bool parse_headers(Iterator& it, Request& request)
{
bool res = true;
while (res)
{
std::string key;
std::string value;
res = consumeUntil(it, key, ": \r");
if (key.empty())
{
return res;
}
skipws(it);
res = res && expect(it, ":");
while (match(it, ' '))
{
}
res = res && consumeUntil(it, value, "\r");
if (res)
{
request.headers.emplace_back(std::move(key), std::move(value));
}
res = res && expect(it, HTTP_DELIMITER);
}
return false;
}
示例13: parse_uri
static bool parse_uri(Iterator& it, Request& request)
{
skipws(it);
consumeUntil(it, request.uri, "? ");
if (match(it, '?'))
{
do
{
std::string key;
std::string value;
bool res = consumeUntil(it, key, "&= ");
if (match(it, '=')) {
res = res && consumeUntil(it, value, "& ");
key = UTILS::url_decode(key);
value = UTILS::url_decode(value);
request.query_params.emplace_back(std::move(key), std::move(value));
}
else
{
request.query_params.emplace_back(std::move(key), "");
}
if (!res)
{
return res;
}
} while (match(it, '&'));
}
return it != EOS;
}
示例14: parse_http_version
static bool parse_http_version(Iterator& it, Request& request)
{
skipws(it);
bool res = expect(it, "HTTP/");
std::string major, minor;
res = res && consumeUntil(it, major, ".");
res = res && expect(it, ".");
res = res && consumeUntil(it, minor, "\r");
if (res)
{
try
{
request.major = std::stoi(major);
request.minor = std::stoi(minor);
}
catch (std::exception const& ex)
{
LOG(parser_logger, error) << "Cannot parse Major/Minor: "
<< ex.what();
return false;
}
}
return res;
}
示例15: get_two_ws_separated_fields
/*
* Split a string into 2 whitespace separated fields returned in "key" and
* "value". If more than 2 fields are found, they are cut off by zero
* terminating "key" and "value" inside the string. If "value" is not found,
* *value is set to NULL. If "key" is not found, *key is set to NULL.
* If something is found, both *key and *value become pointers inside the
* string s.
*
* Return values:
* - 0 if neither "key" nor "value" is found
* - 1 if only "key" is found
* - 2 if both "key" and "value" are found
*/
int get_two_ws_separated_fields(char **key, char **value, char *s)
{
int i;
*key = NULL;
*value = NULL;
i = skipws(s, 0); /* Skip initial whitespace */
if (i < 0)
return 0; /* We got nothing */
*key = s + i;
i = skip_and_terminate_word(s, i);
if (i < 0)
return 1; /* We got a "key", but not a "value" */
*value = s + i;
skip_and_terminate_word(s, i);
return 2; /* We got both a "key" and a "value" */
}