top | up | prev | next

Element Abstract Class

Definition at line 30 of Element.hpp

Constructors

Element(Element&&) delete
Element(const Element&) delete
Element(const std::u32string& name_)
Element(const std::u32string& name_, std::map<std::u32string, std::unique_ptr<Attr>>&& attributeMap_)

Member Functions

void Accept(Visitor& visitor) override
void AddAttribute(std::unique_ptr<Attr>&& attr)
std::unique_ptr<Node> CloneNode(bool deep) override
std::u32string GetAttribute(const std::u32string& attrName) const
NodeList GetElementsByTagName(const std::u32string& tagName)
bool HasAttributes() const override
bool HasMultilineContent()
void RemoveAttribute(const std::u32string& attrName)
void SetAttribute(const std::u32string& attrName, const std::u32string& attrValue)
const std::u32string& TagName() const
void WalkAttribute(NodeOp& nodeOp) override
void Write(CodeFormatter& formatter) override
void WriteAttributes(CodeFormatter& formatter)
Element& operator=(Element&&) delete
Element& operator=(const Element&) delete

Member Variables

std::map<std::u32string, std::unique_ptr<Attr>> attributeMap

Constructor Details

Element Constructor

sngxml::dom::Element::Element(Element &&) delete

Definition at line 37 of Element.hpp


Element Constructor

sngxml::dom::Element::Element(const Element &) delete

Definition at line 35 of Element.hpp


Element Constructor

sngxml::dom::Element::Element(const std::u32string& name_)

Definition at line 73 of Element.cpp :
 73 : ParentNode(NodeType::elementNodename_)
 74 {
 75 }


Declaration at line 33 of Element.hpp


Element Constructor

sngxml::dom::Element::Element(const std::u32string& name_, std::map<std::u32string, std::unique_ptr<Attr >>&& attributeMap_)

Definition at line 77 of Element.cpp :
 77 : ParentNode(NodeType::elementNodename_)attributeMap(std::move(attributeMap_))
 78 {
 79 }


Declaration at line 34 of Element.hpp


Member Function Details

Accept Member Function

void sngxml::dom::Element::Accept(Visitor & visitor) override

Definition at line 247 of Element.cpp :
248 {
249     visitor.BeginVisit(this);
250     ParentNode::Accept(visitor);
251     visitor.EndVisit(this);
252 }


Declaration at line 49 of Element.hpp

Base class overridden functions: sngxml::dom::Node::Accept , sngxml::dom::ParentNode::Accept

Calls: sngxml::dom::ParentNode::Accept

Called by: sngxml::dom::Element::GetElementsByTagName


AddAttribute Member Function

void sngxml::dom::Element::AddAttribute(std::unique_ptr<Attr >&& attr)

Definition at line 193 of Element.cpp :
194 {
195     attributeMap[attr->Name()] = std::move(attr);
196 }


Declaration at line 44 of Element.hpp

Calls: sngxml::dom::Node::Name


CloneNode Member Function

std::unique_ptr<Node > sngxml::dom::Element::CloneNode(bool deep) override

Definition at line 81 of Element.cpp
Declaration at line 39 of Element.hpp

Base class overridden functions: sngxml::dom::Node::CloneNode

Calls: sngxml::dom::Element::CloneNode , sngxml::dom::Node::InternalSetParent , sngxml::dom::Node::Name , sngxml::dom::ParentNode::CloneChildrenTo

Called by: sngxml::dom::Element::CloneNode


GetAttribute Member Function

std::u32string sngxml::dom::Element::GetAttribute(const std::u32string& attrName) const

Definition at line 183 of Element.cpp :
184 {
185     auto it = attributeMap.find(attrName);
186     if (it != attributeMap.cend())
187     {
188         return it->second->Value();
189     }
190     return std::u32string();
191 }


Declaration at line 43 of Element.hpp

Called by: sngxml::dom::BuildIndexVisitor::BeginVisit , sngxml::dom::Element::Write


GetElementsByTagName Member Function

NodeList sngxml::dom::Element::GetElementsByTagName(const std::u32string& tagName)

Definition at line 239 of Element.cpp :
240 {
241     NodeList result;
242     ElementsByTagNameVisitor visitor(resulttagName);
243     Accept(visitor);
244     return result;
245 }


Declaration at line 48 of Element.hpp

Calls: sngxml::dom::Element::Accept


HasAttributes Member Function

bool sngxml::dom::Element::HasAttributes() const override

Definition at line 101 of Element.cpp :
102 {
103     return !attributeMap.empty();
104 }


Declaration at line 41 of Element.hpp

Base class overridden functions: sngxml::dom::Node::HasAttributes


HasMultilineContent Member Function

bool sngxml::dom::Element::HasMultilineContent()

Definition at line 171 of Element.cpp :
172 {
173     if (FirstChild() != LastChild()) return true;
174     Node* child = FirstChild();
175     if (child)
176     {
177         if (child->GetNodeType() == NodeType::elementNode || child->GetNodeType() == NodeType::documentNode) return true;
178         if (child->ValueContainsNewLine()) return true;
179     }
180     return false;
181 }


Declaration at line 53 of Element.hpp

Calls: sngxml::dom::Node::GetNodeType , sngxml::dom::Node::ValueContainsNewLine , sngxml::dom::ParentNode::FirstChild , sngxml::dom::ParentNode::LastChild

Called by: sngxml::dom::Element::Write


RemoveAttribute Member Function

void sngxml::dom::Element::RemoveAttribute(const std::u32string& attrName)

Definition at line 203 of Element.cpp :
204 {
205     attributeMap.erase(attrName);
206 }


Declaration at line 46 of Element.hpp


SetAttribute Member Function

void sngxml::dom::Element::SetAttribute(const std::u32string& attrName, const std::u32string& attrValue)

Definition at line 198 of Element.cpp :
199 {
200     attributeMap[attrName] = std::unique_ptr<Attr>(new Attr(attrNameattrValue));
201 }


Declaration at line 45 of Element.hpp


TagName Member Function

const std::u32string& sngxml::dom::Element::TagName() const

Definition at line 40 of Element.hpp :
40 { return Name(); }

Calls: sngxml::dom::Node::Name


WalkAttribute Member Function

void sngxml::dom::Element::WalkAttribute(NodeOp & nodeOp) override

Definition at line 208 of Element.cpp :
209 {
210     for (const auto& p : attributeMap)
211     {
212         Attr* attr = p.second.get();
213         nodeOp.Apply(attr);
214     }
215 }


Declaration at line 47 of Element.hpp

Base class overridden functions: sngxml::dom::Node::WalkAttribute

Calls: sngxml::dom::NodeOp::Apply


Write Member Function

void sngxml::dom::Element::Write(CodeFormatter& formatter) override

Definition at line 106 of Element.cpp
Declaration at line 42 of Element.hpp

Calls: sngxml::dom::Element::GetAttribute , sngxml::dom::Element::HasMultilineContent , sngxml::dom::Element::Write , sngxml::dom::Element::WriteAttributes , sngxml::dom::Node::Name , sngxml::dom::ParentNode::HasChildNodes , sngxml::dom::ParentNode::Write

Called by: sngxml::dom::Element::Write , sngxml::dom::Element::WriteAttributes


WriteAttributes Member Function

void sngxml::dom::Element::WriteAttributes(CodeFormatter& formatter)

Definition at line 162 of Element.cpp :
163 {
164     for (auto& p : attributeMap)
165     {
166         std::std::unique_ptr<Attr>&attr=p.second;
167         attr->Write(formatter);
168     }
169 }


Declaration at line 52 of Element.hpp

Calls: sngxml::dom::Element::Write

Called by: sngxml::dom::Element::Write


operator= Member Function

Element & sngxml::dom::Element::operator=(Element &&) delete

Definition at line 38 of Element.hpp


operator= Member Function

Element & sngxml::dom::Element::operator=(const Element &) delete

Definition at line 36 of Element.hpp


top | up | prev | next