3 #include <samchon/protocol/Entity.hpp> 4 #include <samchon/protocol/IHTMLEntity.hpp> 5 #include <samchon/protocol/SharedEntityArray.hpp> 7 #include <samchon/library/XML.hpp> 11 # pragma comment(lib, "x64/Debug/SamchonFramework.lib") 13 # pragma comment(lib, "x64/Release/SamchonFramework.lib") 17 # pragma comment(lib, "Debug/SamchonFramework.lib") 19 # pragma comment(lib, "Release/SamchonFramework.lib") 46 Member(
const string &
id,
const string &name,
int age,
int grade)
54 virtual ~Member() =
default;
56 virtual void construct(shared_ptr<XML> xml)
override 58 this->
id = xml->getProperty(
"id");
59 this->name = xml->getProperty(
"name");
60 this->age = xml->getProperty<
int>(
"age");
61 this->grade = xml->getProperty<
int>(
"grade");
67 virtual auto key() const ->
std::
string override 75 virtual auto TAG() const ->
string override 79 virtual auto toXML() const -> shared_ptr<
XML>
81 shared_ptr<XML> &xml = super::toXML();
82 xml->setProperty(
"id",
id);
83 xml->setProperty(
"name", name);
84 xml->setProperty(
"age", age);
85 xml->setProperty(
"grade", grade);
89 virtual auto toHTML() const ->
string 91 return toTR(
id, name, age, grade);
113 this->chief =
nullptr;
115 virtual ~MemberArray() =
default;
119 virtual void construct(shared_ptr<XML> xml)
override 121 super::construct(xml);
123 this->application = xml->getProperty(
"application");
124 this->department = xml->getProperty<
int>(
"department");
126 if(xml->hasProperty(
"chief") ==
true && this->has( xml->getProperty(
"chief") ) ==
true)
127 this->chief = this->
get( xml->getProperty(
"cheif") ).
get();
132 virtual auto createChild(shared_ptr<XML> =
nullptr) -> Member*
override 141 virtual auto TAG() const ->
string override 143 return "memberArray";
145 virtual auto CHILD_TAG() const ->
string override 152 virtual auto toXML() const -> shared_ptr<XML>
154 shared_ptr<XML> &xml = super::toXML();
155 xml->setProperty(
"application", application);
156 xml->setProperty(
"department", department);
159 xml->setProperty(
"cheif", chief->key());
163 virtual auto toHTML() const ->
string 165 string html =
"<table>\n";
166 html += toTH(
"ID",
"Name",
"Age",
"Grade") +
"\n";
168 for (
size_t i = 0; i < 2; i++)
169 html += at(i)->toHTML() +
"\n";
178 string str = string(
"") +
179 "<memberArray application='framework' department='7' cheif='samchon'>\n" +
180 " <member id='samchon' name='Jeongho Nam' age='27' grade='5' />" +
181 " <member id='submaster' name='No Name' age='100' grade='4' />" +
182 " <member id='john' name='John Doe' age='33' grade='2' />" +
183 " <member id='bad_man' name='Bad Man' age='44' grade='-1' />" +
184 " <member id='guest' name='Guest' age='0' grade='0' />" +
186 shared_ptr<XML> xml(
new XML(str));
188 MemberArray memberArray;
189 memberArray.construct(xml);
191 memberArray.emplace_back(
new Member(
"freshman",
"A fresh man", 20, 2));
192 memberArray.emplace_back(
new Member(
"senior",
"A senior", 70, 2));
194 cout << memberArray.toXML()->toString() << endl << endl;
195 cout << memberArray.toHTML() << endl;
An entity, a standard data class.
An Entity and a container of children Entity objects.
Package of network protocol and libraries.
XML is a class representing xml object.
An interface supporting conversion to html.