SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
Event.cc
Go to the documentation of this file.
1 /*
2  * SWC-DB© Copyright since 2019 Alex Kashirin <kashirin.alex@gmail.com>
3  * License details at <https://github.com/kashirin-alex/swc-db/#license>
4  */
5 
6 
7 
9 
10 
11 namespace SWC { namespace Comm {
12 
13 
14 
15 Event::~Event() noexcept { }
16 
17 int32_t Event::response_code() const noexcept {
18  if(error)
19  return error;
20 
21  const uint8_t *ptr = data.base;
22  size_t remaining = data.size;
23 
24  try {
25  return Serialization::decode_i32(&ptr, &remaining);
26  /* opt
27  std::string msg = Serialization::decode_bytes_string(&ptr, &remaining);
28  */
29  } catch(...) {
32  return e.code();
33  }
34 }
35 
36 void Event::print(std::ostream& out) const {
37  out << "Event: ";
38  if(error) {
39  Error::print(out << "ERROR ", error);
40  } else {
41  header.print(out << "MESSAGE ");
42  out << " buffers-sz(" << data.size << ',' << data_ext.size << ')';
43  }
44 }
45 
46 
47 }} // namespace SWC::Comm
48 
SWC::Comm::Header::print
void print(std::ostream &out) const
Definition: Header.cc:13
SWC::Comm::Event::header
Header header
Definition: Event.h:62
SWC::Error::Exception::code
constexpr SWC_CAN_INLINE int code() const noexcept
Definition: Exception.h:51
SWC_LOG_OSTREAM
#define SWC_LOG_OSTREAM
Definition: Logger.h:44
SWC_LOG_OUT
#define SWC_LOG_OUT(pr, _code_)
Definition: Logger.h:178
SWC::Comm::Event::print
void print(std::ostream &out) const
Definition: Event.cc:36
SWC::Comm::Event::data
StaticBuffer data
Primary data buffer.
Definition: Event.h:60
SWC::Comm::Event::error
int error
Definition: Event.h:63
SWC::Comm::Event::data_ext
StaticBuffer data_ext
Extended buffer.
Definition: Event.h:61
SWC::Comm::Event::~Event
~Event() noexcept
Definition: Event.cc:15
SWC::Comm::Event::response_code
int32_t response_code() const noexcept
Definition: Event.cc:17
SWC_CURRENT_EXCEPTION
#define SWC_CURRENT_EXCEPTION(_msg_)
Definition: Exception.h:119
SWC::Core::Buffer::base
value_type * base
Definition: Buffer.h:131
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::Core::Buffer::size
size_t size
Definition: Buffer.h:130
Event.h
SWC::LOG_ERROR
@ LOG_ERROR
Definition: Logger.h:32
SWC::Error::print
void print(std::ostream &out, int err)
Definition: Error.cc:191
SWC::Error::Exception
Definition: Exception.h:21
SWC::Serialization::decode_i32
SWC_CAN_INLINE uint32_t decode_i32(const uint8_t **bufp, size_t *remainp)
Definition: Serialization.h:143