本文整理汇总了C++中std::ostream::eof方法的典型用法代码示例。如果您正苦于以下问题:C++ ostream::eof方法的具体用法?C++ ostream::eof怎么用?C++ ostream::eof使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::ostream
的用法示例。
在下文中一共展示了ostream::eof方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write
bool server_response::write(std::ostream &os) {
// Set "content-length" header
auto i=headers.find("content-length");
if (i==headers.end()) {
headers.insert(std::make_pair("Content-Length", boost::lexical_cast<std::string>(get_content_length())));
} else {
i->second.assign(boost::lexical_cast<std::string>(get_content_length()));
}
// Write headers
if (!write_header(os)) return false;
// Write body
os.write(&(raw_body_stream_.vector()[0]), raw_body_stream_.vector().size());
return !os.eof() && !os.fail() && !os.bad();
}
示例2: write_header
bool server_response::write_header(std::ostream &os) {
std::string ka;
if (keep_alive) {
ka="keep-alive";
} else {
ka="close";
}
auto i=headers.find("connection");
if (i==headers.end()) {
headers.insert(std::make_pair("Connection", ka));
} else {
i->second.assign(ka);
}
if (!common::response::write_header(os)) return false;
return !os.eof() && !os.fail() && !os.bad();
}
示例3: sintoxml
void sintoxml(std::ostream& s, const char* filename, sinparms& sp)
{
std::ifstream f(filename);
if (!f.is_open()) {
throw std::runtime_error("Unable to open SIN file for XML conversion");
}
pugi::xml_document doc;
pugi::xml_node root = doc.append_child();
root.set_name("philips");
std::string line;
const size_t buffer_size = 4096;
char buffer[buffer_size];
while (!f.eof()) {
f.getline(buffer,buffer_size);
std::string line(buffer);
std::stringstream s;
uint16_t idx1, idx2, idx3;
char tmp;
std::string parameter_name;
std::string parameter_value;
if (line.find(':') != std::string::npos && isdigit(line[1])) {
boost::algorithm::trim_right(line);
s << line;
s >> idx1; s >> idx2; s >> idx3; s >> tmp;
s >> parameter_name;
pugi::xml_node parm = root.append_child(parameter_name.c_str());
pugi::xml_attribute attr_idx1 = parm.append_attribute("idx1");
attr_idx1.set_value(idx1);
pugi::xml_attribute attr_idx2 = parm.append_attribute("idx2");
attr_idx2.set_value(idx2);
pugi::xml_attribute attr_idx3 = parm.append_attribute("idx3");
attr_idx3.set_value(idx3);
s >> tmp;
bool get_nchan = false;
float pda[2];
bool get_pda = false;
int pda_comp = 0;
if (parameter_name == "enable_pda") {
sp.ismira = false;
} else if (parameter_name == "max_measured_channels") {
get_nchan = true;
} else if (parameter_name == "nr_measured_channels") {
get_nchan = true;
} else if (parameter_name == "pda_ampl_factors") {
get_pda = true;
}
while (!s.eof()) {
s >> parameter_value;
if (get_nchan) {
sp.nchan = std::atoi(parameter_value.c_str());
}
if (get_pda) {
pda[pda_comp++] = std::atof(parameter_value.c_str());
if (pda_comp > 1) {
sp.pda_amp_factors.push_back(std::complex<float>(pda[0],pda[1]));
pda_comp = 0;
}
}
pugi::xml_node v = parm.append_child("value");
v.append_child(pugi::node_pcdata).set_value(parameter_value.c_str());
}
}
}