CPPSERV


Home Projects Jobs Clientele Contact
CPPSERV Documentation Download TODO Mailing lists Bug tracker News RSS Feed Browse source

cspcontext.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007 by Ilya A. Volynets-Evenbakh                       *
00003  *   ilya@total-knowledge.com                                              *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #include <serverconfig/serverconfig.h>
00022 
00023 namespace container {
00024 namespace serverconfig {
00025 
00035 CSPContext::CSPContext(Context* parent, const std::string& path, const std::string& dso, bool hidden)
00036     : ServletContext(parent, path, dso, hidden)
00037 {
00038 }
00039 
00040 Context* CSPContext::contextCreator(const ConfigNode& n, Context* parent)
00041 {
00042     util::param_t::const_iterator dso = n.getAttrs().find("dso");
00043     if(dso == n.getAttrs().end())
00044         ServerConfig::fart("app=>servlets[]->dso");
00045     util::param_t::const_iterator ithidden = n.getAttrs().find("hidden");
00046     bool hidden = false;
00047     if(ithidden != n.getAttrs().end() && ithidden->second == "true")
00048         hidden = true;
00049     util::param_t::const_iterator pathit = n.getAttrs().find("path");
00050     std::string path;
00051     if(pathit != n.getAttrs().end())
00052         path = pathit->second;
00053     return new CSPContext(parent, path, dso->second, hidden);
00054 }
00055 
00056 std::string CSPContext::getServletName()
00057 {
00058     std::string name = getName();
00059         std::string class_name = "CspServlet";
00060         for(std::string::size_type i=0;i<name.size();++i){
00061             if(!::isalnum(name[i]))
00062                 class_name += '_';
00063             else
00064                 class_name += name[i];
00065         }
00066         return class_name;
00067 }
00068 
00069 }
00070 }

SourceForge.net Logo