]> git.donarmstrong.com Git - bamtools.git/blobdiff - src/api/internal/SamHeaderVersion_p.h
Cleaned up intra-API includes & moved version numbers to 2.0.0
[bamtools.git] / src / api / internal / SamHeaderVersion_p.h
index ff9647136adcc416b842263cae9e70300c704c27..4f85df0d231c6ef9d2590cf2c8669a59e98ca4f8 100644 (file)
@@ -1,7 +1,26 @@
+// ***************************************************************************
+// SamHeaderVersion.h (c) 2010 Derek Barnett
+// Marth Lab, Department of Biology, Boston College
+// ---------------------------------------------------------------------------
+// Last modified: 10 October 2011 (DB)
+// ---------------------------------------------------------------------------
+// Provides functionality for comparing SAM header versions
+// *************************************************************************
+
 #ifndef SAM_HEADERVERSION_P_H
 #define SAM_HEADERVERSION_P_H
 
-#include <api/SamConstants.h>
+//  -------------
+//  W A R N I N G
+//  -------------
+//
+// This file is not part of the BamTools API.  It exists purely as an
+// implementation detail. This header file may change from version to version
+// without notice, or even be removed.
+//
+// We mean it.
+
+#include "api/SamConstants.h"
 #include <sstream>
 #include <string>
 
@@ -39,8 +58,8 @@ class SamHeaderVersion {
         unsigned int MajorVersion(void) const { return m_majorVersion; }
         unsigned int MinorVersion(void) const { return m_minorVersion; }
 
-        inline void SetVersion(const std::string& version);
-        inline std::string ToString(void) const;
+        void SetVersion(const std::string& version);
+        std::string ToString(void) const;
 
     // data members
     private:
@@ -54,28 +73,28 @@ void SamHeaderVersion::SetVersion(const std::string& version) {
     // do nothing if version is empty
     if ( !version.empty() ) {
 
+        std::stringstream versionStream("");
+
         // do nothing if period not found
         const size_t periodFound = version.find(Constants::SAM_PERIOD);
         if ( periodFound != std::string::npos ) {
 
             // store major version if non-empty and contains only digits
             const std::string& majorVersion = version.substr(0, periodFound);
-            if ( majorVersion.empty() ) {
+            versionStream.str(majorVersion);
+            if ( !majorVersion.empty() ) {
                 const size_t nonDigitFound = majorVersion.find_first_not_of(Constants::SAM_DIGITS);
-                if ( nonDigitFound == std::string::npos ) {
-                    std::stringstream major(majorVersion);
-                    major >> m_majorVersion;
-                }
+                if ( nonDigitFound == std::string::npos )
+                    versionStream >> m_majorVersion;
             }
 
             // store minor version if non-empty and contains only digits
             const std::string& minorVersion = version.substr(periodFound + 1);
-            if ( minorVersion.empty() ) {
+            versionStream.str(minorVersion);
+            if ( !minorVersion.empty() ) {
                 const size_t nonDigitFound = minorVersion.find_first_not_of(Constants::SAM_DIGITS);
-                if ( nonDigitFound == std::string::npos ) {
-                    std::stringstream minor(minorVersion);
-                    minor >> m_minorVersion;
-                }
+                if ( nonDigitFound == std::string::npos )
+                    versionStream >> m_minorVersion;
             }
         }
     }