From f92e4e750fd09a40bfbe0d819a68be4eed4f6daa Mon Sep 17 00:00:00 2001 From: Marenz Date: Sun, 15 May 2011 20:36:16 +0200 Subject: [PATCH] added function setParseFlags --- d/include/psyc/parse.d | 21 +++++++++++++++++++-- include/psyc/parse.h | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/d/include/psyc/parse.d b/d/include/psyc/parse.d index d655da2..5027ce1 100644 --- a/d/include/psyc/parse.d +++ b/d/include/psyc/parse.d @@ -133,17 +133,34 @@ struct ParseState * Params: * flags = Flags to be set for the parser, see ParseFlag. */ - static ParseState opCall ( ubyte flags ) + static ParseState opCall ( ParseFlag flags ) { ParseState inst; inst.flags = flags; - if (flags & ParseFlag.ROUTING_ONLY) + if (flags & ParseFlag.START_AT_CONTENT) inst.part = Part.CONTENT; return inst; } + /** + * Change parse flags in state + * + * Params: + * state = Pointer to the state struct that should be initialized. + * flags = Flags to be set for the parser, see psycParseFlag. + * + * See_Also: psyc_initParseState psycParseFlag + */ + void setParseFlags (ParseFlag flags) + { + this.flags = flags; + + if (flags & ParseFlag.START_AT_CONTENT) + this.part = Part.CONTENT; + } + /** * Sets a new buffer in the parser state struct with data to be parsed. * diff --git a/include/psyc/parse.h b/include/psyc/parse.h index e1f2495..79687b5 100644 --- a/include/psyc/parse.h +++ b/include/psyc/parse.h @@ -268,6 +268,25 @@ void psyc_initParseState2 (psycParseState *state, uint8_t flags) state->part = PSYC_PART_CONTENT; } +/** + * Change parse flags in state + * + * @param state Pointer to the state struct that should be initialized. + * @param flags Flags to be set for the parser, see psycParseFlag. + * @see psyc_initParseState + * @see psycParseFlag + */ +static inline +void psyc_setParseFlags (psycParseState *state, uint8_t flags) +{ + state->flags = flags; + + if (flags & PSYC_PARSE_START_AT_CONTENT) + state->part = PSYC_PART_CONTENT; +} + + + /** * Sets a new buffer in the parser state struct with data to be parsed. *