bes  Updated for version 3.19.1
BESUtil.h
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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  static string assemblePath(const string &firstPart, const string &secondPart, bool addLeadingSlash = false);
120 
121  static bool endsWith(std::string const &fullString, std::string const &ending);
122  static void conditional_timeout_cancel();
123 
124 } ;
125 
126 #endif // E_BESUtil_h
127 
static string id2xml(string in, const string &not_allowed="><&'\"")
Definition: BESUtil.cc:489
static string lowercase(const string &s)
Definition: BESUtil.cc:189
static void conditional_timeout_cancel()
Definition: BESUtil.cc:878
static string www2id(const string &in, const string &escape="%", const string &except="")
Definition: BESUtil.cc:174
static void removeLeadingAndTrailingBlanks(string &key)
Definition: BESUtil.cc:450
static string assemblePath(const string &firstPart, const string &secondPart, bool addLeadingSlash=false)
Assemble path fragments making sure that they are separated by a single '/' character.
Definition: BESUtil.cc:757
static string implode(const list< string > &values, char delim)
Definition: BESUtil.cc:622
static string xml2id(string in)
Definition: BESUtil.cc:506
static void set_mime_html(ostream &strm)
Generate an HTTP 1.0 response header for a html document.
Definition: BESUtil.cc:91
static void explode(char delim, const string &str, list< string > &values)
Definition: BESUtil.cc:545
static void set_mime_text(ostream &strm)
Generate an HTTP 1.0 response header for a text document.
Definition: BESUtil.cc:72
static void url_explode(const string &url_str, BESUtil::url &url_parts)
Given a url, break the url into its different parts.
Definition: BESUtil.cc:662
static bool endsWith(std::string const &fullString, std::string const &ending)
Definition: BESUtil.cc:852
static char * fastpidconverter(char *buf, int base)
Definition: BESUtil.cc:420
static string unescape(const string &s)
Definition: BESUtil.cc:199
static void check_path(const string &path, const string &root, bool follow_sym_links)
Definition: BESUtil.cc:242