Add session command class

The class abstracts the session commands and the lists of session commands
using standard library containers.
This commit is contained in:
Markus Mäkelä
2017-03-24 15:04:04 +02:00
parent 9e4e70a337
commit d8abefff5f
5 changed files with 147 additions and 2 deletions

View File

@ -0,0 +1,56 @@
/*
* Copyright (c) 2016 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
*
* Change Date: 2019-07-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
#include "session_command.hh"
#include <maxscale/modutil.h>
void SessionCommand::mark_reply_received()
{
m_replySent = true;
}
bool SessionCommand::is_reply_received() const
{
return m_replySent;
}
Buffer SessionCommand::copy_buffer() const
{
return m_buffer;
}
SessionCommand::SessionCommand(GWBUF *buffer):
m_buffer(buffer),
m_replySent(false)
{
}
SessionCommand::~SessionCommand()
{
}
std::string SessionCommand::to_string()
{
std::string str;
GWBUF **buf = &m_buffer;
char *sql;
int sql_len;
if (modutil_extract_SQL(*buf, &sql, &sql_len))
{
str.append(sql, sql_len);
}
return str;
}