Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cgicc: multi-levels of same element
- <ul>
- <li>
- <a href="#" ><span>Main 1</span></a>
- <ul>
- <li><a href="ref1-1" ><span>Sub 1</span></a></li>
- <li><a href="ref1-2" ><span>Sub 2</span></a></li>
- <li><a href="ref1-3" ><span>Sub 3</span></a></li>
- </ul>
- </li>
- <li>
- <a href="#" ><span>Main 2</span></a>
- <ul>
- <li><a href="ref2-1" ><span>Sub 1</span></a></li>
- <li><a href="ref2-2" ><span>Sub 2</span></a></li>
- <li><a href="ref2-3" ><span>Sub 3</span></a></li>
- </ul>
- </li>
- </ul>
- cout << ul() << endl;
- cout << li() << endl;
- cout << a("Main 1").set("href", "#") << endl;
- cout << ul() << endl; // <-- must fail here!
- cout << li(a("Sub 1").set("href", "ref1-1")) << endl;
- cout << li(a("Sub 2").set("href", "ref1-2")) << endl;
- cout << li(a("Sub 3").set("href", "ref1-3")) << endl;
- cout << ul() << endl;
- cout << li() << endl;
- cout << li() << endl;
- cout << a("Main 2").set("href", "#") << endl;
- cout << ul() << endl;
- cout << li(a("Sub 1").set("href", "ref2-1")) << endl;
- cout << li(a("Sub 2").set("href", "ref2-2")) << endl;
- cout << li(a("Sub 3").set("href", "ref2-3")) << endl;
- cout << ul() << endl;
- cout << li() << endl;
- cout << ul() << endl;
- #include <cgicc/HTMLElement.h>
- #include <cgicc/HTMLAttributeList.h>
- template<class Tag>
- class HTMLSimpleElement : public cgicc::HTMLElement
- {
- public:
- HTMLSimpleElement() : HTMLElement(0, 0, 0, EElementType(-1))
- {}
- HTMLSimpleElement(const cgicc::HTMLAttributeList& attributes) : HTMLElement(&attributes, 0, 0, EElementType(-1))
- {}
- virtual ~HTMLSimpleElement() {}
- virtual inline HTMLElement* clone() const
- { return new HTMLSimpleElement<Tag>(*this); }
- virtual inline const char* getName() const
- { return Tag::getName(); }
- virtual void render(std::ostream& out) const
- {
- const cgicc::HTMLAttributeList* attributes = getAttributes();
- out << '<' << getName();
- if (attributes != NULL)
- {
- out << ' ';
- attributes->render(out);
- }
- out << ">";
- }
- };
- #define TAG(name, tag)
- class name##Tag
- { public: inline static const char* getName() { return tag; } }
- #define SIMPLE_ELEMENT(name, tag)
- TAG(name, tag); typedef HTMLSimpleElement<name##Tag> name
- SIMPLE_ELEMENT (divB, "div");
- SIMPLE_ELEMENT (divE, "/div");
- // and so on...
Add Comment
Please, Sign In to add comment