[Liblas-commits] r1216 - trunk/include/liblas

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Apr 16 09:51:27 EDT 2009


Author: mloskot
Date: Thu Apr 16 09:51:27 2009
New Revision: 1216
URL: http://liblas.org/changeset/1216

Log:
Use std::bitset<N> interface for all bitwise operations, instead of intermediate objects of uint8_t (Ticket #131).

Modified:
   trunk/include/liblas/lasclassification.hpp

Modified: trunk/include/liblas/lasclassification.hpp
==============================================================================
--- trunk/include/liblas/lasclassification.hpp	(original)
+++ trunk/include/liblas/lasclassification.hpp	Thu Apr 16 09:51:27 2009
@@ -123,6 +123,8 @@
     /// Raturns name of class as defined in LAS 1.1+
     /// Finds class name in lookup table based on class index
     /// as defined in classification object.
+    ///
+    /// \todo TODO: To be implemented
     std::string GetClassName() const
     {
         return std::string("");
@@ -140,11 +142,13 @@
     {
         check_class_index(index);
 
-        uint8_t flags = static_cast<uint8_t>(m_flags.to_ulong());
-        uint8_t const mask = 0x1F << 0; // 0b00011111
-        flags &= ~mask;
-        flags |= mask & (static_cast<uint8_t>(index) << 0);
-        m_flags = bitset_type(flags);
+        bitset_type binval(index);
+        binval <<= 0;
+
+        // Store value in bits 0,1,2,3,4
+        bitset_type const mask(0x1F);
+        m_flags &= ~mask;
+        m_flags |= mask & binval;
     }
 
     void SetSynthetic(bool flag)
@@ -211,9 +215,9 @@
 /// The output stream operator is based on std::bitset<N>::operator<<.
 /// It outputs classification flags in form of string.
 /// Effects promised as by Standard for Programming Language C++, 23.3.5.2:
-/// Each character is determined by the value of its corresponding bit
-/// position in *this. Character position N - 1 corresponds to bit position
-/// zero. Subsequent decreasing character positions correspond to increasing
+/// Each character is determined by the value of its corresponding bit
+/// position in *this. Character position N - 1 corresponds to bit position
+/// zero. Subsequent decreasing character positions correspond to increasing
 /// bit positions. Bit value zero becomes the character 0, bit value one
 /// becomes the character 1.
 inline std::ostream& operator<<(std::ostream& os, LASClassification const& cls)


More information about the Liblas-commits mailing list