Added a streaming object for outputting XML strings (convenience wrapper).
This commit is contained in:
parent
307a933180
commit
cac7d02dd8
1 changed files with 24 additions and 0 deletions
24
src/utils.h
24
src/utils.h
|
|
@ -548,6 +548,30 @@ inline void xml_print(std::ostream& out,
|
|||
out << str;
|
||||
}
|
||||
|
||||
struct xml_str
|
||||
{
|
||||
const string& str;
|
||||
const std::size_t depth;
|
||||
|
||||
xml_str(const string& _str, const std::size_t _depth)
|
||||
: str(_str), depth(_depth) {
|
||||
TRACE_CTOR(xml_str, "const string&, const std::size_t");
|
||||
}
|
||||
xml_str(const xml_str& other)
|
||||
: str(other.str), depth(other.depth) {
|
||||
TRACE_CTOR(xml_str, "copy");
|
||||
}
|
||||
~xml_str() throw() {
|
||||
TRACE_DTOR(xml_str);
|
||||
}
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out, const xml_str& obj) {
|
||||
xml_space(out, obj.depth);
|
||||
out << obj.str;
|
||||
return out;
|
||||
}
|
||||
|
||||
#define READ_INTO(str, targ, size, var, cond) { \
|
||||
char * _p = targ; \
|
||||
var = str.peek(); \
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue