X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2Fapi%2FBamConstants.h;h=3e674ee5d3afe06fcf2b0d0c20f8a2775a6d78e2;hb=11fabb69eb8c86635dd9498679b72bf78b3af3d1;hp=1107371ec703d74af78fa30454f55a1cd61ef1f6;hpb=72f5b82ad353b4cc9d6f8153f1ad19cc387b9597;p=bamtools.git diff --git a/src/api/BamConstants.h b/src/api/BamConstants.h index 1107371..3e674ee 100644 --- a/src/api/BamConstants.h +++ b/src/api/BamConstants.h @@ -2,7 +2,7 @@ // BamConstants.h (c) 2011 Derek Barnett // Marth Lab, Department of Biology, Boston College // --------------------------------------------------------------------------- -// Last modified: 19 April 2011 (DB) +// Last modified: 4 October 2011 (DB) // --------------------------------------------------------------------------- // Provides basic constants for handling BAM files. // *************************************************************************** @@ -10,6 +10,8 @@ #ifndef BAM_CONSTANTS_H #define BAM_CONSTANTS_H +#include +#include #include /*! \namespace BamTools::Constants @@ -122,6 +124,137 @@ const int BGZF_MAX_BLOCK_SIZE = 65536; const int BGZF_DEFAULT_BLOCK_SIZE = 65536; } // namespace Constants + +// ------------------------- +// tag-type helper structs +// ------------------------- + +// fail on any types not specified below +template +struct TagTypeHelper { + static bool CanConvertFrom(const char) { assert(false); return false; } + static bool CanConvertTo(const char) { assert(false); return false; } + static char TypeCode(void) { assert(false); return 0; } +}; + +template<> +struct TagTypeHelper { + static bool CanConvertFrom(const char c) { + return ( c == Constants::BAM_TAG_TYPE_ASCII || + c == Constants::BAM_TAG_TYPE_UINT8 ); + } + static bool CanConvertTo(const char c) { + return ( c == Constants::BAM_TAG_TYPE_ASCII || + c == Constants::BAM_TAG_TYPE_UINT8 || + c == Constants::BAM_TAG_TYPE_UINT16 || + c == Constants::BAM_TAG_TYPE_UINT32 ); + } + + static char TypeCode(void) { return Constants::BAM_TAG_TYPE_UINT8; } +}; + +template<> +struct TagTypeHelper { + static bool CanConvertFrom(const char c) { + return ( c == Constants::BAM_TAG_TYPE_ASCII || + c == Constants::BAM_TAG_TYPE_INT8 ); + } + static bool CanConvertTo(const char c) { + return ( c == Constants::BAM_TAG_TYPE_ASCII || + c == Constants::BAM_TAG_TYPE_INT8 || + c == Constants::BAM_TAG_TYPE_INT16 || + c == Constants::BAM_TAG_TYPE_INT32 ); + } + static char TypeCode(void) { return Constants::BAM_TAG_TYPE_INT8; } +}; + +template<> +struct TagTypeHelper { + static bool CanCovnertFrom(const char c) { + return ( c == Constants::BAM_TAG_TYPE_ASCII || + c == Constants::BAM_TAG_TYPE_UINT8 || + c == Constants::BAM_TAG_TYPE_UINT16 ); + } + static bool CanConvertTo(const char c) { + return ( c == Constants::BAM_TAG_TYPE_UINT16 || + c == Constants::BAM_TAG_TYPE_UINT32); + } + static char TypeCode(void) { return Constants::BAM_TAG_TYPE_UINT16; } +}; + +template<> +struct TagTypeHelper { + static bool CanConvertFrom(const char c) { + return ( c == Constants::BAM_TAG_TYPE_ASCII || + c == Constants::BAM_TAG_TYPE_INT8 || + c == Constants::BAM_TAG_TYPE_INT16 ); + } + static bool CanConvertTo(const char c) { + return ( c == Constants::BAM_TAG_TYPE_INT16 || + c == Constants::BAM_TAG_TYPE_INT32); + } + static char TypeCode(void) { return Constants::BAM_TAG_TYPE_INT16; } +}; + +template<> +struct TagTypeHelper { + static bool CanConvertFrom(const char c) { + return ( c == Constants::BAM_TAG_TYPE_ASCII || + c == Constants::BAM_TAG_TYPE_UINT8 || + c == Constants::BAM_TAG_TYPE_UINT16 || + c == Constants::BAM_TAG_TYPE_UINT32 ); + } + static bool CanConvertTo(const char c) { + return ( c == Constants::BAM_TAG_TYPE_UINT32 ); + } + static char TypeCode(void) { return Constants::BAM_TAG_TYPE_UINT32; } +}; + +template<> +struct TagTypeHelper { + static bool CanConvertFrom(const char c) { + return ( c == Constants::BAM_TAG_TYPE_ASCII || + c == Constants::BAM_TAG_TYPE_INT8 || + c == Constants::BAM_TAG_TYPE_INT16 || + c == Constants::BAM_TAG_TYPE_INT32 ); + } + static bool CanConvertTo(const char c) { + return ( c == Constants::BAM_TAG_TYPE_INT32 ); + } + static char TypeCode(void) { return Constants::BAM_TAG_TYPE_INT32; } +}; + +template<> +struct TagTypeHelper { + static bool CanConvertFrom(const char c) { + return ( c == Constants::BAM_TAG_TYPE_ASCII || + c == Constants::BAM_TAG_TYPE_UINT8 || + c == Constants::BAM_TAG_TYPE_INT8 || + c == Constants::BAM_TAG_TYPE_UINT16 || + c == Constants::BAM_TAG_TYPE_INT16 || + c == Constants::BAM_TAG_TYPE_UINT32 || + c == Constants::BAM_TAG_TYPE_INT32 || + c == Constants::BAM_TAG_TYPE_FLOAT); + } + static bool CanConvertTo(const char c) { + return ( c == Constants::BAM_TAG_TYPE_FLOAT ); + } + static char TypeCode(void) { return Constants::BAM_TAG_TYPE_FLOAT; } +}; + +template<> +struct TagTypeHelper { + static bool CanConvertFrom(const char c) { + return ( c == Constants::BAM_TAG_TYPE_HEX || + c == Constants::BAM_TAG_TYPE_STRING ); + } + static bool CanConvertTo(const char c) { + return ( c == Constants::BAM_TAG_TYPE_HEX || + c == Constants::BAM_TAG_TYPE_STRING ); + } + static char TypeCode(void) { return Constants::BAM_TAG_TYPE_STRING; } +}; + } // namespace BamTools #endif // BAM_CONSTANTS_H