From a79cfb92e093d9c9c78e3ccbabcd45de1a283e56 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Sun, 28 Sep 2014 00:44:36 +0300 Subject: [PATCH] Added "done" signature for parsers. --- .../stargazer/plugins/configuration/sgconfig/parser.cpp | 1 + projects/stargazer/plugins/configuration/sgconfig/parser.h | 6 +++++- .../plugins/configuration/sgconfig/parser_message.cpp | 1 + .../plugins/configuration/sgconfig/parser_users.cpp | 5 +++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser.cpp b/projects/stargazer/plugins/configuration/sgconfig/parser.cpp index 03717981..e52eb3fa 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/parser.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/parser.cpp @@ -40,6 +40,7 @@ int BASE_PARSER::End(void *, const char * el) if (strcasecmp(el, m_tag.c_str()) != 0) return -1; CreateAnswer(); + m_done = true; } --m_depth; diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser.h b/projects/stargazer/plugins/configuration/sgconfig/parser.h index af77158d..4e4b9417 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/parser.h +++ b/projects/stargazer/plugins/configuration/sgconfig/parser.h @@ -38,7 +38,8 @@ class BASE_PARSER BASE_PARSER(const ADMIN & admin, const std::string & t) : m_currAdmin(admin), m_depth(0), - m_tag(t) + m_tag(t), + m_done(false) {} virtual ~BASE_PARSER() {} virtual int Start(void * data, const char * el, const char ** attr); @@ -49,6 +50,8 @@ class BASE_PARSER std::string GetOpenTag() const { return "<" + m_tag + ">"; } std::string GetCloseTag() const { return ""; } + bool IsDone() const { return m_done; } + protected: BASE_PARSER(const BASE_PARSER & rvalue); BASE_PARSER & operator=(const BASE_PARSER & rvalue); @@ -57,6 +60,7 @@ class BASE_PARSER size_t m_depth; std::string m_answer; std::string m_tag; + bool m_done; private: virtual void CreateAnswer() = 0; diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser_message.cpp b/projects/stargazer/plugins/configuration/sgconfig/parser_message.cpp index 06489a42..2279aae6 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/parser_message.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/parser_message.cpp @@ -102,6 +102,7 @@ int SEND_MESSAGE::End(void *, const char *el) m_result = res_ok; } CreateAnswer(); + m_done = true; return 0; } diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser_users.cpp b/projects/stargazer/plugins/configuration/sgconfig/parser_users.cpp index cd66ec9e..67e2c699 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/parser_users.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/parser_users.cpp @@ -682,6 +682,8 @@ int DEL_USER::End(void *, const char *el) if (!res) m_users.Del(u->GetLogin(), &m_currAdmin); + m_done = true; + return 0; } return -1; @@ -731,7 +733,10 @@ int CHECK_USER::Start(void *, const char *el, const char **attr) int CHECK_USER::End(void *, const char *el) { if (strcasecmp(el, m_tag.c_str()) == 0) + { + m_done = true; return 0; + } return -1; } -- 2.43.2