Selaa lähdekoodia

add output_binary

David Rose 22 vuotta sitten
vanhempi
sitoutus
6552771a5f
2 muutettua tiedostoa jossa 35 lisäystä ja 1 poistoa
  1. 33 1
      panda/src/express/hashVal.cxx
  2. 2 0
      panda/src/express/hashVal.h

+ 33 - 1
panda/src/express/hashVal.cxx

@@ -41,7 +41,7 @@ output_hex(ostream &out) const {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: HashVal::input
+//     Function: HashVal::input_hex
 //       Access: Published
 //       Access: Published
 //  Description: Inputs the HashVal as a 32-digit hexadecimal number.
 //  Description: Inputs the HashVal as a 32-digit hexadecimal number.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -77,6 +77,38 @@ input_hex(istream &in) {
   decode_hex(buffer + 24, _hv[3]);
   decode_hex(buffer + 24, _hv[3]);
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: HashVal::output_binary
+//       Access: Published
+//  Description: Outputs the HashVal as a binary stream of bytes in
+//               order.  This is not the same order generated by
+//               write_stream().
+////////////////////////////////////////////////////////////////////
+void HashVal::
+output_binary(ostream &out) const {
+  StreamWriter writer(out);
+  writer.add_be_uint32(_hv[0]);
+  writer.add_be_uint32(_hv[1]);
+  writer.add_be_uint32(_hv[2]);
+  writer.add_be_uint32(_hv[3]);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: HashVal::input_binary
+//       Access: Published
+//  Description: Inputs the HashVal as a binary stream of bytes in
+//               order.  This is not the same order expected by
+//               read_stream().
+////////////////////////////////////////////////////////////////////
+void HashVal::
+input_binary(istream &in) {
+  StreamReader reader(in);
+  _hv[0] = reader.get_be_uint32();
+  _hv[1] = reader.get_be_uint32();
+  _hv[2] = reader.get_be_uint32();
+  _hv[3] = reader.get_be_uint32();
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: HashVal::as_dec
 //     Function: HashVal::as_dec
 //       Access: Published
 //       Access: Published

+ 2 - 0
panda/src/express/hashVal.h

@@ -50,6 +50,8 @@ PUBLISHED:
   INLINE void input_dec(istream &in);
   INLINE void input_dec(istream &in);
   void output_hex(ostream &out) const;
   void output_hex(ostream &out) const;
   void input_hex(istream &in);
   void input_hex(istream &in);
+  void output_binary(ostream &out) const;
+  void input_binary(istream &in);
 
 
   INLINE void output(ostream &out) const;
   INLINE void output(ostream &out) const;