OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
BESUtil.h
Go to the documentation of this file.
1 // BESUtil.h
2 
3 // This file is part of bes, A C++ back-end server implementation framework
4 // for the OPeNDAP Data Access Protocol.
5 
6 // Copyright (c) 2004-2009 University Corporation for Atmospheric Research
7 // Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu>
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 //
23 // You can contact University Corporation for Atmospheric Research at
24 // 3080 Center Green Drive, Boulder, CO 80301
25 
26 // (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
27 // Please read the full copyright statement in the file COPYRIGHT_UCAR.
28 //
29 // Authors:
30 // pwest Patrick West <pwest@ucar.edu>
31 // jgarcia Jose Garcia <jgarcia@ucar.edu>
32 
33 #ifndef E_BESUtil_h
34 #define E_BESUtil_h 1
35 
36 #include <string>
37 #include <list>
38 #include <iostream>
39 
40 using std::string ;
41 using std::list ;
42 using std::ostream ;
43 
44 class BESUtil
45 {
46 private:
47  static string rfc822_date( const time_t t ) ;
48 
49  static string entity( char c ) ;
50 public:
61  static void set_mime_text( ostream &strm ) ;
62  static void set_mime_html( ostream &strm ) ;
63 
65  static string www2id( const string &in,
66  const string &escape = "%",
67  const string &except = "" ) ;
68  static string unhexstring( string s ) ;
69 
71  static string lowercase( const string &s ) ;
72 
74  static string unescape( const string &s ) ;
75 
77  static void check_path( const string &path,
78  const string &root,
79  bool follow_sym_links ) ;
80 
82  static char * fastpidconverter( char *buf,
83  int base ) ;
84  static char * fastpidconverter( long val,
85  char *buf,
86  int base ) ;
87 
89  static void removeLeadingAndTrailingBlanks( string &key ) ;
90 
92  static string id2xml( string in,
93  const string &not_allowed = "><&'\"" ) ;
94 
96  static string xml2id( string in ) ;
97 
99  static void explode( char delim, const string &str,
100  list<string> &values ) ;
101 
103  static string implode( const list<string> &values,
104  char delim ) ;
105 
106  struct url
107  {
108  string protocol ;
109  string domain ;
110  string uname ;
111  string psswd ;
112  string port ;
113  string path ;
114  } ;
115 
116  static void url_explode( const string &url_str,
117  BESUtil::url &url_parts ) ;
118  static string url_create( BESUtil::url &url_parts ) ;
119 } ;
120 
121 #endif // E_BESUtil_h
122