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 Frank Hassanabad
00009  *
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2.1 of the License, or (at your option) any later version.
00014  *
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Lesser General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00023  */
00024 
00025 
00026 //Std includes
00027 #include <string>
00028 #include <iostream>
00029 
00030 //Boost includes
00031 #include <boost/algorithm/string.hpp>
00032 
00033 //Custom tags includes
00034 #include "sanitizeString.h"
00035 
00036 namespace customTag
00037 {
00038 namespace impl
00039 {
00040 
00041 using namespace std;
00042 using namespace boost;
00043 
00049 class Links
00050 {
00051     public:
00058         void setUrl(const string &url)
00059         {
00060             m_url = url;
00061         }
00062         
00071         void setDisplayUrl(const string &displayUrl)
00072         {
00073             m_displayUrl = displayUrl;
00074         }
00080         string getUrl()
00081         {
00082             return m_url;
00083         }
00092         string getDisplayUrl()
00093         {
00094             return m_displayUrl;
00095         }
00096         
00114         string getHtmlLink()
00115         {
00116             /*
00117              * If the display url is not empty use
00118              * it otherwise use the template string
00119              * which isn't a link at all.  It's just
00120              * text
00121              */
00122             if(!m_displayUrl.empty())
00123             {
00124                 return string("<center><i><a href=\"" + sanitizeString(m_url) + ".html" + "\">" + m_displayUrl + "</a></i></center>");
00125             }
00126             else if(!m_templateString.empty())
00127             {
00128                 return string("<center>" + getTemplateString() + "</center>");
00129             }
00130             else
00131             {
00132                 cout << "Error neither displayUrl or TemplateString have been set" << endl;
00133                 return string();
00134             }
00135         }
00136         
00143         void setTemplateString(string templateString)
00144         {
00145             m_templateString = templateString;
00146         }
00147         
00154         string getTemplateString()
00155         {
00156             return m_templateString;
00157         }
00158 
00159     private:
00160 
00164         string m_url;
00165 
00171         string m_displayUrl;
00172 
00183         string m_templateString;
00184 };
00185 
00186 } //end of impl namespace
00187 } //end of customTag namespace
00188 
00189 
00190 #endif

Generated on Tue Apr 4 23:38:57 2006 for RebeccaAIML by  doxygen 1.4.5