libdap Updated for version 3.21.1
libdap4 is an implementation of OPeNDAP's DAP protocol.
escaping.h
Go to the documentation of this file.
1
2// -*- mode: c++; c-basic-offset:4 -*-
3
4// This file is part of libdap, A C++ implementation of the OPeNDAP Data
5// Access Protocol.
6
7// Copyright (c) 2002,2003 OPeNDAP, Inc.
8// Author: James Gallagher <jgallagher@opendap.org>
9//
10// This library is free software; you can redistribute it and/or
11// modify it under the terms of the GNU Lesser General Public
12// License as published by the Free Software Foundation; either
13// version 2.1 of the License, or (at your option) any later version.
14//
15// This library is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18// Lesser General Public License for more details.
19//
20// You should have received a copy of the GNU Lesser General Public
21// License along with this library; if not, write to the Free Software
22// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23//
24// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25
26// (c) COPYRIGHT URI/MIT 1999
27// Please read the full copyright statement in the file COPYRIGHT_URI.
28//
29// Authors:
30// jhrg,jimg James Gallagher <jgallagher@gso.uri.edu>
31
32// Declarations for identifier escaping and un-escaping functions.
33
34#ifndef _escaping_h
35#define _escaping_h
36
37#include <string>
38
39using std::string;
40
41namespace libdap {
42
43string hexstring(unsigned char val);
44string unhexstring(string s);
45string octstring(unsigned char val);
46string unoctstring(string s);
47
48// The original set of allowed characters was: [0-9a-zA-Z_%]
49// The characters accepted in DAP2 ids: [-+a-zA-Z0-9_/%.\\#*]; everything
50// else must be escaped. Note that for some inscrutable reason, we've been
51// escaping '*'.
52
53// The characters allowable in an id in a URI (see RFC 2396):
54// [-A-Za-z0-9_.!~*'()].
55
56string id2www(string s,
57 const string &allowable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+_/.\\*");
58
59// This is what DAP2 allows in a ce: [-+a-zA-Z0-9_/%.\\#]
60string id2www_ce(string s,
61 const string &allowable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+_/.\\");
62
63string www2id(const string &in, const string &escape = "%", const string &except = "");
64
65// Include these for compatibility with the old names. 7/19/2001 jhrg
66#define id2dods id2www
67#define dods2id www2id
68
69string octal_to_hex(const string &octal_digits);
70
71string id2xml(string in, const string &not_allowed = "><&'\"");
72string xml2id(string in);
73
74string esc2underscore(string s);
75string char2ASCII(string s, const string escape = "%[0-7][0-9a-fA-F]");
76string escattr(string s);
77string escattr_xml(string s);
78string unescattr(string s);
79
80string munge_error_message(string msg);
81
82string unescape_double_quotes(string source);
83string escape_double_quotes(string source);
84
85} // namespace libdap
86
87#endif // _escaping_h
top level DAP object to house generic methods
Definition AISConnect.cc:30
string char2ASCII(string s, const string escape="%[0-7][0-9a-fA-F]")
string esc2underscore(string s)
Definition escaping.cc:331
string escattr(string s)
Definition escaping.cc:342
string escattr_xml(string s)
Definition escaping.cc:375
string www2id(const string &in, const string &escape, const string &except)
Definition escaping.cc:202
string unescape_double_quotes(string source)
Definition escaping.cc:481
string hexstring(unsigned char val)
Definition escaping.cc:81
string octstring(unsigned char val)
Definition escaping.cc:98
string xml2id(string in)
Definition escaping.cc:301
string octal_to_hex(const string &octal_digits)
Definition escaping.cc:236
string id2xml(string in, const string &not_allowed)
Definition escaping.cc:253
string unescattr(string s)
Definition escaping.cc:407
string munge_error_message(string msg)
Definition escaping.cc:446
string unhexstring(string s)
Definition escaping.cc:88
string escape_double_quotes(string source)
Definition escaping.cc:466
string id2www_ce(string in, const string &allowable)
Definition escaping.cc:166
string unoctstring(string s)
Definition escaping.cc:105
string id2www(string in, const string &allowable)
Definition escaping.cc:143