00001 /* 00002 ** \file Link.h 00003 ** \date 2006-05-05 00004 ** \author grymse@alhem.net 00005 **/ 00006 /* 00007 Copyright (C) 2006 Anders Hedstrom 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License 00011 as published by the Free Software Foundation; either version 2 00012 of the License, or (at your option) any later version. 00013 00014 This program 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 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with this program; if not, write to the Free Software 00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00022 */ 00023 #ifndef _CGI_LINK_H 00024 #define _CGI_LINK_H 00025 00026 #include <string> 00027 #include <list> 00028 #include "Styled.h" 00029 00030 class WebForm; 00031 00032 00033 namespace Cgi 00034 { 00035 00036 00037 class Link : public Styled 00038 { 00039 class Param { 00040 public: 00041 Param(const std::string& name) : m_name(name) {} 00042 virtual ~Param() {} 00043 virtual std::string Print() { 00044 std::string tmp = "&"; 00045 tmp += m_name; 00046 return tmp; 00047 } 00048 std::string m_name; 00049 }; 00050 class Param2 : public Param { 00051 public: 00052 Param2(const std::string& name,const std::string& value) : Param(name), m_value(value) {} 00053 std::string Print() { 00054 std::string tmp = "&"; 00055 tmp += m_name; 00056 tmp += "="; 00057 tmp += m_value; 00058 return tmp; 00059 } 00060 std::string m_value; 00061 }; 00062 typedef std::list<Param *> param_v; 00063 public: 00064 Link(WebForm *, const std::string& action, const std::string& linktext); 00065 ~Link(); 00066 00067 void AddParam(const std::string& name); 00068 void AddParam(const std::string& name,const std::string& value); 00069 void AddParam(const std::string& name,long value); 00070 00071 const std::string& GetLink(); 00072 00073 private: 00074 Link(const Link& ) {} // copy constructor 00075 Link& operator=(const Link& ) { return *this; } // assignment operator 00076 WebForm *m_webform; 00077 std::string m_action; 00078 std::string m_linktext; 00079 param_v m_params; 00080 std::string m_link; 00081 }; 00082 00083 00084 } // namespace Cgi 00085 00086 00087 #endif // _CGI_LINK_H