+
+//! \cond
+// -------------------------
+// tag-type helper structs
+// -------------------------
+
+// fail on any types not specified below
+template<typename T>
+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<uint8_t> {
+ 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<int8_t> {
+ 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<uint16_t> {
+ 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<int16_t> {
+ 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<uint32_t> {
+ 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<int32_t> {
+ 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<float> {
+ 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<std::string> {
+ 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; }
+};
+
+//! \endcond
+