2 #include <samchon/protocol/Entity.hpp> 5 #include <samchon/ByteArray.hpp> 6 #include <samchon/WeakString.hpp> 80 std::shared_ptr<library::XML>
xml;
112 InvokeParameter(
const std::string &name,
const std::string &type,
const std::string &val)
152 template <
typename T>
157 construct_by_varadic_template(val);
163 this->type =
"string";
175 this->type =
"string";
177 this->str = move(str);
186 this->type =
"ByteArray";
188 this->byte_array = move(byte_array);
193 virtual void construct(std::shared_ptr<library::XML> xml)
override 195 if (xml->hasProperty(
"name") ==
true)
196 this->name = xml->getProperty(
"name");
200 this->type = xml->getProperty(
"type");
207 this->xml = xml->begin()->second->at(0);
209 else if (type ==
"ByteArray")
211 size_t size = xml->getValue<
size_t>();
213 byte_array.reserve(size);
216 this->str = xml->getValue();
219 auto byteArrayCapacity()
const ->
size_t 221 return byte_array.capacity();
226 byte_array = move(ba);
230 template <
typename T>
231 void construct_by_varadic_template(
const T &val)
233 this->type =
"number";
235 std::stringstream sstream;
238 this->str = move(sstream.str());
240 template<>
void construct_by_varadic_template(
const std::string &str)
242 this->type =
"string";
245 template<>
void construct_by_varadic_template(
const WeakString &wstr)
247 this->type =
"string";
248 this->str = wstr.
str();
250 template<>
void construct_by_varadic_template(
const ByteArray &byte_array)
252 this->type =
"ByteArray";
256 template<>
void construct_by_varadic_template(
const std::shared_ptr<library::XML> &xml)
266 virtual auto key() const ->
std::
string override 294 double val = std::stod(str);
298 template<>
auto getValue()
const -> std::string
306 template<>
auto getValue()
const -> std::shared_ptr<library::XML>
329 template <
typename T>
auto referValue()
const ->
const T&;
330 template<>
auto referValue()
const ->
const std::string&
344 template <
typename T>
auto moveValue() -> T;
345 template<>
auto moveValue() -> std::string
351 return move(byte_array);
358 virtual auto TAG()
const -> std::string
override 363 virtual auto toXML()
const -> std::shared_ptr<library::XML>
override 365 std::shared_ptr<library::XML> &xml = super::toXML();
367 if (name.empty() ==
false)
368 xml->setProperty(
"name", name);
369 xml->setProperty(
"type", type);
372 xml->push_back(this->xml);
373 else if (type ==
"ByteArray")
374 xml->setValue(byte_array.size());
An entity, a standard data class.
auto str() const -> std::string
Get the string content.
std::string str
A string value if the type is "string" or "number".
std::string name
A name can represent the parameter.
InvokeParameter(const std::string &name, const std::string &type, const std::string &val)
Construct from arguments.
InvokeParameter(const std::string &name, const T &val)
Construct with its name and a value.
auto referValue() const -> const T &
Reference value.
auto getType() const -> std::string
Get type.
std::shared_ptr< library::XML > xml
An XML object if the type is "XML".
virtual auto key() const -> std::string override
Get a key that can identify the Entity uniquely.
auto moveValue() -> T
Move value.
auto getValueAsXML() const -> std::shared_ptr< library::XML >
Get value as XML object.
auto getName() const -> std::string
Get name.
Standard message of network I/O.
InvokeParameter()
Default Constructor.
ByteArray byte_array
A binary value if the type is "ByteArray".
std::string type
Type of the parameter.
InvokeParameter(const std::string &name, std::string &&str)
Construct from the name and a moved string.
A parameter of an Invoke.
auto getValue() const -> T
Get value.
InvokeParameter(const std::string &name, ByteArray &&byte_array)
Construct from name and a moved ByteArray.
A string class only references characeters, reference only.