40 #include "TheBESKeys.h"
41 #include "BESInternalError.h"
45 #define BES_INFO_FILE_BUFFER_SIZE 4096
53 _strm(0), _strm_owned(false), _buffered(true), _response_started(false)
55 _strm =
new ostringstream;
73 _strm(0), _strm_owned(false), _buffered(true), _response_started(false), _response_name(
"")
76 vector < string > vals;
79 if (b ==
"true" || b ==
"True" || b ==
"TRUE" || b ==
"yes" || b ==
"Yes" || b ==
"YES") {
80 _strm =
new ostringstream;
83 if (strm && strm_owned)
delete strm;
87 string s =
"Informational response not buffered but no stream passed";
91 _strm_owned = strm_owned;
98 if (_strm && _strm_owned) {
113 _response_started =
true;
114 _response_name = response_name;
126 _response_started =
true;
127 _response_name = response_name;
130 void BESInfo::end_response()
132 _response_started =
false;
134 string s =
"Not all tags were ended in info response";
139 void BESInfo::begin_tag(
const string &tag_name, map<string, string> *)
141 _tags.push(tag_name);
144 void BESInfo::end_tag(
const string &tag_name)
146 if (_tags.size() == 0 || _tags.top() != tag_name) {
147 string s = (string)
"tag " + tag_name +
" already ended or not started";
192 if (found ==
false) {
193 add_data(name +
" file key " + key +
" not found, information not available\n");
196 ifstream ifs(file.c_str());
199 string serr = name +
" file " + file +
" not found, information not available: ";
200 char *err = strerror(myerrno);
204 serr +=
"Unknown error";
211 char line[BES_INFO_FILE_BUFFER_SIZE];
213 ifs.getline(line, BES_INFO_FILE_BUFFER_SIZE);
236 begin_tag(
"BESError");
239 add_tag(
"Type", stype.str());
241 add_tag(
"Administrator", admin);
243 begin_tag(
"Location" );
247 add_tag(
"Line", sline.str() );
248 end_tag(
"Location" );
264 strm << ((ostringstream *) _strm)->str();
277 strm << BESIndent::LMarg <<
"BESInfo::dump - (" << (
void *)
this <<
")" << endl;
279 strm << BESIndent::LMarg <<
"response name: " << _response_name << endl;
280 strm << BESIndent::LMarg <<
"is it buffered? " << _buffered << endl;
281 strm << BESIndent::LMarg <<
"has response been started? " << _response_started << endl;
283 strm << BESIndent::LMarg <<
"tags:" << endl;
285 stack < string > temp_tags = _tags;
286 while (!temp_tags.empty()) {
287 string tag = temp_tags.top();
288 strm << BESIndent::LMarg << tag << endl;
291 BESIndent::UnIndent();
294 strm << BESIndent::LMarg <<
"tags: empty" << endl;
296 BESIndent::UnIndent();