[DEV] add some capabilities
This commit is contained in:
parent
8543095cf3
commit
ce8bef3599
@ -18,6 +18,7 @@ namespace exml
|
||||
{
|
||||
public:
|
||||
Declaration(void) { };
|
||||
Declaration(const etk::UString& _version, const etk::UString& _format, const etk::UString& _validation) { };
|
||||
virtual ~Declaration(void) { };
|
||||
virtual nodeType_te GetType(void) const { return typeAttribute; };
|
||||
virtual bool Generate(etk::UString& _data, int32_t _indent) const;
|
||||
|
@ -81,6 +81,7 @@ exml::Attribute* exml::Element::GetAttr(int32_t _id)
|
||||
}
|
||||
return m_listAttribute[_id];
|
||||
}
|
||||
|
||||
const exml::Attribute* exml::Element::GetAttr(int32_t _id) const
|
||||
{
|
||||
if (_id <0 || _id>m_listAttribute.Size()) {
|
||||
@ -88,6 +89,7 @@ const exml::Attribute* exml::Element::GetAttr(int32_t _id) const
|
||||
}
|
||||
return m_listAttribute[_id];
|
||||
}
|
||||
|
||||
void exml::Element::AppendAttribute(exml::Attribute* _node)
|
||||
{
|
||||
if (_node == NULL) {
|
||||
@ -118,6 +120,37 @@ const etk::UString& exml::Element::GetAttribute(const etk::UString& _name) const
|
||||
return errorReturn;
|
||||
}
|
||||
|
||||
void exml::Element::SetAttribute(const etk::UString& _name, const etk::UString& _value)
|
||||
{
|
||||
// check if attribute already det :
|
||||
for (int32_t iii=0; iii<m_listAttribute.Size(); iii++) {
|
||||
if( NULL != m_listAttribute[iii]
|
||||
&& m_listAttribute[iii]->GetName() == _name) {
|
||||
// update the value :
|
||||
m_listAttribute[iii]->SetValue(_value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
exml::Attribute* attr = new exml::Attribute(_name, _value);
|
||||
if (NULL==attr) {
|
||||
EXML_ERROR("memory allocation error...");
|
||||
}
|
||||
m_listAttribute.PushBack(attr);
|
||||
}
|
||||
|
||||
etk::UString exml::Element::GetText(void)
|
||||
{
|
||||
// TODO : Add more capabilities ...
|
||||
etk::UString res;
|
||||
for (int32_t iii=0; iii<m_listSub.Size(); iii++) {
|
||||
if (NULL!=m_listSub[iii]) {
|
||||
m_listSub[iii]->Generate(res, 0);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
bool exml::Element::Generate(etk::UString& _data, int32_t _indent) const
|
||||
{
|
||||
AddIndent(_data, _indent);
|
||||
|
@ -39,6 +39,9 @@ namespace exml
|
||||
Attribute* GetAttr(int32_t _id);
|
||||
const Attribute* GetAttr(int32_t _id) const;
|
||||
const etk::UString& GetAttribute(const etk::UString& _name) const;
|
||||
void SetAttribute(const etk::UString& _name, const etk::UString& _value);
|
||||
public:
|
||||
etk::UString GetText(void);
|
||||
public:
|
||||
virtual bool Parse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, ivec2& _filePos);
|
||||
virtual bool Generate(etk::UString& _data, int32_t _indent) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user