37using std::ostringstream;
43#include "BESTextInfo.h"
56 BESInfo(), _ishttp(ishttp), _header(false)
80 BESInfo(key, strm, strm_owned), _ishttp(ishttp), _header(false)
84BESTextInfo::~BESTextInfo()
106void BESTextInfo::add_tag(
const string &tag_name,
const string &tag_data, map<
string,
string, std::less<>> *attrs)
108 add_data(_indent + tag_name +
": " + tag_data +
"\n");
112 for (; i != e; i++) {
113 string name = (*i).first;
114 string val = (*i).second;
115 add_data(_indent +
" " + name +
": " + val +
"\n");
127 BESInfo::begin_tag(tag_name);
128 add_data(_indent + tag_name +
"\n");
133 for (; i != e; i++) {
134 string name = (*i).first;
135 string val = (*i).second;
136 add_data(_indent + name +
": " + val +
"\n");
149 BESInfo::end_tag(tag_name);
150 if (_indent.size() >= 4) _indent = _indent.substr(0, _indent.size() - 4);
159 if (_ishttp && !_header && !_buffered) {
173 for (
unsigned long i = 0; i < num_spaces; i++) {
186 for (
unsigned long i = 0; i < num_breaks; i++) {
202 string newkey = key +
".TXT";
216 transmitter->send_text(*
this, dhi);
228 strm << BESIndent::LMarg <<
"BESTextInfo::dump - (" << (
void *)
this <<
")" << endl;
230 strm << BESIndent::LMarg <<
"has header been added? " << _header << endl;
231 strm << BESIndent::LMarg <<
"indentation \"" << _indent <<
"\"" << endl;
232 strm << BESIndent::LMarg <<
"is http? " << _ishttp << endl;
234 BESIndent::UnIndent();
238BESTextInfo::BuildTextInfo(
const string &)
Structure storing information used by the BES to handle the request.
informational response object
virtual void add_data(const std::string &s)
add data to this informational object. If buffering is not set then the information is output directl...
BESInfo()
constructs a BESInfo object
virtual void begin_response(const std::string &response_name, BESDataHandlerInterface &dhi)
begin the informational response
virtual void dump(std::ostream &strm) const
Displays debug information about this object.
virtual void add_data_from_file(const std::string &key, const std::string &name)
add data from a file to the informational object.
void add_data_from_file(const std::string &key, const std::string &name) override
add data from a file to the informational object
void begin_tag(const std::string &tag_name, std::map< std::string, std::string, std::less<> > *attrs=nullptr) override
begin a tagged part of the information, information to follow
BESTextInfo(bool ishttp=false)
constructs a basic text information response object.
void add_space(unsigned long num_spaces) override
add a space to the informational response
void add_tag(const std::string &tag_name, const std::string &tag_data, std::map< std::string, std::string, std::less<> > *attrs=nullptr) override
add tagged information to the inforamtional response
void transmit(BESTransmitter *transmitter, BESDataHandlerInterface &dhi) override
transmit the text information as text
void dump(std::ostream &strm) const override
dumps information about this object
void add_data(const std::string &s) override
add string data to the informational response
void end_tag(const std::string &tag_name) override
end a tagged part of the informational response
void add_break(unsigned long num_breaks) override
add a line break to the information
void begin_response(const std::string &response_name, BESDataHandlerInterface &dhi) override
begin the informational response
static void set_mime_text(std::ostream &strm)
Generate an HTTP 1.0 response header for a text document.