Skip to content

Commit 589fa00

Browse files
committed
Add XML methods: setName, removeChild, getAttributeNames, setAttributeInt/Float
1 parent 0978c07 commit 589fa00

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/Processing.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,6 +2132,11 @@ struct XML {
21322132
::std::vector<XML*> getChildren(const ::std::string& n){ ::std::vector<XML*> r; for(auto& c:children) if(c.name==n) r.push_back(&c); return r; }
21332133

21342134
::std::string toString(int indent=0) const;
2135+
void setName(const ::std::string& n) { name=n; }
2136+
void removeChild(XML* c) { children.erase(::std::remove_if(children.begin(),children.end(),[c](const XML& x){return &x==c;}),children.end()); }
2137+
::std::vector<::std::string> getAttributeNames() const { ::std::vector<::std::string> r; for(auto& p:attributes) r.push_back(p.first); return r; }
2138+
void setAttributeInt(const ::std::string& k, int v) { attributes[k]=::std::to_string(v); }
2139+
void setAttributeFloat(const ::std::string& k, float v){ attributes[k]=::std::to_string(v); }
21352140
};
21362141

21372142

0 commit comments

Comments
 (0)