diff options
-rw-r--r-- | src/messageparser.h | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/src/messageparser.h b/src/messageparser.h index 1559e86..b071dd8 100644 --- a/src/messageparser.h +++ b/src/messageparser.h @@ -1,7 +1,7 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set et sw=2 ts=2: */ /*************************************************************************** - * msgparser.h + * messageparser.h * * Fri Feb 24 14:59:34 CET 2012 * Copyright 2012 Jonas Suhr Christensen @@ -25,58 +25,77 @@ * along with Munia; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef __MUNIA_MSGPARSER_H__ -#define __MUNIA_MSGPARSER_H__ +#ifndef __MUNIA_MESSAGEPARSER_H__ +#define __MUNIA_MESSAGEPARSER_H__ #include <list> #include <string> +#include "task.h" + namespace cmd { - enum cmd_t { + typedef enum { + observe, + unobserve, update, move, add, del, error - }; + } cmd_t; }; typedef struct { - int id; - int parentid; + taskid_t id; +} observe_t; + +typedef struct { + taskid_t id; +} unobserve_t; + +typedef struct { + taskid_t id; + taskid_t parent_id; char title[256]; char desc[256]; } add_t; + typedef struct { - int id; + taskid_t id; } del_t; + typedef struct { - int id; - int parentid; + taskid_t id; + taskid_t parent_id; } move_t; + typedef struct { - int id; + taskid_t id; char title[256]; char desc[256]; } update_t; -typedef struct msg_t { +typedef struct { cmd::cmd_t cmd; union { + observe_t observe; + unobserve_t unobserve; add_t add; del_t del; move_t move; update_t update; }; -} msg_types; +} message_t; + + +typedef std::list<message_t> MessageList; -typedef std::list<msg_t> MsgList; +MessageList parse_msg(std::string msg); -MsgList parse_msg(std::string msg); +message_t create_msg(cmd::cmd_t type, task_t task); +std::string msg_tostring(message_t msg); -//msg_t create_msg(cmd::cmd_t msg_type, task_t task); -std::string msg_tostring(msg_t msg); -#endif/*__MUNIA_MSGPARSER_H__*/ +#endif/*__MUNIA_MESSAGEPARSER_H__*/ |