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