39 using std::ostringstream;
46 #define BES_INFO_FILE_BUFFER_SIZE 4096
54 _strm(0), _strm_owned(false), _buffered(true), _response_started(false)
56 _strm =
new ostringstream;
74 _strm(0), _strm_owned(false), _buffered(true)
77 vector < string > vals;
80 if (b ==
"true" || b ==
"True" || b ==
"TRUE" || b ==
"yes" || b ==
"Yes" || b ==
"YES") {
81 _strm =
new ostringstream;
84 if (strm && strm_owned)
delete strm;
88 string s =
"Informational response not buffered but no stream passed";
122 string s =
"Not all tags were ended in info response";
129 _tags.push(tag_name);
134 if (
_tags.size() == 0 ||
_tags.top() != tag_name) {
135 string s = (string)
"tag " + tag_name +
" already ended or not started";
180 if (found ==
false) {
181 add_data(name +
" file key " + key +
" not found, information not available\n");
184 ifstream ifs(file.c_str());
187 string serr = name +
" file " + file +
" not found, information not available: ";
188 char *err = strerror(myerrno);
192 serr +=
"Unknown error";
229 add_tag(
"Administrator", admin);
235 add_tag(
"Line", sline.str() );
252 strm << ((ostringstream *)
_strm)->str();
265 strm <<
BESIndent::LMarg <<
"BESInfo::dump - (" << (
void *)
this <<
")" << endl;
273 stack < string > temp_tags =
_tags;
274 while (!temp_tags.empty()) {
275 string tag = temp_tags.top();
virtual void end_response()
exception thrown if inernal error encountered
virtual void add_data_from_file(const string &key, const string &name)
add data from a file to the informational object.
BESInfo()
constructs a BESInfo object
virtual void add_tag(const string &tag_name, const string &tag_data, map< string, string > *attrs=0)=0
virtual void dump(ostream &strm) const
Displays debug information about this object.
virtual int get_error_type()
Return the return code for this error class.
virtual string get_file()
get the file name where the exception was thrown
virtual string get_message()
get the error message for this exception
Abstract exception class for the BES with basic string message.
virtual void add_exception(BESError &e, const string &admin)
add exception information to this informational object
virtual void begin_tag(const string &tag_name, map< string, string > *attrs=0)
static ostream & LMarg(ostream &strm)
void get_value(const string &s, string &val, bool &found)
Retrieve the value of a given key, if set.
Structure storing information used by the BES to handle the request.
#define BES_INFO_FILE_BUFFER_SIZE
virtual void begin_response(const string &response_name, BESDataHandlerInterface &dhi)
begin the informational response
virtual void add_data(const string &s)
add data to this informational object.
virtual void print(ostream &strm)
print the information from this informational object to the specified stream
static BESKeys * TheKeys()
virtual void end_tag(const string &tag_name)
virtual int get_line()
get the line number where the exception was thrown