Represents data loaded from a file.
More...
#include <rapidxml_utils.hpp>
|
| file (const char *filename) |
|
| file (std::basic_istream< Ch > &stream) |
|
Ch * | data () |
|
const Ch * | data () const |
|
std::size_t | size () const |
|
template<class Ch = char>
class rapidxml::file< Ch >
Represents data loaded from a file.
Definition at line 21 of file rapidxml_utils.hpp.
◆ file() [1/2]
file |
( |
const char * |
filename | ) |
|
|
inline |
Loads file into the memory. Data will be automatically destroyed by the destructor.
- Parameters
-
filename | Filename to load. |
Definition at line 28 of file rapidxml_utils.hpp.
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();
45 stream.read(&
m_data.front(),
static_cast<streamsize
>(
size));
◆ file() [2/2]
file |
( |
std::basic_istream< Ch > & |
stream | ) |
|
|
inline |
Loads file into the memory. Data will be automatically destroyed by the destructor
- Parameters
-
stream | Stream to load from |
Definition at line 51 of file rapidxml_utils.hpp.
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");
◆ data() [1/2]
◆ data() [2/2]
◆ size()
std::size_t size |
( |
| ) |
const |
|
inline |
Gets file data size.
- Returns
- Size of file data, in characters.
Definition at line 79 of file rapidxml_utils.hpp.
◆ m_data
The documentation for this class was generated from the following file: