CppCMS
cppcms/url_mapper.h
00001 
00002 //                                                                             
00003 //  Copyright (C) 2008-2012  Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>     
00004 //                                                                             
00005 //  See accompanying file COPYING.TXT file for licensing details.
00006 //
00008 #ifndef CPPCMS_URL_MAPPER_H
00009 #define CPPCMS_URL_MAPPER_H
00010 
00011 #include <cppcms/defs.h>
00012 #include <cppcms/string_key.h>
00013 #include <booster/noncopyable.h>
00014 #include <booster/hold_ptr.h>
00015 #include <cppcms/filters.h>
00016 #include <string>
00017 #include <vector>
00018 
00019 
00020 namespace cppcms {
00021         class application;
00022 
00149         class CPPCMS_API url_mapper : public booster::noncopyable {
00150         public:
00152                 url_mapper(application *app);
00153                 ~url_mapper();
00155                 
00161                 std::string root();
00167                 void root(std::string const &r);
00168 
00199                 void assign(std::string const &key,std::string const &url);
00204                 void assign(std::string const &url);
00205 
00213                 void set_value(std::string const &key,std::string const &value);
00220                 void clear_value(std::string const &key);
00221         
00225                 void map(       std::ostream &out,
00226                                 char const *path);
00227 
00231                 void map(       std::ostream &out,
00232                                 char const *path,
00233                                 filters::streamable const &p1);
00234 
00238                 void map(       std::ostream &out,
00239                                 char const *path,
00240                                 filters::streamable const &p1,
00241                                 filters::streamable const &p2);
00242 
00246                 void map(       std::ostream &out,
00247                                 char const *path,
00248                                 filters::streamable const &p1,
00249                                 filters::streamable const &p2,
00250                                 filters::streamable const &p3);
00251 
00255                 void map(       std::ostream &out,
00256                                 char const *path,
00257                                 filters::streamable const &p1,
00258                                 filters::streamable const &p2,
00259                                 filters::streamable const &p3,
00260                                 filters::streamable const &p4);
00264                 void map(       std::ostream &out,
00265                                 char const *path,
00266                                 filters::streamable const &p1,
00267                                 filters::streamable const &p2,
00268                                 filters::streamable const &p3,
00269                                 filters::streamable const &p4,
00270                                 filters::streamable const &p5);
00274                 void map(       std::ostream &out,
00275                                 char const *path,
00276                                 filters::streamable const &p1,
00277                                 filters::streamable const &p2,
00278                                 filters::streamable const &p3,
00279                                 filters::streamable const &p4,
00280                                 filters::streamable const &p5,
00281                                 filters::streamable const &p6);
00285                 void map(       std::ostream &out,
00286                                 std::string const &path);
00287 
00291                 void map(       std::ostream &out,
00292                                 std::string const &path,
00293                                 filters::streamable const &p1);
00294 
00298                 void map(       std::ostream &out,
00299                                 std::string const &path,
00300                                 filters::streamable const &p1,
00301                                 filters::streamable const &p2);
00302 
00306                 void map(       std::ostream &out,
00307                                 std::string const &path,
00308                                 filters::streamable const &p1,
00309                                 filters::streamable const &p2,
00310                                 filters::streamable const &p3);
00311 
00315                 void map(       std::ostream &out,
00316                                 std::string const &path,
00317                                 filters::streamable const &p1,
00318                                 filters::streamable const &p2,
00319                                 filters::streamable const &p3,
00320                                 filters::streamable const &p4);
00324                 void map(       std::ostream &out,
00325                                 std::string const &path,
00326                                 filters::streamable const &p1,
00327                                 filters::streamable const &p2,
00328                                 filters::streamable const &p3,
00329                                 filters::streamable const &p4,
00330                                 filters::streamable const &p5);
00334                 void map(       std::ostream &out,
00335                                 std::string const &path,
00336                                 filters::streamable const &p1,
00337                                 filters::streamable const &p2,
00338                                 filters::streamable const &p3,
00339                                 filters::streamable const &p4,
00340                                 filters::streamable const &p5,
00341                                 filters::streamable const &p6);
00342 
00350                 void mount(std::string const &name,std::string const &url,application &app);
00354                 url_mapper &child(std::string const &name);
00355 
00359                 url_mapper &parent();
00363                 url_mapper &topmost();
00364 
00365         private:
00366                 void real_assign(std::string const &key,std::string const &url,application *child = 0);
00367                 url_mapper &get_mapper_for_key(string_key const &key,string_key &real_key,std::vector<string_key> &direct);
00368                 url_mapper *root_mapper();
00369                 void real_map(  char const *key,
00370                                 filters::streamable const *const *params,
00371                                 size_t params_no,
00372                                 std::ostream &output);
00373 
00374                 struct data;
00375                 booster::hold_ptr<data> d;
00376         };
00377 
00378 };
00379 
00380 #endif