cphot 0.1
A C++ tool for computing photometry from spectra.
|
|
Go to the documentation of this file. 1 #ifndef RAPIDXML_UTILS_HPP_INCLUDED
2 #define RAPIDXML_UTILS_HPP_INCLUDED
20 template<
class Ch =
char>
33 basic_ifstream<Ch> stream(filename, ios::binary);
35 throw runtime_error(
string(
"cannot open file ") + filename);
36 stream.unsetf(ios::skipws);
39 stream.seekg(0, ios::end);
40 size_t size = stream.tellg();
44 m_data.resize(
size + 1);
45 stream.read(&m_data.front(),
static_cast<streamsize
>(
size));
51 file(std::basic_istream<Ch> &stream)
56 stream.unsetf(ios::skipws);
57 m_data.assign(istreambuf_iterator<Ch>(stream), istreambuf_iterator<Ch>());
58 if (stream.fail() || stream.bad())
59 throw runtime_error(
"error reading stream");
67 return &m_data.front();
74 return &m_data.front();
86 std::vector<Ch> m_data;
96 std::size_t count = 0;
111 std::size_t count = 0;
std::size_t size() const
Gets file data size.
std::size_t count_children(xml_node< Ch > *node)
Counts children of node.
file(std::basic_istream< Ch > &stream)
Loads file into the memory.
Class representing attribute node of XML document.
Represents data loaded from a file.
Ch * data()
Gets file data.
const Ch * data() const
Gets file data.
xml_node< Ch > * first_node(const Ch *name=0, const Ch *xmlns=0, std::size_t name_size=0, std::size_t xmlns_size=0, bool case_sensitive=true) const
Gets first child node, optionally matching node name.
file(const char *filename)
Loads file into the memory.
Class representing a node of XML document.
xml_attribute< Ch > * next_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Gets next attribute, optionally matching attribute name.
std::size_t count_attributes(xml_node< Ch > *node)
Counts attributes of node.
xml_attribute< Ch > * first_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Gets first attribute of node, optionally matching attribute name.
xml_node< Ch > * next_sibling(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Gets next sibling node, optionally matching node name.