本文整理汇总了C++中parser_getstr函数的典型用法代码示例。如果您正苦于以下问题:C++ parser_getstr函数的具体用法?C++ parser_getstr怎么用?C++ parser_getstr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parser_getstr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse_r_s
static enum parser_error parse_r_s(struct parser *p) {
struct monster_race *r = parser_priv(p);
char *flags;
char *s;
int pct;
int ret = PARSE_ERROR_NONE;
if (!r)
return PARSE_ERROR_MISSING_RECORD_HEADER;
flags = string_make(parser_getstr(p, "spells"));
s = strtok(flags, " |");
while (s) {
if (1 == sscanf(s, "1_IN_%d", &pct)) {
if (pct < 1 || pct > 100) {
ret = PARSE_ERROR_INVALID_SPELL_FREQ;
break;
}
r->freq_spell = 100 / pct;
r->freq_innate = r->freq_spell;
} else {
if (grab_flag(r->spell_flags, RSF_SIZE, r_info_spell_flags, s)) {
ret = PARSE_ERROR_INVALID_FLAG;
break;
}
}
s = strtok(NULL, " |");
}
/* Add the "base monster" flags to the monster */
if (r->base)
rsf_union(r->spell_flags, r->base->spell_flags);
mem_free(flags);
return ret;
}
示例2: parse_r_d
static enum parser_error parse_r_d(struct parser *p) {
struct monster_race *r = parser_priv(p);
if (!r)
return PARSE_ERROR_MISSING_RECORD_HEADER;
r->text = string_append(r->text, parser_getstr(p, "desc"));
return PARSE_ERROR_NONE;
}
示例3: parse_vault_type
static enum parser_error parse_vault_type(struct parser *p) {
struct vault *v = parser_priv(p);
if (!v)
return PARSE_ERROR_MISSING_RECORD_HEADER;
v->typ = string_make(parser_getstr(p, "type"));
return PARSE_ERROR_NONE;
}
示例4: parse_rb_n
static enum parser_error parse_rb_n(struct parser *p) {
struct monster_base *h = parser_priv(p);
struct monster_base *rb = mem_zalloc(sizeof *rb);
rb->next = h;
rb->name = string_make(parser_getstr(p, "name"));
parser_setpriv(p, rb);
return PARSE_ERROR_NONE;
}
示例5: parse_v_d
static enum parser_error parse_v_d(struct parser *p) {
struct vault *v = parser_priv(p);
if (!v)
return PARSE_ERROR_MISSING_RECORD_HEADER;
v->text = string_append(v->text, parser_getstr(p, "text"));
return PARSE_ERROR_NONE;
}
示例6: parse_room_d
static enum parser_error parse_room_d(struct parser *p) {
struct room_template *t = parser_priv(p);
if (!t)
return PARSE_ERROR_MISSING_RECORD_HEADER;
t->text = string_append(t->text, parser_getstr(p, "text"));
return PARSE_ERROR_NONE;
}
示例7: helper_str0
static enum parser_error helper_str0(struct parser *p) {
const char *s = parser_getstr(p, "s0");
int *wasok = parser_priv(p);
if (!s || strcmp(s, "foo:bar:baz quxx..."))
return PARSE_ERROR_GENERIC;
*wasok = 1;
return PARSE_ERROR_NONE;
}
示例8: parse_graf_p
static enum parser_error parse_graf_p(struct parser *p) {
graphics_mode *mode = parser_priv(p);
if (!mode) {
return PARSE_ERROR_INVALID_VALUE;
}
strncpy(mode->pref, parser_getstr(p, "prefname"), 32);
return PARSE_ERROR_NONE;
}
示例9: parse_summon_name
static enum parser_error parse_summon_name(struct parser *p) {
struct summon *h = parser_priv(p);
struct summon *s = mem_zalloc(sizeof *s);
s->next = h;
parser_setpriv(p, s);
s->name = string_make(parser_getstr(p, "name"));
return PARSE_ERROR_NONE;
}
示例10: parse_r_n
/* Parsing functions for monster.txt */
static enum parser_error parse_r_n(struct parser *p) {
struct monster_race *h = parser_priv(p);
struct monster_race *r = mem_zalloc(sizeof *r);
r->next = h;
r->ridx = parser_getuint(p, "index");
r->name = string_make(parser_getstr(p, "name"));
parser_setpriv(p, r);
return PARSE_ERROR_NONE;
}
示例11: parse_vault_name
/**
* Parsing functions for vault.txt
*/
static enum parser_error parse_vault_name(struct parser *p) {
struct vault *h = parser_priv(p);
struct vault *v = mem_zalloc(sizeof *v);
v->name = string_make(parser_getstr(p, "name"));
v->next = h;
parser_setpriv(p, v);
return PARSE_ERROR_NONE;
}
示例12: parse_room_name
/**
* Parsing functions for room_template.txt
*/
static enum parser_error parse_room_name(struct parser *p) {
struct room_template *h = parser_priv(p);
struct room_template *t = mem_zalloc(sizeof *t);
t->name = string_make(parser_getstr(p, "name"));
t->next = h;
parser_setpriv(p, t);
return PARSE_ERROR_NONE;
}
示例13: parse_graf_i
static enum parser_error parse_graf_i(struct parser *p) {
graphics_mode *mode = parser_priv(p);
if (!mode) {
return PARSE_ERROR_INVALID_VALUE;
}
mode->cell_width = parser_getuint(p, "wid");
mode->cell_height = parser_getuint(p, "hgt");
strncpy(mode->file, parser_getstr(p, "filename"), 32);
return PARSE_ERROR_NONE;
}
示例14: parse_prefs_y
static enum parser_error parse_prefs_y(struct parser *p)
{
struct prefs_data *d = parser_priv(p);
assert(d != NULL);
if (d->bypass) return PARSE_ERROR_NONE;
option_set(parser_getstr(p, "option"), TRUE);
return PARSE_ERROR_NONE;
}
示例15: parse_prefs_x
static enum parser_error parse_prefs_x(struct parser *p)
{
struct prefs_data *d = parser_priv(p);
assert(d != NULL);
if (d->bypass) return PARSE_ERROR_NONE;
/* XXX check for valid option */
option_set(parser_getstr(p, "option"), FALSE);
return PARSE_ERROR_NONE;
}