2 #include <samchon/protocol/Entity.hpp> 4 #include <samchon/library/StringUtil.hpp> 5 #include <samchon/library/XML.hpp> 15 using namespace library;
16 using namespace protocol;
30 :
public virtual Entity<std::string>
76 Instance(
const string &name,
int price,
int volume,
int weight)
81 this->volume = volume;
82 this->weight = weight;
87 virtual void construct(shared_ptr<XML> xml)
override 89 this->name = xml->getProperty(
"name");
90 this->price = xml->getProperty<
int>(
"price");
91 this->volume = xml->getProperty<
int>(
"volume");
92 this->weight = xml->getProperty<
int>(
"weight");
133 virtual auto toXML()
const -> shared_ptr<XML>
override 135 shared_ptr<XML> &xml = super::toXML();
136 xml->setProperty(
"name", name);
137 xml->setProperty(
"price", price);
138 xml->setProperty(
"volume", volume);
139 xml->setProperty(
"weight", weight);
151 "{1}: ${2}, {3}cm^3, {4}g",
152 name, price, volume, weight
An entity, a standard data class.
auto get_name() const -> string
Get name.
int price
Price of an instance -> 1,000 won.
Instance(const string &name, int price, int volume, int weight)
Construct from instance.
Instance()
Default Constructor.
auto getPrice() const -> int
Get price.
auto getVolume() const -> int
Get volume.
auto getWeight() const -> int
Get weight.
string name
Name represent the Instance.
static auto substitute(const std::string &format, const T &val, const _Args &...args) -> std::string
Substitutes "{n}" tokens within the specified string with the respective arguments passed in...
int volume
Volume of an instance -> 130 cm^3.
int weight
Weight of an instance -> 1,200 g.
virtual auto toString() const -> string
Return a string represents the Instance.