Samchon Framework for CPP  1.0.0
ChatMessage.cpp
1 #include "ChatMessage.hpp"
2 
3 #include <samchon/library/XML.hpp>
4 
5 using namespace std;
6 using namespace samchon::library;
7 using namespace samchon::protocol;
8 using namespace samchon::example::chat_service;
9 
10 /* -----------------------------------------------------------
11  CONSTRUCTORS
12 ----------------------------------------------------------- */
13 ChatMessage::ChatMessage()
14  : super()
15 {
16 }
17 void ChatMessage::construct(shared_ptr<XML> xml)
18 {
19  this->orator = xml->getProperty("orator");
20  this->message = xml->getProperty("message");
21 
22  if(xml->hasProperty("listener") == true)
23  this->listener = xml->getProperty("listener");
24  else
25  this->listener.clear();
26 }
27 
28 /* -----------------------------------------------------------
29  GETTERS
30 ----------------------------------------------------------- */
31 auto ChatMessage::getListener() const -> string
32 {
33  return listener;
34 }
35 auto ChatMessage::toXML() const -> shared_ptr<XML>
36 {
37  shared_ptr<XML> &xml = super::toXML();
38  xml->setProperty("orator", orator);
39  xml->setProperty("message", message);
40 
41  if(listener.empty() == false)
42  xml->setProperty("listener", listener);
43  return xml;
44 }
45 
std::string listener
A listener, target of whispering.
Definition: ChatMessage.hpp:45
An entity, a standard data class.
Definition: Entity.hpp:48
virtual auto toXML() const -> std::shared_ptr< library::XML >
Get an XML object represents the Entity.
Definition: Entity.cpp:30
A chat service inherited from cloud service.
Definition: ChatClient.hpp:8
Definition: RWMutex.hpp:4
std::string message
A message, what to say.
Definition: ChatMessage.hpp:50
Package of libraries.
Definition: library.hpp:84
virtual void construct(std::shared_ptr< library::XML >)
Construct data of the Entity from an XML object.
Definition: ChatMessage.cpp:17
auto getListener() const -> std::string
Get listener.
Definition: ChatMessage.cpp:31
virtual auto toXML() const -> std::shared_ptr< library::XML >
Get an XML object represents the Entity.
Definition: ChatMessage.cpp:35
Package of network protocol and libraries.
Definition: protocol.hpp:185
std::string orator
An orator, who told.
Definition: ChatMessage.hpp:33
XML is a class representing xml object.
Definition: XML.hpp:72