bes  Updated for version 3.17.4
BESUtil Class Reference

Classes

struct  url
 

Static Public Member Functions

MIME utility functions

These functions are used to create the MIME headers for a message from a server to a client.

NB: These functions actually write both the response status line and the header.

See also
libdap::escaping.cc
libdap::mime_util.cc
static void set_mime_text (ostream &strm)
 Generate an HTTP 1.0 response header for a text document. More...
 
static void set_mime_html (ostream &strm)
 Generate an HTTP 1.0 response header for a html document. More...
 
static string www2id (const string &in, const string &escape="%", const string &except="")
 
static string unhexstring (string s)
 
static string lowercase (const string &s)
 
static string unescape (const string &s)
 
static void check_path (const string &path, const string &root, bool follow_sym_links)
 
static char * fastpidconverter (char *buf, int base)
 
static char * fastpidconverter (long val, char *buf, int base)
 
static void removeLeadingAndTrailingBlanks (string &key)
 
static string id2xml (string in, const string &not_allowed="><&'\)
 
static string xml2id (string in)
 
static void explode (char delim, const string &str, list< string > &values)
 
static string implode (const list< string > &values, char delim)
 
static void url_explode (const string &url_str, BESUtil::url &url_parts)
 Given a url, break the url into its different parts. More...
 
static string url_create (BESUtil::url &url_parts)
 
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. More...
 
static bool endsWith (std::string const &fullString, std::string const &ending)
 

Detailed Description

Definition at line 44 of file BESUtil.h.

Member Function Documentation

◆ assemblePath()

string BESUtil::assemblePath ( const string &  firstPart,
const string &  secondPart,
bool  ensureLeadingSlash = false 
)
static

If the parameter ensureLeadingSlash is true then the returned string will begin with a single '/' character followed by the string firstPart, a single '/' character, and the string secondPart.

Note
I replaced the code here with a simpler version that assumes the two string arguments do not contain multiple consecutive slashes - I don't think the original version will work in cases where the string is only slashes because it will dereference the return value of begin()

Definition at line 754 of file BESUtil.cc.

◆ check_path()

void BESUtil::check_path ( const string &  path,
const string &  root,
bool  follow_sym_links 
)
static

Check if the specified path is valid

Check if the specified path is valid

Checks to see if the specified path is a valid path or not. The root directory specified is assumed to be valid, so we don't check that part of the path. The path parameter is relative to the root directory.

If follow_sym_links is false, then if any part of the specified path is a symbolic link, this function will return false, set the passed has_sym_link parameter. No error message is specified.

If there is a problem accessing the specified path then the error string will be filled with whatever system error message is provided.

param path path to check param root root directory path, assumed to be valid param follow_sym_links specifies whether allowed to follow symbolic links throws BESForbiddenError if the user is not allowed to traverse the path throws BESNotFoundError if there is a problem accessing the path or the path does not exist.

Definition at line 239 of file BESUtil.cc.

◆ endsWith()

bool BESUtil::endsWith ( std::string const &  fullString,
std::string const &  ending 
)
static

Returns true if (the value of) 'fullString' ends with (the value of) 'ending', false otherwise.

Definition at line 849 of file BESUtil.cc.

◆ explode()

void BESUtil::explode ( char  delim,
const string &  str,
list< string > &  values 
)
static

explode a string into an array given a delimiter

Given a string of values separated by a delimiter, break out the values and store in the list.

Quoted values must be escaped.

If values contain the delimiter then the value must be wrapped in quotes.

Parameters
delimdelimiter separating the values
strthe original string
valueslist of the delimited values returned to caller
Exceptions
BESInternalErrorif missing ending quote or delimiter does not follow end quote

Definition at line 542 of file BESUtil.cc.

◆ fastpidconverter()

char * BESUtil::fastpidconverter ( char *  buf,
int  base 
)
static

convert pid and place in provided buffer

Definition at line 417 of file BESUtil.cc.

◆ id2xml()

string BESUtil::id2xml ( string  in,
const string &  not_allowed = "><&'\"" 
)
static

convert characters not allowed in xml to escaped characters

Replace characters that are not allowed in XML

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

Definition at line 486 of file BESUtil.cc.

◆ implode()

string BESUtil::implode ( const list< string > &  values,
char  delim 
)
static

implode a list of values into a single string delimited by delim

Given a list of string values create a single string of values delimited by delim

If the delimiter exists in a value in the list then that value must be enclosed in quotes

Parameters
valueslist of string values to implode
delimthe delimiter to use in creating the resulting string
Returns
the delim delimited string of values

Definition at line 619 of file BESUtil.cc.

◆ lowercase()

string BESUtil::lowercase ( const string &  s)
static

Convert a string to all lower case

Definition at line 186 of file BESUtil.cc.

◆ removeLeadingAndTrailingBlanks()

void BESUtil::removeLeadingAndTrailingBlanks ( string &  key)
static

remove leading and trailing blanks from a string

Definition at line 447 of file BESUtil.cc.

◆ set_mime_html()

void BESUtil::set_mime_html ( ostream &  strm)
static
Parameters
strmWrite the MIME header to this ostream.

Definition at line 88 of file BESUtil.cc.

◆ set_mime_text()

void BESUtil::set_mime_text ( ostream &  strm)
static
Parameters
strmWrite the MIME header to this ostream.

Definition at line 69 of file BESUtil.cc.

◆ unescape()

string BESUtil::unescape ( const string &  s)
static

Unescape characters with backslash before them

Definition at line 196 of file BESUtil.cc.

◆ url_explode()

void BESUtil::url_explode ( const string &  url_str,
BESUtil::url url_parts 
)
static

The different parts are the protocol, the domain name, a username if specified, a password if specified, a port if specified, and a path if specified.

struct url { string protocol ; string domain ; string uname ; string psswd ; string port ; string path ; } ;

Parameters
urlstring representation of the URL

Definition at line 659 of file BESUtil.cc.

◆ www2id()

string BESUtil::www2id ( const string &  in,
const string &  escape = "%",
const string &  except = "" 
)
static

This functions are used to unescape hex characters from strings

Definition at line 171 of file BESUtil.cc.

◆ xml2id()

string BESUtil::xml2id ( string  in)
static

unescape xml escaped characters

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

Parameters
inThe string to modify.
Returns
The modified string.

Definition at line 503 of file BESUtil.cc.


The documentation for this class was generated from the following files: