More marshalling simplification
[invirt/third/libt4.git] / paxos_protocol.h
index c24f155..5e8afdd 100644 (file)
@@ -7,8 +7,13 @@
 struct prop_t {
     unsigned n;
     string m;
+
+    MEMBERS(n, m)
+    LEXICOGRAPHIC_COMPARISON(prop_t)
 };
 
+MARSHALLABLE(prop_t)
+
 class paxos_protocol {
     public:
         enum status : status_t { OK, ERR };
@@ -24,20 +29,11 @@ class paxos_protocol {
             bool accept;
             prop_t n_a;
             string v_a;
+
+            MEMBERS(oldinstance, accept, n_a, v_a)
         };
 };
 
-inline unmarshall & operator>>(unmarshall &u, prop_t &a) { return u >> a.n >> a.m; }
-inline marshall & operator<<(marshall &m, prop_t a) { return m << a.n << a.m; }
-inline bool operator>(const prop_t &a, const prop_t &b) { return tie(a.n, a.m) > tie(b.n, b.m); }
-inline bool operator>=(const prop_t &a, const prop_t &b) { return tie(a.n, a.m) >= tie(b.n, b.m); }
-
-inline unmarshall & operator>>(unmarshall &u, paxos_protocol::prepareres &r) {
-    return u >> r.oldinstance >> r.accept >> r.n_a >> r.v_a;
-}
-
-inline marshall & operator<<(marshall &m, paxos_protocol::prepareres r) {
-    return m << r.oldinstance << r.accept << r.n_a << r.v_a;
-}
+MARSHALLABLE(paxos_protocol::prepareres)
 
 #endif