#ifndef ELEMENT_H #define ELEMENT_H ///////////////////////////////////////////////////////////////////// // Element.h - Concrete Element class builds simple XML style // // ver 2.0 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, stdafx.h, stdafx.cpp // // // // Build Process: // // Build with test stub, as console application: // // cl /EHsc /DTEST_ELEMENT element.cpp // creates element.exe // // // // Build as static library to work with client: // // cl /EHsc /c element.cpp // creates element.obj // // lib element.obj // creates element.lib // // // /////////////////////////////////////////////////////////////////////// /* Maintenance History: ==================== ver 2.0 : 01/24/06 - moved title and subtitle functions to client ver 1.0 : 01/20/03 - first release */ // #include #include #include "../IElement/IElement.h" class Element : public IElement { public: Element(const std::string &tag); ~Element(); 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; }; inline Element::~Element() { std::cout << "\n size of Element: " << sizeof(*this); } // 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