#ifndef ELEMENT_H #define ELEMENT_H ///////////////////////////////////////////////////////////////////// // Element.h - Concrete Element class builds simple XML style // // elements // // // // Language: Visual Studio.Net, using standard C++ // // Platform: Dell Dimension 8100, Windows 2000, SP 2 // // Application: Demonstration of Programming to Interface for // // CSE687, Spring 2003 // // Author: Jim Fawcett, CST 2-187, Syracuse University // // (315) 443-3948, jfawcett@twcny.rr.com // ///////////////////////////////////////////////////////////////////// /* Module Operation: ================= The Element class creates simple tagged, attributed elements with string bodies, similar to that used with XML and HTML. The product is of the form: some text The class does no well-formedness checks. Class interface: ================ Element e1("aTag"); Element e2 = e1; e1.addAttribute("name","value"); e2.addBody("some text"); e1 = e2; string elementString = e1.makeElement(); */ ///////////////////////////////////////////////////////////////////// // Build Process // ///////////////////////////////////////////////////////////////////// // Required Files: // // IElement.h, Element.h, Element.cpp // // // // Build Process: // // Set preprocessor definition TEST_ELEMENT in properties // // compile and run in Visual Studio // // or: // // cl /DTEST_ELEMENT Element.cpp // ///////////////////////////////////////////////////////////////////// /* Maintenance History: ==================== - ver 1.0 : 01/20/03 first release */ // #include #include #include "../IElement/IElement.h" class Element : IElement { public: Element(const std::string &tag); void addAttribute(const std::string &name, const std::string &value); void addBody(const std::string &body); std::string makeElement(); private: std::string _tag; std::map _attribs; std::string _body; // adding or removing the useless integer changes // the size of an Element object but does not cause // IElement.cpp to be recompiled, just relinked. int useless; }; // Note: Copy constructor and assignment operator are not needed. // The compiler defined defaults work fine with this class. // // Element(const Element &e); // Element& operator=(const Element &e); #endif