|
|
|
@ -44,6 +44,8 @@ public:
|
|
|
|
|
bool is_bare() const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class xmlns;
|
|
|
|
|
|
|
|
|
|
namespace xml {
|
|
|
|
|
|
|
|
|
|
class node {
|
|
|
|
@ -77,7 +79,7 @@ namespace xml {
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename xmlns>
|
|
|
|
|
template<typename X, std::enable_if_t<std::is_base_of<xmlns,X>::value, int> = 0>
|
|
|
|
|
inline std::vector<std::reference_wrapper<node>>
|
|
|
|
|
get_children(std::string_view name) {
|
|
|
|
|
std::vector<std::reference_wrapper<node>> list;
|
|
|
|
@ -85,7 +87,7 @@ namespace xml {
|
|
|
|
|
std::back_inserter(list),
|
|
|
|
|
[&](node& x) {
|
|
|
|
|
return x.name == name
|
|
|
|
|
&& x.ns == std::string_view(xmlns());
|
|
|
|
|
&& x.ns == std::string_view(X());
|
|
|
|
|
});
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
@ -102,9 +104,13 @@ namespace xml {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
namespace builder {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace stanza {
|
|
|
|
|
template<class... Ts> struct overloaded : Ts... { using Ts::operator()...; };
|
|
|
|
|
|
|
|
|
|
extern std::string uuid(xmpp_ctx_t *context);
|
|
|
|
|
|
|
|
|
|
class spec {
|
|
|
|
|
protected:
|
|
|
|
|
explicit spec(std::string_view tag): tag(tag) {}
|
|
|
|
@ -117,10 +123,15 @@ namespace xml {
|
|
|
|
|
attributes[k] = v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void text(std::string_view s) {
|
|
|
|
|
void text(std::string_view s) {
|
|
|
|
|
children.push_back(std::string(s));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename X, std::enable_if_t<std::is_base_of<xmlns,X>::value, int> = 0>
|
|
|
|
|
void xmlns() {
|
|
|
|
|
attr("xmlns", X().ns());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
const std::string tag;
|
|
|
|
|
std::map<std::string, std::string> attributes;
|
|
|
|
@ -149,15 +160,23 @@ namespace xml {
|
|
|
|
|
return { stanza, &xmpp_stanza_release };
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#include "xep-0027.inl"
|
|
|
|
|
#include "xep-0030.inl"
|
|
|
|
|
#include "xep-0045.inl"
|
|
|
|
|
#include "xep-0115.inl"
|
|
|
|
|
#include "xep-0319.inl"
|
|
|
|
|
|
|
|
|
|
struct body : public spec {
|
|
|
|
|
namespace stanza {
|
|
|
|
|
struct body : virtual public spec {
|
|
|
|
|
body() : body("") {}
|
|
|
|
|
body(std::string_view s) : spec("body") {
|
|
|
|
|
text(s);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct message : public spec {
|
|
|
|
|
struct message : virtual public spec {
|
|
|
|
|
message() : spec("message") {}
|
|
|
|
|
|
|
|
|
|
message& id(std::string_view s) { attr("id", s); return *this; }
|
|
|
|
@ -165,30 +184,29 @@ namespace xml {
|
|
|
|
|
message& to(std::string_view s) { attr("to", s); return *this; }
|
|
|
|
|
message& type(std::string_view s) { attr("type", s); return *this; }
|
|
|
|
|
|
|
|
|
|
message& body(builder::body b) { child(b); return *this; }
|
|
|
|
|
message& body(std::string_view s) { return body(builder::body(s)); }
|
|
|
|
|
message& body(stanza::body b) { child(b); return *this; }
|
|
|
|
|
message& body(std::string_view s) { return body(stanza::body(s)); }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct presence : public spec {
|
|
|
|
|
struct presence : virtual public spec {
|
|
|
|
|
presence() : spec("presence") {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct iq : public spec {
|
|
|
|
|
struct iq : virtual public spec,
|
|
|
|
|
public xep0030::iq {
|
|
|
|
|
iq() : spec("iq") {}
|
|
|
|
|
|
|
|
|
|
iq& id(std::string_view s) { attr("id", s); return *this; }
|
|
|
|
|
iq& from(std::string_view s) { attr("from", s); return *this; }
|
|
|
|
|
iq& to(std::string_view s) { attr("to", s); return *this; }
|
|
|
|
|
iq& type(std::string_view s) { attr("type", s); return *this; }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct error : public spec {
|
|
|
|
|
struct error : virtual public spec {
|
|
|
|
|
error() : spec("error") {}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#include "xep-0027.inl"
|
|
|
|
|
#include "xep-0045.inl"
|
|
|
|
|
#include "xep-0115.inl"
|
|
|
|
|
#include "xep-0319.inl"
|
|
|
|
|
|
|
|
|
|
namespace xml {
|
|
|
|
|
|
|
|
|
|
class message : virtual public node,
|
|
|
|
|