- if (strcasecmp(tag.c_str(), "getserverinfo") == 0)
- return new STG::PARSER::GET_SERVER_INFO(*m_admin, m_settings, m_users, m_tariffs);
- if (strcasecmp(tag.c_str(), "getadmins") == 0)
- return new STG::PARSER::GET_ADMINS(*m_admin, m_admins);
- if (strcasecmp(tag.c_str(), "addadmin") == 0)
- return new STG::PARSER::ADD_ADMIN(*m_admin, m_admins);
- if (strcasecmp(tag.c_str(), "deladmin") == 0)
- return new STG::PARSER::DEL_ADMIN(*m_admin, m_admins);
- if (strcasecmp(tag.c_str(), "chgadmin") == 0)
- return new STG::PARSER::CHG_ADMIN(*m_admin, m_admins);
- return NULL;
+ ssize_t res = write(m_sock, buffer, size);
+ if (res < 0)
+ {
+ // TODO: log it
+ return false;
+ }
+ return true;
+}
+
+BASE_PARSER * Conn::GetParser(const std::string & tag) const
+{
+ BASE_PARSER::REGISTRY::const_iterator it = m_registry.find(tag);
+ if (it == m_registry.end())
+ return NULL;
+ return it->second->create(*m_admin);