Revision: 43929
          http://brlcad.svn.sourceforge.net/brlcad/?rev=43929&view=rev
Author:   davidloman
Date:     2011-03-23 15:12:20 +0000 (Wed, 23 Mar 2011)

Log Message:
-----------
Add a printHexString(...) method.  Helps a tons during t-shooting.

Modified Paths:
--------------
    geomcore/trunk/include/ByteArray.h
    geomcore/trunk/src/utility/ByteArray.cxx

Modified: geomcore/trunk/include/ByteArray.h
===================================================================
--- geomcore/trunk/include/ByteArray.h  2011-03-23 04:13:49 UTC (rev 43928)
+++ geomcore/trunk/include/ByteArray.h  2011-03-23 15:12:20 UTC (rev 43929)
@@ -41,6 +41,8 @@
        int size();
        void assign(const char *buf, int len);
 
+       void printHexString(std::string prefix = "");
+
 private:
        bu_vlb vlb;
 };

Modified: geomcore/trunk/src/utility/ByteArray.cxx
===================================================================
--- geomcore/trunk/src/utility/ByteArray.cxx    2011-03-23 04:13:49 UTC (rev 
43928)
+++ geomcore/trunk/src/utility/ByteArray.cxx    2011-03-23 15:12:20 UTC (rev 
43929)
@@ -23,6 +23,8 @@
  *
  */
 
+#include <string>
+#include <iostream>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -37,6 +39,21 @@
 int ByteArray::size() { return bu_vlb_buflen(&vlb); }
 void ByteArray::assign(const char *buf, int size) { bu_vlb_reset(&vlb); 
bu_vlb_write(&vlb, (unsigned char *)buf, size); }
 
+void
+ByteArray::printHexString(std::string prefix)
+{
+       size_t len = bu_vlb_buflen(&this->vlb);
+       std::cout << prefix << " (Len: " << len << " bytes) ";
+
+       unsigned char *p = bu_vlb_addr(&this->vlb);
+       for (int i = 0; i<len;i++)
+       {
+               printf("%02x ", *p);
+               p++;
+       }
+       std::cout << std::endl;
+}
+
 /*
  * Local Variables:
  * tab-width: 8


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to