NCBI C++ ToolKit
redirect.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef MISC___CGI_REDIRECT__REDIRECT__HPP
2 #define MISC___CGI_REDIRECT__REDIRECT__HPP
3 
4 /* $Id: redirect.hpp 33815 2007-05-04 17:18:18Z kazimird $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Author: Vladimir Ivanov
30  *
31  *
32  */
33 
34 /// @cgi_redirect.hpp
35 /// Define class CCgiRedirectApplication used to redirect CGI requests.
36 
37 #include <cgi/cgiapp.hpp>
38 #include <html/page.hpp>
39 
40 /** @addtogroup CGIBase
41  *
42  * @{
43  */
44 
45 
47 
48 
49 /////////////////////////////////////////////////////////////////////////////
50 ///
51 /// CCgiRedirectApplication --
52 ///
53 /// Defines class for CGI redirection.
54 ///
55 /// CCgiRedirectApplication inherits its basic functionality from
56 /// CCgiApplication and defines additional method for remapping CGI entries.
57 ///
58 /// The CCgiRedirectApplication class uses registry file to get settings,
59 /// and rules to entries changing.
60 ///
61 /// Class map some registry entries to HTML page tags.
62 /// The list of mapped tags:
63 ///
64 /// _TITLE_ - Page title;
65 /// _HEADER_ - Main header;
66 /// _MESSAGE_ - Some additional message;
67 /// _BASEURL_ - New base URL to redirect to;
68 /// _URL_ - Full new URL with all parameters;
69 /// _TIMER_ - Wait time (in seconds) before redirecting
70 /// (if this feature is implemented by template).
71 ///
72 /// Also, all CGI variables will be mapped with its names.
73 /// So they can be used inside HTML forms to redirect requests by
74 /// GET/POST methods.
75 ///
76 /// For an explanation of the syntax of the Registry file, see the
77 /// C++ Toolkit documentation.
78 ///
79 /// For an examples of the registry and template files, see
80 /// directory "/src/misc/cgi_redirect". It also contains standart
81 /// CGI redirect application.
82 
84 {
86 public:
87  virtual void Init(void);
88  virtual int ProcessRequest(CCgiContext& ctx);
89 
90 public:
91  /// Remap CGI entries for the redirection.
92  ///
93  /// This default implementation uses registry file to obtain rules for
94  /// the entries' remapping (see details in this class's description)
95  /// New entries will be placed into "new_entries" according to these rules.
96  /// If there is no rule defined for an entry, then the entry will be copied
97  /// to "new_entries" as is, unchanged.
98  ///
99  /// @param ctx
100  /// Current CGI context.
101  /// Can be used to get original entries and server context.
102  /// @param new_entries
103  /// Storage for the new, remapped CGI entries. Initially, it is empty,
104  /// and this method should fill it up. These entries will then be used
105  /// instead of original entries to generate request(URL) for the redirection.
106  /// @return
107  /// Reference to "new_entries" parameter.
108  /// @sa
109  /// ProcessRequest()
110  virtual TCgiEntries& RemapEntries(CCgiContext& ctx, TCgiEntries& new_entries);
111 
112 protected:
113  const CHTMLPage& GetPage(void) const;
115 
116 private:
117  CHTMLPage m_Page; ///< HTML page used to send back the redirect information.
118 };
119 
120 
122 
123 
124 /* @} */
125 
126 #endif // MISC___CGI_REDIRECT__REDIRECT__HPP
CCgiRedirectApplication –.
Definition: redirect.hpp:84
CHTMLPage –.
Definition: page.hpp:161
CS_CONTEXT * ctx
Definition: t0006.c:12
virtual void Init(void)
This method is called on the CGI application initialization – before starting to process a HTTP reque...
Definition: cgiapp.cpp:864
CCgiApplication CParent
Definition: redirect.hpp:85
CHTMLPage & GetPage(void)
const CHTMLPage & GetPage(void) const
CHTMLPage m_Page
HTML page used to send back the redirect information.
Definition: redirect.hpp:117
virtual int ProcessRequest(CCgiContext &context)=0
This is the method you should override.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_XCGI_REDIRECT_EXPORT
Definition: ncbi_export.h:1113
The HTML page.
Modified on Fri Sep 20 14:57:29 2024 by modify_doxy.py rev. 669887