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

Go to the SVN repository for this file.

1 #ifndef REF_ARGS__HPP
2 #define REF_ARGS__HPP
3 
4 /* $Id: ref_args.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: Aleksey Grichenko
30 *
31 * File Description:
32 * NCBI C++ CGI API:
33 * Referrer args - extract query string from HTTP referrers
34 */
35 
36 #include <corelib/ncbistd.hpp>
37 #include <map>
38 
39 /** @addtogroup CGIReqRes
40  *
41  * @{
42  */
43 
44 
46 
47 ////////////////////////////////////////////////////////
48 ///
49 /// CRefArgs::
50 ///
51 /// Extract query string from HTTP referrers
52 ///
53 
55 {
56 public:
57  /// Create referrer parser from a set of definitions.
58  /// @param definitions
59  /// Multiple definitions should be separated by new line ('\n').
60  /// Host mask should be followed by space(s).
61  /// Multiple argument names should be separated with commas.
62  /// E.g. ".google. q, query\n.foo. bar".
63  CRefArgs(const string& definitions = kEmptyStr);
64  ~CRefArgs(void);
65 
66  /// Add mappings between host mask and CGI argument name for query string.
67  /// @sa CRefArgs::CRefArgs
68  void AddDefinitions(const string& definitions);
69  void AddDefinitions(const string& host_mask, const string& arg_names);
70 
71  /// Find query string in the referrer.
72  /// @param referrer
73  /// Full HTTP referrer
74  /// @return
75  /// Query string assigned to one of the names associated with the host
76  /// in the referrer or empty string.
77  string GetQueryString(const string& referrer) const;
78 
79  /// Get default set of search engine definitions.
80  static string GetDefaultDefinitions(void);
81 
82  /// Check if the host from the referrer string is listed in definitions.
83  bool IsListedHost(const string& referrer) const;
84 
85 private:
87 
89 };
90 
91 
93 
94 #endif /* REF_ARGS__HPP */
CRefArgs::
Definition: ref_args.hpp:55
Include a standard set of the NCBI C++ Toolkit most basic headers.
multimap< string, string > THostMap
Definition: ref_args.hpp:86
THostMap m_HostMap
Definition: ref_args.hpp:88
string GetQueryString(EAmpEncoding amp_enc, EUrlEncode encode) const
Definition: cgi_util.hpp:112
#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 kEmptyStr
Definition: ncbistr.hpp:123
#define NCBI_XCGI_EXPORT
Definition: ncbi_export.h:1097
Modified on Wed Jul 24 17:22:20 2024 by modify_doxy.py rev. 669887