]> git.donarmstrong.com Git - bamtools.git/blobdiff - src/utils/bamtools_utilities.h
Cleaned up help formatting & added some string utilities
[bamtools.git] / src / utils / bamtools_utilities.h
index 3701690fbc6f6a3499dcd3f744d04b5e8e06024f..3320e33351ceca803fed906d4af9c883ecce2120 100644 (file)
@@ -3,7 +3,7 @@
 // Marth Lab, Department of Biology, Boston College
 // All rights reserved.
 // ---------------------------------------------------------------------------
-// Last modified: 26 January 2011
+// Last modified: 9 June 2011
 // ---------------------------------------------------------------------------
 // Provides general utilities used by BamTools sub-tools.
 // ***************************************************************************
@@ -16,6 +16,7 @@
 #include <cassert>
 #include <stdexcept>
 #include <string>
+#include <vector>
 
 #define BAMTOOLS_ASSERT_UNREACHABLE assert( false )
 #define BAMTOOLS_ASSERT_MESSAGE( condition, message ) if (!( condition )) throw std::runtime_error( message );
@@ -28,6 +29,14 @@ class BamMultiReader;
 class UTILS_EXPORT Utilities {
   
     public: 
+        // returns true if 'source' contains 'pattern' or 'c'
+        static bool Contains(const std::string& source, const std::string& pattern);
+        static bool Contains(const std::string& source, const char c);
+
+        // returns true if 'source' ends with 'pattern' or 'c'
+        static bool EndsWith(const std::string& source, const std::string& pattern);
+        static bool EndsWith(const std::string& source, const char c);
+
         // check if a file exists
         static bool FileExists(const std::string& fname);
         
@@ -44,6 +53,14 @@ class UTILS_EXPORT Utilities {
         // sequence utilities
         static void Reverse(std::string& sequence);
         static void ReverseComplement(std::string& sequence);
+
+        // split string on delimiter character (or string of allowed delimiters)
+        static std::vector<std::string> Split(const std::string& source, const char delim);
+        static std::vector<std::string> Split(const std::string& source, const std::string& delims);
+
+        // returns true if 'source' starts with 'pattern' or 'c'
+        static bool StartsWith(const std::string& source, const std::string& pattern);
+        static bool StartsWith(const std::string &source, const char c);
 };
 
 } // namespace BamTools