# # # patch "vocab.cc" # from [e0e42e8bf39443a337bfb58c93d08c45c0143ead] # to [b6b53768e6891eb6f1e302bcd6cdb7019bfc8b5c] # # patch "vocab_macros.hh" # from [3e98a31c4c78c36b9c22900be265f23123d30e45] # to [6eb6aecd0aaee7b4452f35a2a1e3ec214881aa29] # # patch "vocab_terms.hh" # from [f314ffbf3ac27df4aa973cd9371fd633914be492] # to [e21a5302083239e54cb8ede3dbaf76ef1faf6367] # ============================================================ --- vocab.cc e0e42e8bf39443a337bfb58c93d08c45c0143ead +++ vocab.cc b6b53768e6891eb6f1e302bcd6cdb7019bfc8b5c @@ -208,8 +208,19 @@ fake_id() #undef ATOMIC #undef DECORATE +template +void dump(revision_id const & r, string &); template +void dump(manifest_id const & r, string &); + +template +void dump(file_id const & r, string &); + +template +void dump(hexenc const & r, string &); + +template void dump(rsa_pub_key const&, string &); template @@ -222,82 +233,16 @@ void dump(manifest_data const & d, strin void dump(manifest_data const & d, string &); /* - * specializations for hexenc, which allows the encoded id - * to be dumped out, even if id itself must never be dumped - * because it's binary. + * specializations for id, which allows the encoded id + * to be dumped out as a human readable, hex encoded + * string. */ template <> -void dump (hexenc const & obj, std::string & out) +void dump (id const & obj, std::string & out) { out = encode_hexenc(obj()); } -template <> -std::ostream & -operator<< (std::ostream & out, hexenc const & hex_id) -{ - return (out << encode_hexenc(hex_id())); -} - - -/* - * specializations for decorated binary values, which shouldn't - * be dumped out as binaries. - * - * FIXME: these shouldn't be necessary. Heck, you shouldn't even - * use them. They are here to tell you *where* you are - * calling them. Otherwise, you'd just get a linker error - * for undefined references. - */ - -template <> -void dump (revision const & obj, std::string & out) -{ - W(F("shouldn't dump out binary revision_id contents!")); - *((char*) NULL) = 0; - out = encode_hexenc(obj.inner()()); -} - -template <> std::ostream & -operator<< (std::ostream & out, revision const & id) -{ - W(F("shouldn't dump out binary revision_id contents!")); - *((char*) NULL) = 0; - return (out << encode_hexenc(id.inner()())); -} - -template <> -void dump (manifest const & obj, std::string & out) -{ - W(F("shouldn't dump out binary manifest_id contents!")); - *((char*) NULL) = 0; - out = encode_hexenc(obj.inner()()); -} - -template <> std::ostream & -operator<< (std::ostream & out, manifest const & id) -{ - W(F("shouldn't dump out binary manifest_id contents!")); - *((char*) NULL) = 0; - return (out << encode_hexenc(id.inner()())); -} - -template <> -void dump (file const & obj, std::string & out) -{ - W(F("shouldn't dump out binary file_id contents!")); - *((char*) NULL) = 0; - out = encode_hexenc(obj.inner()()); -} - -template <> std::ostream & -operator<< (std::ostream & out, file const & id) -{ - W(F("shouldn't dump out binary file_id contets!")); - *((char*) NULL) = 0; - return (out << encode_hexenc(id.inner()())); -} - #ifdef BUILD_UNIT_TESTS #include "unit_tests.hh" ============================================================ --- vocab_macros.hh 3e98a31c4c78c36b9c22900be265f23123d30e45 +++ vocab_macros.hh 6eb6aecd0aaee7b4452f35a2a1e3ec214881aa29 @@ -131,12 +131,17 @@ public: { return s.get() != other(); } \ friend void verify(ty &); \ friend void verify_full(ty &); \ + friend std::ostream & operator<<(std::ostream &, \ + ty const &); \ struct symtab \ { \ symtab(); \ ~symtab(); \ }; \ }; \ +std::ostream & operator<<(std::ostream &, ty const &); \ +template <> \ +void dump(ty const &, std::string &); \ inline void verify_full(ty &) {} @@ -206,6 +211,10 @@ ty const & ty::operator=(ty const & othe { s = other.s; ok = other.ok; \ verify(*this); return *this; } \ \ + std::ostream & operator<<(std::ostream & o,\ + ty const & a) \ + { return (o << encode_hexenc(a.s.get())); }\ + \ ty::symtab::symtab() \ { ty ## _tab_active++; } \ \ ============================================================ --- vocab_terms.hh f314ffbf3ac27df4aa973cd9371fd633914be492 +++ vocab_terms.hh e21a5302083239e54cb8ede3dbaf76ef1faf6367 @@ -112,18 +112,14 @@ EXTERN template class base64; // instantiate those bits of the stream operator vocab (again) actually in // use. "again" since stream operators are friends, not members. -#if 0 -EXTERN template std::ostream & operator<< <>(std::ostream &, hexenc const &); -#endif +EXTERN template std::ostream & operator<< <>(std::ostream &, hexenc const &); +EXTERN template std::ostream & operator<< <>(std::ostream &, revision const &); +EXTERN template std::ostream & operator<< <>(std::ostream &, roster const &); +EXTERN template std::ostream & operator<< <>(std::ostream &, manifest const &); +EXTERN template std::ostream & operator<< <>(std::ostream &, file const &); +EXTERN template std::ostream & operator<< <>(std::ostream &, epoch const &); -#if 0 - -// EXTERN template std::ostream & operator<< <>(std::ostream &, revision const &); - -#endif - - EXTERN template std::ostream & operator<< <>(std::ostream &, hexenc const &); EXTERN template std::ostream & operator<< <>(std::ostream &, roster const &);