From aae3b8bfb83abec0f1bb8e4c854c156c03be5ca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 19 Feb 2019 00:27:43 +0100 Subject: Started full rewrite in C++. --- parse.h | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'parse.h') diff --git a/parse.h b/parse.h index b69bcfa5..6ab98bfd 100644 --- a/parse.h +++ b/parse.h @@ -4,12 +4,17 @@ #include #include +#include +#include + #include "strbuf.h" #include "vcal.h" +#if 0 #define TYPE vcomponent #include "linked_list.h" #undef TYPE +#endif /* * The standard says that no line should be longer than 75 octets. @@ -18,32 +23,32 @@ */ #define SEGSIZE 75 -typedef enum { +enum part_context { p_key, p_value, p_param_name, p_param_value, p_escape -} part_context; +}; /* * Struct holding most state information needed while parsing. * Kept together for simplicity. */ -typedef struct { - char* filename; - LLIST(strbuf) key_stack; - LLIST(vcomponent) comp_stack; +struct parse_ctx { + std::string filename; + std::stack key_stack; + std::stack comp_stack; /* Number for unfolded lines */ - int line; - int column; + int line = 0; + int column = 0; /* Actuall lines and columns from file */ - int pline; - int pcolumn; + int pline = 1; + int pcolumn = 1; strbuf str; -} parse_ctx; -INIT_F(parse_ctx, char* filename); -FREE_F(parse_ctx); + parse_ctx (const std::string& filename) + : filename(filename) { } +}; int handle_kv( content_line* cline, -- cgit v1.2.3