escaping.cc File Reference

#include <ctype.h>
#include <iomanip>
#include <string>
#include <sstream>
#include "GNURegex.h"
#include "Error.h"
#include "InternalErr.h"
#include "debug.h"

Include dependency graph for escaping.cc:

Go to the source code of this file.

Functions

string esc2underscore (string s)
string escattr (string s)
string hexstring (unsigned char val)
string id2www (string in, const string &allowable)
string id2www_ce (string in, const string &allowable)
string id2xml (string in, const string &not_allowed)
string munge_error_message (string msg)
string octstring (unsigned char val)
string unescattr (string s)
string unhexstring (string s)
string unoctstring (string s)
string www2id (const string &in, const string &escape, const string &except)
string xml2id (string in)


Function Documentation

string esc2underscore ( string  s  ) 

Return a string that has all the %<hex digit><hex digit> sequences replaced with underscores (`_').

Parameters:
s The string to transform
Returns:
The modified string.

Definition at line 293 of file escaping.cc.

string escattr ( string  s  ) 

Escape non-printable characters and quotes from an HDF attribute.

Parameters:
s The attribute to modify.
Returns:
The modified attribute.

Definition at line 307 of file escaping.cc.

References octstring().

Referenced by Str::print_val().

Here is the call graph for this function:

string hexstring ( unsigned char  val  ) 

Definition at line 78 of file escaping.cc.

Referenced by id2www().

string id2www ( string  in,
const string &  allowable 
)

Replace characters that are not allowed in DAP2 identifiers.

-In the DAP itself, id2www() is called in:

  1. Array::print_decl() where dimension names are escaped
  2. AttrTable::print() (which calls AttrTable::simple_print()) where attribute names are escaped
  3. BaseType::print_decl() where variable names are escaped.
  4. Constructor::print_decl() where the name of the constructor type is printed.
  5. DDS::print() and DDS::print_constrained() where the name of the dataset is printed.
  6. Grid::print_decl() where the name of the grid is printed.

-In the client code:

  1. id2www_ce() is called five times in the five methods that are used to request responses where a CE is appended to a URL (Connect::request_version, request_protocol, request_das, request_dds, request_data).

Parameters:
in The string in which to replace characters.
allowable The set of characters that are allowed in a URI. default: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+_/.\\*"
See also:
id2www_ce()
Returns:
The modified identifier.

Definition at line 150 of file escaping.cc.

References hexstring().

Referenced by id2www_ce(), DDS::print(), AttrTable::print(), DDS::print_constrained(), Grid::print_decl(), Constructor::print_decl(), BaseType::print_decl(), Array::print_decl(), and AttrTable::simple_print().

Here is the call graph for this function:

string id2www_ce ( string  in,
const string &  allowable 
)

Replace characters that are not allowed in WWW URLs using rules specific to Constraint Expressions. This has canged over time and now the only difference is that '*' is escaped by this function while it is not escaped by id2www().

Parameters:
in The string in which to replace characters.
allowable The set of characters that are allowed in a URI. default: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+_/.\\"
See also:
id2www()
Returns:
The modified identifier.

Definition at line 173 of file escaping.cc.

References id2www().

Referenced by Connect::request_das(), Connect::request_data(), Connect::request_dds(), Connect::request_ddx(), Connect::request_protocol(), and Connect::request_version().

Here is the call graph for this function:

string id2xml ( string  in,
const string &  not_allowed 
)

Replace characters that are not allowed in XML

Parameters:
in The string in which to replace characters.
not_allowed The set of characters that are not allowed in XML. default: ><&'(single quote)"(double quote)
Returns:
The modified identifier.

Definition at line 243 of file escaping.cc.

Referenced by Grid::print_xml(), DDS::print_xml(), Constructor::print_xml(), BaseType::print_xml(), AttrTable::print_xml(), and Array::print_xml_core().

string munge_error_message ( string  msg  ) 

Definition at line 388 of file escaping.cc.

string octstring ( unsigned char  val  ) 

Definition at line 100 of file escaping.cc.

Referenced by escattr().

string unescattr ( string  s  ) 

Un-escape special characters, quotes and backslashes from an HDF attribute.

Note: A regex to match one \ must be defined as: Regex foo = "\\\\"; because both C++ strings and GNU's Regex also employ \ as an escape character!

Parameters:
s The escaped attribute.
Returns:
The unescaped attribute.

Definition at line 346 of file escaping.cc.

References DBG, and unoctstring().

Here is the call graph for this function:

string unhexstring ( string  s  ) 

Definition at line 88 of file escaping.cc.

Referenced by www2id().

string unoctstring ( string  s  ) 

Definition at line 110 of file escaping.cc.

References DBG.

Referenced by unescattr().

string www2id ( const string &  in,
const string &  escape,
const string &  except 
)

Given a string that contains WWW escape sequences, translate those escape sequences back into ASCII characters. Return the modified string.

-Places in the dap code where www2id() is called:

  1. Array::append_dim() the name is decoded before it is added
  2. AttrTable::set_name(), AttrTable::append_attr(), AttrTable::append_container(), AttrTable?del_attr(), AttrTable::add_container_alias(), AttrTable::add_value_alias() names are decoded before that are set/used.
  3. BaseType::set_name() Names are decoded before they are set
  4. When the constraint expression parser looks for a variable, the name is first decoded.
  5. DAS::DAS() Named attribute containers are decoded
  6. DDS::var() When a DDS searches for a variable, the name is first decoded.
  7. Grid::var(), Sequence::var(), Structure::var() Variable names are decoded.

-In the server code:

  1. DODSFilter::initialize() The dataset name is decoded except that 20 is not removed.
  2. DODSFilter::set_ce() The CE is decoded, except for spaces (20).
  3. DODSFilter::set_dataset_name() same logic as the first case.

Parameters:
in The string to modify.
escape The character used to signal the begining of an escape sequence. default: "%"
except If there is some escape code that should not be removed by this call (e.g., you might not want to remove spaces, 20) use this parameter to specify that code. The function will then transform all escapes except that one. default: ""
Returns:
The modified string.

Definition at line 207 of file escaping.cc.

References unhexstring().

Referenced by AttrTable::add_container_alias(), AttrTable::add_value_alias(), AttrTable::append_attr(), AttrTable::append_container(), Array::append_dim(), DAS::DAS(), AttrTable::del_attr(), DODSFilter::initialize(), DODSFilter::set_ce(), DODSFilter::set_dataset_name(), BaseType::set_name(), AttrTable::set_name(), Vector::var(), Structure::var(), Sequence::var(), Grid::var(), and DDS::var().

Here is the call graph for this function:

string xml2id ( string  in  ) 

Given a string that contains XML escape sequences (i.e., entities), translate those back into ASCII characters. Return the modified string.

Parameters:
in The string to modify.
Returns:
The modified string.

Definition at line 261 of file escaping.cc.


Generated on Wed Jun 27 12:56:54 2007 for libdap++ by  doxygen 1.4.7