00001 /* -*-mode:c++; c-file-style: "gnu";-*- */ 00002 /* 00003 * $Id: HTMLElementList_8cpp-source.html,v 1.1 2007/07/03 21:34:43 sebdiaz Exp $ 00004 * 00005 * Copyright (C) 1996 - 2004 Stephen F. Booth <sbooth@gnu.org> 00006 * 2007 Sebastien DIAZ <sebastien.diaz@gmail.com> 00007 * Part of the GNU cgicc library, http://www.gnu.org/software/cgicc 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 3 of the License, or (at your option) any later version. 00013 * 00014 * This library is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 * Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public 00020 * License along with this library; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA 00022 */ 00023 00024 #ifdef __GNUG__ 00025 # pragma implementation 00026 #endif 00027 00028 #include <new> 00029 00030 #include "cgicc/HTMLElementList.h" 00031 00032 00033 // ============================================================ 00034 // Class HTMLElementList 00035 // ============================================================ 00036 cgicc::HTMLElementList::HTMLElementList() 00037 { 00038 fElements.reserve(5); 00039 } 00040 00041 cgicc::HTMLElementList::HTMLElementList(const HTMLElement& head) 00042 { 00043 fElements.reserve(5); 00044 fElements.push_back(head.clone()); 00045 } 00046 00047 cgicc::HTMLElementList::HTMLElementList(const HTMLElementList& list) 00048 { 00049 this->operator=(list); 00050 } 00051 00052 cgicc::HTMLElementList::~HTMLElementList() 00053 { 00054 std::vector<HTMLElement*>::const_iterator iter; 00055 for(iter = fElements.begin(); iter != fElements.end(); ++iter) 00056 delete *iter; 00057 } 00058 00059 cgicc::HTMLElementList& 00060 cgicc::HTMLElementList::operator= (const HTMLElementList& list) 00061 { 00062 fElements = list.fElements; 00063 00064 std::vector<HTMLElement*>::iterator iter; 00065 for(iter = fElements.begin(); iter != fElements.end(); ++iter) 00066 *iter = (*iter)->clone(); 00067 00068 return *this; 00069 } 00070 00071 cgicc::HTMLElementList& 00072 cgicc::HTMLElementList::add(const HTMLElement& element) 00073 { 00074 fElements.push_back(element.clone()); 00075 return *this; 00076 } 00077 00078 cgicc::HTMLElementList& 00079 cgicc::HTMLElementList::add(HTMLElement *element) 00080 { 00081 fElements.push_back(element); 00082 return *this; 00083 } 00084 00085 void 00086 cgicc::HTMLElementList::render(std::ostream& out) const 00087 { 00088 std::vector<HTMLElement*>::const_iterator iter; 00089 for(iter = fElements.begin(); iter != fElements.end(); ++iter) 00090 (*iter)->render(out); 00091 }