2020-09-08 19:15:28 +08:00
|
|
|
#include "HtmlElement.h"
|
|
|
|
#include "HtmlObject.h"
|
|
|
|
|
|
|
|
NS_FGUI_BEGIN
|
2022-07-11 17:50:21 +08:00
|
|
|
USING_NS_AX;
|
2020-09-08 19:15:28 +08:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
HtmlElement::HtmlElement(Type type) :
|
|
|
|
type(type),
|
|
|
|
link(nullptr),
|
|
|
|
obj(nullptr),
|
|
|
|
space(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int HtmlElement::getInt(const std::string& attrName, int defValue)
|
|
|
|
{
|
|
|
|
if (attrs.empty())
|
|
|
|
return defValue;
|
|
|
|
|
|
|
|
auto it = attrs.find(attrName);
|
|
|
|
if (it != attrs.end())
|
|
|
|
return it->second.asInt();
|
|
|
|
else
|
|
|
|
return defValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string HtmlElement::getString(const std::string& attrName, const std::string& defValue)
|
|
|
|
{
|
|
|
|
if (attrs.empty())
|
|
|
|
return defValue;
|
|
|
|
|
|
|
|
auto it = attrs.find(attrName);
|
|
|
|
if (it != attrs.end())
|
|
|
|
return it->second.asString();
|
|
|
|
else
|
|
|
|
return defValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ValueVector& HtmlElement::getArray(const std::string& attrName)
|
|
|
|
{
|
|
|
|
if (!attrs.empty())
|
|
|
|
{
|
|
|
|
auto it = attrs.find(attrName);
|
|
|
|
if (it != attrs.end())
|
|
|
|
return it->second.asValueVector();
|
|
|
|
}
|
|
|
|
|
|
|
|
attrs[attrName] = ValueVector();
|
|
|
|
return attrs[attrName].asValueVector();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_FGUI_END
|