Links.h

00001 #ifndef CUSTOMHTML_LINKS_H
00002 #define CUSTOMHTML_LINKS_H
00003 
00004 /*
00005  * RebeccaAIML, Artificial Intelligence Markup Language 
00006  * C++ api and engine.
00007  *
00008  * Copyright (C) 2005,2006,2007 Frank Hassanabad
00009  *
00010  * This file is part of RebeccaAIML.
00011  *
00012  * RebeccaAIML is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation; either version 3 of the License, or
00015  * (at your option) any later version.
00016  *
00017  * RebeccaAIML is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00024  */
00025 
00026 
00027 //Std includes
00028 #include <string>
00029 #include <iostream>
00030 
00031 //Custom tags includes
00032 #include "sanitizeString.h"
00033 
00034 namespace customTag
00035 {
00036 namespace impl
00037 {
00038 
00039 using namespace std;
00040 
00046 class Links
00047 {
00048     public:
00055         void setUrl(const string &url)
00056         {
00057             m_url = url;
00058         }
00059         
00068         void setDisplayUrl(const string &displayUrl)
00069         {
00070             m_displayUrl = displayUrl;
00071         }
00077         string getUrl()
00078         {
00079             return m_url;
00080         }
00089         string getDisplayUrl()
00090         {
00091             return m_displayUrl;
00092         }
00093         
00111         string getHtmlLink()
00112         {
00113             /*
00114              * If the display url is not empty use
00115              * it otherwise use the template string
00116              * which isn't a link at all.  It's just
00117              * text
00118              */
00119             if(!m_displayUrl.empty())
00120             {
00121                 return string("<center><i><a href=\"" + sanitizeString(m_url) + ".html" + "\">" + m_displayUrl + "</a></i></center>");
00122             }
00123             else if(!m_templateString.empty())
00124             {
00125                 return string("<center>" + getTemplateString() + "</center>");
00126             }
00127             else
00128             {
00129                 cout << "Error neither displayUrl or TemplateString have been set" << endl;
00130                 return string();
00131             }
00132         }
00133         
00140         void setTemplateString(string templateString)
00141         {
00142             m_templateString = templateString;
00143         }
00144         
00151         string getTemplateString()
00152         {
00153             return m_templateString;
00154         }
00155 
00156     private:
00157 
00161         string m_url;
00162 
00168         string m_displayUrl;
00169 
00180         string m_templateString;
00181 };
00182 
00183 } //end of impl namespace
00184 } //end of customTag namespace
00185 
00186 
00187 #endif

Generated on Mon Aug 27 12:26:53 2007 for RebeccaAIML by  doxygen 1.5.3