123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- #pragma once
- #include <functional>
- #include "Array.h"
- #include "Maybe.h"
- #include "RCPointer.h"
- #include "ReferenceCounter.h"
- namespace Framework
- {
- class Text;
- namespace XML
- {
- class Editor;
-
-
- class Element : public virtual ReferenceCounter
- {
- private:
- RCArray<Element>* children;
- RCArray<Text>* attributes;
- RCArray<Text>* attributeValues;
- Text* name;
- Text* text;
- Element* parent;
- public:
-
-
-
- DLLEXPORT Element(Text string);
-
-
-
-
- DLLEXPORT Element(Text string, Element* zParent);
- DLLEXPORT ~Element();
-
-
-
- DLLEXPORT void setAttribute(Text attribut, Text value);
-
-
- DLLEXPORT void removeAttribute(Text attribut);
-
-
- DLLEXPORT void addChild(Element* child);
-
-
- DLLEXPORT void addChildAtFront(Element* child);
-
-
- DLLEXPORT void removeChild(Element* child);
-
-
- DLLEXPORT void removeChild(int i);
-
- DLLEXPORT void removeAllChilds();
-
-
- DLLEXPORT void removeChilds(RCArray<Element>* childs);
-
- DLLEXPORT void remove();
-
-
- DLLEXPORT void setText(Text text);
-
- DLLEXPORT Text getText() const;
-
- DLLEXPORT int getChildCount() const;
-
-
-
-
-
-
-
- DLLEXPORT int getChildIndex(Element* zChild) const;
-
- DLLEXPORT Element* getChild(int i) const;
-
- DLLEXPORT Element* zChild(int i) const;
-
- DLLEXPORT Element* getParent() const;
-
- DLLEXPORT Element* zParent() const;
-
-
- DLLEXPORT ArrayIterator<Element*> getChilds() const;
-
- DLLEXPORT Editor select();
-
- DLLEXPORT Editor selectChildren() const;
-
-
- DLLEXPORT Editor selectChildsByName(Text name) const;
-
-
- DLLEXPORT Editor selectChildsByAttribute(Text attribute) const;
-
-
-
- DLLEXPORT Editor selectChildsByAttribute(
- Text attribute, Text value) const;
-
- DLLEXPORT bool hasAttribute(Text name) const;
-
- DLLEXPORT int getAttributeCount() const;
-
- DLLEXPORT Text getAttributeName(int i) const;
-
- DLLEXPORT Text getAttributeValue(int i) const;
-
-
- DLLEXPORT Text getAttributeValue(Text attribut) const;
-
-
- DLLEXPORT ArrayIterator<Text*> getAttributeNames() const;
-
-
- DLLEXPORT ArrayIterator<Text*> getAttributeValues() const;
-
- DLLEXPORT Text getName() const;
-
-
- DLLEXPORT Text toString() const;
-
- DLLEXPORT Element* dublicate() const;
- friend Editor;
- };
-
- class Editor : public virtual ReferenceCounter
- {
- private:
- RCArray<Element>* elements;
- public:
-
-
- DLLEXPORT Editor(RCArray<Element>* elements);
- DLLEXPORT Editor(const Editor& e);
- DLLEXPORT ~Editor();
-
-
-
-
-
- DLLEXPORT Maybe<RCPointer<Element>> getFirstElement() const;
-
-
-
- DLLEXPORT void setAttribute(Text attribut, Text value);
-
-
- DLLEXPORT void removeAttribute(Text attribut);
-
-
- DLLEXPORT void addChild(Element* child);
-
-
- DLLEXPORT void removeChild(Element* child);
-
-
- DLLEXPORT void removeChild(int i);
-
- DLLEXPORT void removeAllChilds();
-
-
- DLLEXPORT void removeChilds(RCArray<Element>* childs);
-
-
- DLLEXPORT void remove();
-
-
- DLLEXPORT void setText(Text text);
-
- DLLEXPORT ArrayIterator<Element*> begin();
-
- DLLEXPORT ArrayIterator<Element*> end();
-
-
-
- DLLEXPORT Editor selectAllElements();
-
- DLLEXPORT Editor selectChildren() const;
-
- DLLEXPORT Editor selectParents() const;
-
-
- DLLEXPORT Editor whereNameEquals(Text name) const;
-
-
- DLLEXPORT Editor whereChildWithNameExists(Text name) const;
-
-
- DLLEXPORT Editor whereChildWithAttributeExists(
- Text attribute) const;
-
-
-
- DLLEXPORT Editor whereChildWithAttributeExists(
- Text attribute, Text value) const;
-
-
- DLLEXPORT Editor whereAttributeExists(Text attribute) const;
-
-
-
- DLLEXPORT Editor whereAttributeEquals(
- Text attribute, Text value) const;
-
-
-
- DLLEXPORT Editor without(Editor e) const;
-
-
-
- DLLEXPORT void forEach(std::function<void(Element*)> f) const;
-
- DLLEXPORT bool exists() const;
-
- DLLEXPORT int getSize() const;
-
- DLLEXPORT Editor& operator=(const Editor& e);
- };
- }
- }
|