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:
60  static void set_mime_text( ostream &strm ) ;
61  static void set_mime_html( ostream &strm ) ;
62 
64  static string www2id( const string &in,
65  const string &escape = "%",
66  const string &except = "" ) ;
67  static string unhexstring( string s ) ;
68 
70  static string lowercase( const string &s ) ;
71 
73  static string unescape( const string &s ) ;
74 
76  static void check_path( const string &path,
77  const string &root,
78  bool follow_sym_links ) ;
79 
81  static char * fastpidconverter( char *buf,
82  int base ) ;
83  static char * fastpidconverter( long val,
84  char *buf,
85  int base ) ;
86 
88  static void removeLeadingAndTrailingBlanks( string &key ) ;
89 
91  static string id2xml( string in,
92  const string &not_allowed = "><&'\"" ) ;
93 
95  static string xml2id( string in ) ;
96 
98  static void explode( char delim, const string &str,
99  list<string> &values ) ;
100 
102  static string implode( const list<string> &values,
103  char delim ) ;
104 } ;
105 
106 #endif // E_BESUtil_h
107 
static string lowercase(const string &s)
Convert a string to all lower case.
Definition: BESUtil.cc:190
static string www2id(const string &in, const string &escape="%", const string &except="")
This functions are used to unescape hex characters from strings.
Definition: BESUtil.cc:174
static void removeLeadingAndTrailingBlanks(string &key)
remove leading and trailing blanks from a string
Definition: BESUtil.cc:417
static string implode(const list< string > &values, char delim)
implode a list of values into a single string delimited by delim
Definition: BESUtil.cc:606
static string xml2id(string in)
unescape xml escaped characters
Definition: BESUtil.cc:473
static void set_mime_html(ostream &strm)
Generate an HTTP 1.0 response header for a html document.
Definition: BESUtil.cc:85
static void explode(char delim, const string &str, list< string > &values)
explode a string into an array given a delimiter
Definition: BESUtil.cc:513
static void set_mime_text(ostream &strm)
Generate an HTTP 1.0 response header for a text document.
Definition: BESUtil.cc:65
static string unhexstring(string s)
Definition: BESUtil.cc:160
static string id2xml(string in, const string &not_allowed="><&'\)
convert characters not allowed in xml to escaped characters
Definition: BESUtil.cc:454
static char * fastpidconverter(char *buf, int base)
convert pid and place in provided buffer
Definition: BESUtil.cc:383
static string unescape(const string &s)
Unescape characters with backslash before them.
Definition: BESUtil.cc:202
static void check_path(const string &path, const string &root, bool follow_sym_links)
Check if the specified path is valid.
Definition: BESUtil.cc:249