//
// Created by Dan Crosby on 3/18/20.
//

#ifndef EAGLE0_REPEATEDPROTOUTILS_HPP
#define EAGLE0_REPEATEDPROTOUTILS_HPP

#include <google/protobuf/util/message_differencer.h>

#include <vector>

// allow comparison of repeated fields & vectors
template<class Container, class Proto>
bool operator==(const Container& lhs, const std::vector<Proto>& rhs) {
    if ((size_t)lhs.size() != (size_t)rhs.size()) return false;

    for (int i = 0; i < lhs.size(); i++) {
        if (!google::protobuf::util::MessageDifferencer::Equals(lhs[i], rhs[i])) return false;
    }

    return true;
}

template<class Container, class Proto>
bool operator==(const std::vector<Proto>& lhs, const Container& rhs) {
    return rhs == lhs;
}

#endif  // EAGLE0_REPEATEDPROTOUTILS_HPP
