1 /*==========================================================================
2 SeqAn - The Library for Sequence Analysis
4 ============================================================================
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 3 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 ============================================================================
18 $Id: basic_alphabet_simple.h,v 1.1 2008/08/25 16:20:02 langmead Exp $
19 ==========================================================================*/
21 #ifndef SEQAN_HEADER_BASIC_ALPHABET_SIMPLE_H
22 #define SEQAN_HEADER_BASIC_ALPHABET_SIMPLE_H
24 namespace SEQAN_NAMESPACE_MAIN
27 //////////////////////////////////////////////////////////////////////////////
28 //Class that is used for various simple value types
29 //////////////////////////////////////////////////////////////////////////////
34 ..summary:Implementation for "simple" types.
35 ..signature:SimpleType<TValue, TSpec>
36 ..param.TValue:Type that stores the values of an instance.
37 ...remarks:TValue must be a simple type.
38 ...metafunction:Metafunction.Value
39 ..param.TSpec:Specialization tag.
40 ...metafunction:Metafunction.Spec
42 ...text:A "simple type" is a C++ type that can be constructed without constructor,
43 destructed without destructor and copied without copy constructor or assignment operator.
44 All basic types (like $char$, $int$ or $float$) are simple. Pointers, references and arrays of
45 simple types are simple.
46 POD types ("plain old data types"), that are - simplified spoken - C++-types that already existed in C,
48 ...text:Arrays of simple types can be copied very fast by memory manipulation routines,
49 but the default implementation of functions like @Function.arrayCopyForward@ and @Function.arrayCopy@
50 are not optimized for simple types this way.
51 But for classes derived from $SimpleType$, optimized variants of array manipulation functions are applied.
52 ...text:Note that simple types need not to be derived or specialized from $SimpleType$, but
53 it could be convenient to do so.
54 ..implements:Concept.Simple Type
56 template <typename TValue, typename TSpec>
59 //____________________________________________________________________________
63 //____________________________________________________________________________
70 //____________________________________________________________________________
72 SimpleType(SimpleType const & other)
79 SimpleType(T const & other)
86 //____________________________________________________________________________
88 SimpleType & operator=(SimpleType const & other)
95 SimpleType & operator=(T const & other)
101 //____________________________________________________________________________
107 //____________________________________________________________________________
109 //this cannot be a template since a template would be in conflict to
113 operator long() const
120 operator unsigned long() const
134 operator unsigned int() const
141 operator short() const
148 operator unsigned short() const
155 operator char() const
162 operator signed char() const
169 operator unsigned char() const
177 //____________________________________________________________________________
180 //////////////////////////////////////////////////////////////////////////////
182 //////////////////////////////////////////////////////////////////////////////
184 ///.Metafunction.IsSimple.param.T.type:Class.SimpleType
186 template <typename TValue, typename TSpec>
187 struct IsSimple<SimpleType<TValue, TSpec> >
192 //////////////////////////////////////////////////////////////////////////////
194 ///.Metafunction.Value.param.T.type:Class.SimpleType
195 template <typename TValue, typename TSpec>
196 struct Value<SimpleType<TValue, TSpec> >
201 template <typename TValue, typename TSpec>
202 struct Value<SimpleType<TValue, TSpec> const >
204 typedef TValue const Type;
207 //////////////////////////////////////////////////////////////////////////////
209 ///.Metafunction.Spec.param.T.type:Class.SimpleType
210 template <typename TValue, typename TSpec>
211 struct Spec<SimpleType<TValue, TSpec> >
216 template <typename TValue, typename TSpec>
217 struct Spec<SimpleType<TValue, TSpec> const >
222 //////////////////////////////////////////////////////////////////////////////
224 template <typename TValue, typename TSpec>
225 struct Iterator<SimpleType<TValue, TSpec>, Standard>
227 typedef SimpleType<TValue, TSpec> * Type;
228 // typedef Iter<SimpleType<TValue, TSpec>, SimpleIterator> * Type;
231 template <typename TValue, typename TSpec>
232 struct Iterator<SimpleType<TValue, TSpec> const, Standard>
234 typedef SimpleType<TValue, TSpec> const * Type;
235 // typedef Iter<SimpleType<TValue, TSpec> const, SimpleIterator> * Type;
239 //////////////////////////////////////////////////////////////////////////////
241 //////////////////////////////////////////////////////////////////////////////
243 template <typename TTarget, typename T, typename TSourceValue, typename TSourceSpec>
244 inline typename _RemoveConst<TTarget>::Type
245 convertImpl(Convert<TTarget, T> const,
246 SimpleType<TSourceValue, TSourceSpec> const & source_)
249 typename _RemoveConst<TTarget>::Type target_;
250 assign(target_, source_);
256 //////////////////////////////////////////////////////////////////////////////
258 template <typename TStream, typename TValue, typename TSpec>
260 operator << (TStream & stream,
261 SimpleType<TValue, TSpec> const & data)
264 stream << convert<char>(data);
268 //////////////////////////////////////////////////////////////////////////////
270 template <typename TStream, typename TValue, typename TSpec>
272 operator >> (TStream & stream,
273 SimpleType<TValue, TSpec> & data)
282 //////////////////////////////////////////////////////////////////////////////
284 //////////////////////////////////////////////////////////////////////////////
286 ///.Function.assign.param.target.type:Class.SimpleType
287 ///.Function.assign.param.source.type:Class.SimpleType
290 template <typename TTargetValue, typename TTargetSpec, typename TSourceValue, typename TSourceSpec>
292 assign(SimpleType<TTargetValue, TTargetSpec> & target,
293 SimpleType<TSourceValue, TSourceSpec> & source)
296 target.value = source.value;
298 template <typename TTargetValue, typename TTargetSpec, typename TSourceValue, typename TSourceSpec>
300 assign(SimpleType<TTargetValue, TTargetSpec> & target,
301 SimpleType<TSourceValue, TSourceSpec> const & source)
304 target.value = source.value;
307 //____________________________________________________________________________
309 template <typename TTargetValue, typename TTargetSpec, typename TSource>
311 assign(SimpleType<TTargetValue, TTargetSpec> & target,
315 target.value = source;
317 template <typename TTargetValue, typename TTargetSpec, typename TSource>
319 assign(SimpleType<TTargetValue, TTargetSpec> & target,
320 TSource const & source)
323 target.value = source;
326 //____________________________________________________________________________
327 // Assign Proxy to SimpleType
328 //??? Diese Funktionen wurden noetig wegen eines seltsamen VC++-Verhaltens
330 template <typename TTargetValue, typename TTargetSpec, typename TSourceSpec>
332 assign(SimpleType<TTargetValue, TTargetSpec> & target,
333 Proxy<TSourceSpec> & source)
336 target.value = getValue(source);
339 template <typename TTargetValue, typename TTargetSpec, typename TSourceSpec>
341 assign(SimpleType<TTargetValue, TTargetSpec> & target,
342 Proxy<TSourceSpec> const & source)
345 target.value = getValue(source);
348 //____________________________________________________________________________
350 //note: it is not possible to write a single function here since "assign"
351 //must be specialized for the first argument at the first place
354 template <typename TValue, typename TSpec>
356 assign(int & c_target,
357 SimpleType<TValue, TSpec> & source)
360 c_target = source.value;
362 template <typename TValue, typename TSpec>
364 assign(int & c_target,
365 SimpleType<TValue, TSpec> const & source)
368 c_target = source.value;
372 template <typename TValue, typename TSpec>
374 assign(unsigned int & c_target,
375 SimpleType<TValue, TSpec> & source)
378 c_target = source.value;
380 template <typename TValue, typename TSpec>
382 assign(unsigned int & c_target,
383 SimpleType<TValue, TSpec> const & source)
386 c_target = source.value;
390 template <typename TValue, typename TSpec>
392 assign(short & c_target,
393 SimpleType<TValue, TSpec> & source)
396 c_target = source.value;
398 template <typename TValue, typename TSpec>
400 assign(short & c_target,
401 SimpleType<TValue, TSpec> const & source)
404 c_target = source.value;
408 template <typename TValue, typename TSpec>
410 assign(unsigned short & c_target,
411 SimpleType<TValue, TSpec> & source)
414 c_target = source.value;
416 template <typename TValue, typename TSpec>
418 assign(unsigned short & c_target,
419 SimpleType<TValue, TSpec> const & source)
422 c_target = source.value;
426 template <typename TValue, typename TSpec>
428 assign(char & c_target,
429 SimpleType<TValue, TSpec> & source)
432 c_target = source.value;
434 template <typename TValue, typename TSpec>
436 assign(char & c_target,
437 SimpleType<TValue, TSpec> const & source)
440 c_target = source.value;
444 template <typename TValue, typename TSpec>
446 assign(signed char & c_target,
447 SimpleType<TValue, TSpec> & source)
450 c_target = source.value;
452 template <typename TValue, typename TSpec>
454 assign(signed char & c_target,
455 SimpleType<TValue, TSpec> const & source)
458 c_target = source.value;
462 template <typename TValue, typename TSpec>
464 assign(unsigned char & c_target,
465 SimpleType<TValue, TSpec> & source)
468 c_target = source.value;
470 template <typename TValue, typename TSpec>
472 assign(unsigned char & c_target,
473 SimpleType<TValue, TSpec> const & source)
476 c_target = source.value;
479 //////////////////////////////////////////////////////////////////////////////
480 //////////////////////////////////////////////////////////////////////////////
482 //////////////////////////////////////////////////////////////////////////////
484 /**.Metafunction.CompareType:
485 ..summary:Type to convert other types for comparisons.
486 ..signature:CompareType<TLeft, TRight>::Type
487 ..param.TLeft:Type of the left operand of a comparison.
488 ..param.TRight:Type of the right operand of a comparison.
489 ..return.Type:The Type in which the arguments are converted in order to compare them.
490 ..remarks:Comparisons are for example operators like $==$ or $<$.
491 ..remarks.text:Note that there is no rule that guarantees that $CompareType<T1, T2>::Type$
492 is the same as $CompareType<T2, T1>::Type$. It is also possible, that only one of these
493 two types is defined.
494 ..remarks.text:This metafunction is used for the implementation of
495 comparisons that involve @Class.SimpleType@.
497 //???TODO: muss geprueft werden, ob diese Metafunktion noch ausgeweitet oder aber versteckt wird.
499 template <typename TLeft, typename TRight>
502 template <typename T>
503 struct CompareType<T, T>
508 //____________________________________________________________________________
510 template <typename TValue, typename TSpec, typename TRight>
511 struct CompareType<SimpleType<TValue, TSpec>, TRight>
516 //////////////////////////////////////////////////////////////////////////////
519 template <typename TValue, typename TSpec, typename TRight>
521 operator == (SimpleType<TValue, TSpec> const & left_,
522 TRight const & right_)
525 typedef SimpleType<TValue, TSpec> TLeft;
526 typedef typename CompareType<TLeft, TRight>::Type TCompareType;
527 return convert<TCompareType>(left_) == convert<TCompareType>(right_);
530 template <typename TLeft, typename TValue, typename TSpec>
532 operator == (TLeft const & left_,
533 SimpleType<TValue, TSpec> const & right_)
536 typedef SimpleType<TValue, TSpec> TRight;
537 typedef typename CompareType<TRight, TLeft>::Type TCompareType;
538 return convert<TCompareType>(left_) == convert<TCompareType>(right_);
541 template <typename TLeftValue, typename TLeftSpec, typename TRightValue, typename TRightSpec>
543 operator == (SimpleType<TLeftValue, TLeftSpec> const & left_,
544 SimpleType<TRightValue, TRightSpec> const & right_)
547 typedef SimpleType<TLeftValue, TLeftSpec> TLeft;
548 typedef SimpleType<TRightValue, TRightSpec> TRight;
549 typedef typename CompareType<TLeft, TRight>::Type TCompareType;
550 return convert<TCompareType>(left_) == convert<TCompareType>(right_);
553 template <typename TValue, typename TSpec>
555 operator == (SimpleType<TValue, TSpec> const & left_,
556 SimpleType<TValue, TSpec> const & right_)
559 return convert<TValue>(left_) == convert<TValue>(right_);
563 template <typename TSpec, typename TValue, typename TSpec2>
565 operator == (Proxy<TSpec> const & left_,
566 SimpleType<TValue, TSpec2> const & right_)
569 typedef Proxy<TSpec> TLeft;
570 typedef SimpleType<TValue, TSpec> TRight;
571 typedef typename CompareType<TLeft, TRight>::Type TCompareType;
572 return convert<TCompareType>(left_) == convert<TCompareType>(right_);
574 template <typename TSpec, typename TValue, typename TSpec2>
576 operator == (SimpleType<TValue, TSpec2> const & left_,
577 Proxy<TSpec> const & right_)
580 typedef SimpleType<TValue, TSpec> TLeft;
581 typedef Proxy<TSpec> TRight;
582 typedef typename CompareType<TLeft, TRight>::Type TCompareType;
583 return convert<TCompareType>(left_) == convert<TCompareType>(right_);
587 //____________________________________________________________________________
590 template <typename TValue, typename TSpec, typename TRight>
592 operator != (SimpleType<TValue, TSpec> const & left_,
593 TRight const & right_)
596 typedef SimpleType<TValue, TSpec> TLeft;
597 typedef typename CompareType<TLeft, TRight>::Type TCompareType;
598 return convert<TCompareType>(left_) != convert<TCompareType>(right_);
601 template <typename TLeft, typename TValue, typename TSpec>
603 operator != (TLeft const & left_,
604 SimpleType<TValue, TSpec> const & right_)
607 typedef SimpleType<TValue, TSpec> TRight;
608 typedef typename CompareType<TRight, TLeft>::Type TCompareType;
609 return convert<TCompareType>(left_) != convert<TCompareType>(right_);
612 template <typename TLeftValue, typename TLeftSpec, typename TRightValue, typename TRightSpec>
614 operator != (SimpleType<TLeftValue, TLeftSpec> const & left_,
615 SimpleType<TRightValue, TRightSpec> const & right_)
618 typedef SimpleType<TLeftValue, TLeftSpec> TLeft;
619 typedef SimpleType<TRightValue, TRightSpec> TRight;
620 typedef typename CompareType<TLeft, TRight>::Type TCompareType;
621 return convert<TCompareType>(left_) != convert<TCompareType>(right_);
624 template <typename TValue, typename TSpec>
626 operator != (SimpleType<TValue, TSpec> const & left_,
627 SimpleType<TValue, TSpec> const & right_)
630 return convert<TValue>(left_) != convert<TValue>(right_);
634 template <typename TSpec, typename TValue, typename TSpec2>
636 operator != (Proxy<TSpec> const & left_,
637 SimpleType<TValue, TSpec2> const & right_)
640 typedef Proxy<TSpec> TLeft;
641 typedef SimpleType<TValue, TSpec> TRight;
642 typedef typename CompareType<TLeft, TRight>::Type TCompareType;
643 return convert<TCompareType>(left_) != convert<TCompareType>(right_);
645 template <typename TSpec, typename TValue, typename TSpec2>
647 operator != (SimpleType<TValue, TSpec2> const & left_,
648 Proxy<TSpec> const & right_)
651 typedef SimpleType<TValue, TSpec> TLeft;
652 typedef Proxy<TSpec> TRight;
653 typedef typename CompareType<TLeft, TRight>::Type TCompareType;
654 return convert<TCompareType>(left_) != convert<TCompareType>(right_);
658 //____________________________________________________________________________
661 template <typename TValue, typename TSpec, typename TRight>
663 operator < (SimpleType<TValue, TSpec> const & left_,
664 TRight const & right_)
667 typedef SimpleType<TValue, TSpec> TLeft;
668 typedef typename CompareType<TLeft, TRight>::Type TCompareType;
669 return convert<TCompareType>(left_) < convert<TCompareType>(right_);
672 template <typename TLeft, typename TValue, typename TSpec>
674 operator < (TLeft const & left_,
675 SimpleType<TValue, TSpec> const & right_)
678 typedef SimpleType<TValue, TSpec> TRight;
679 typedef typename CompareType<TRight, TLeft>::Type TCompareType;
680 return convert<TCompareType>(left_) < convert<TCompareType>(right_);
683 template <typename TLeftValue, typename TLeftSpec, typename TRightValue, typename TRightSpec>
685 operator < (SimpleType<TLeftValue, TLeftSpec> const & left_,
686 SimpleType<TRightValue, TRightSpec> const & right_)
689 typedef SimpleType<TLeftValue, TLeftSpec> TLeft;
690 typedef SimpleType<TRightValue, TRightSpec> TRight;
691 typedef typename CompareType<TLeft, TRight>::Type TCompareType;
692 return convert<TCompareType>(left_) < convert<TCompareType>(right_);
695 template <typename TValue, typename TSpec>
697 operator < (SimpleType<TValue, TSpec> const & left_,
698 SimpleType<TValue, TSpec> const & right_)
701 return convert<TValue>(left_) < convert<TValue>(right_);
705 template <typename TSpec, typename TValue, typename TSpec2>
707 operator < (Proxy<TSpec> const & left_,
708 SimpleType<TValue, TSpec2> const & right_)
711 typedef Proxy<TSpec> TLeft;
712 typedef SimpleType<TValue, TSpec> TRight;
713 typedef typename CompareType<TLeft, TRight>::Type TCompareType;
714 return convert<TCompareType>(left_) < convert<TCompareType>(right_);
716 template <typename TSpec, typename TValue, typename TSpec2>
718 operator < (SimpleType<TValue, TSpec2> const & left_,
719 Proxy<TSpec> const & right_)
722 typedef SimpleType<TValue, TSpec> TLeft;
723 typedef Proxy<TSpec> TRight;
724 typedef typename CompareType<TLeft, TRight>::Type TCompareType;
725 return convert<TCompareType>(left_) < convert<TCompareType>(right_);
729 //____________________________________________________________________________
732 template <typename TValue, typename TSpec, typename TRight>
734 operator <= (SimpleType<TValue, TSpec> const & left_,
735 TRight const & right_)
738 typedef SimpleType<TValue, TSpec> TLeft;
739 typedef typename CompareType<TLeft, TRight>::Type TCompareType;
740 return convert<TCompareType>(left_) <= convert<TCompareType>(right_);
743 template <typename TLeft, typename TValue, typename TSpec>
745 operator <= (TLeft const & left_,
746 SimpleType<TValue, TSpec> const & right_)
749 typedef SimpleType<TValue, TSpec> TRight;
750 typedef typename CompareType<TRight, TLeft>::Type TCompareType;
751 return convert<TCompareType>(left_) <= convert<TCompareType>(right_);
754 template <typename TLeftValue, typename TLeftSpec, typename TRightValue, typename TRightSpec>
756 operator <= (SimpleType<TLeftValue, TLeftSpec> const & left_,
757 SimpleType<TRightValue, TRightSpec> const & right_)
760 typedef SimpleType<TLeftValue, TLeftSpec> TLeft;
761 typedef SimpleType<TRightValue, TRightSpec> TRight;
762 typedef typename CompareType<TLeft, TRight>::Type TCompareType;
763 return convert<TCompareType>(left_) <= convert<TCompareType>(right_);
766 template <typename TValue, typename TSpec>
768 operator <= (SimpleType<TValue, TSpec> const & left_,
769 SimpleType<TValue, TSpec> const & right_)
772 return convert<TValue>(left_) <= convert<TValue>(right_);
776 template <typename TSpec, typename TValue, typename TSpec2>
778 operator <= (Proxy<TSpec> const & left_,
779 SimpleType<TValue, TSpec2> const & right_)
782 typedef Proxy<TSpec> TLeft;
783 typedef SimpleType<TValue, TSpec> TRight;
784 typedef typename CompareType<TLeft, TRight>::Type TCompareType;
785 return convert<TCompareType>(left_) <= convert<TCompareType>(right_);
787 template <typename TSpec, typename TValue, typename TSpec2>
789 operator <= (SimpleType<TValue, TSpec2> const & left_,
790 Proxy<TSpec> const & right_)
793 typedef SimpleType<TValue, TSpec> TLeft;
794 typedef Proxy<TSpec> TRight;
795 typedef typename CompareType<TLeft, TRight>::Type TCompareType;
796 return convert<TCompareType>(left_) <= convert<TCompareType>(right_);
801 //____________________________________________________________________________
804 template <typename TValue, typename TSpec, typename TRight>
806 operator > (SimpleType<TValue, TSpec> const & left_,
807 TRight const & right_)
810 typedef SimpleType<TValue, TSpec> TLeft;
811 typedef typename CompareType<TLeft, TRight>::Type TCompareType;
812 return convert<TCompareType>(left_) > convert<TCompareType>(right_);
815 template <typename TLeft, typename TValue, typename TSpec>
817 operator > (TLeft const & left_,
818 SimpleType<TValue, TSpec> const & right_)
821 typedef SimpleType<TValue, TSpec> TRight;
822 typedef typename CompareType<TRight, TLeft>::Type TCompareType;
823 return convert<TCompareType>(left_) > convert<TCompareType>(right_);
826 template <typename TLeftValue, typename TLeftSpec, typename TRightValue, typename TRightSpec>
828 operator > (SimpleType<TLeftValue, TLeftSpec> const & left_,
829 SimpleType<TRightValue, TRightSpec> const & right_)
832 typedef SimpleType<TLeftValue, TLeftSpec> TLeft;
833 typedef SimpleType<TRightValue, TRightSpec> TRight;
834 typedef typename CompareType<TLeft, TRight>::Type TCompareType;
835 return convert<TCompareType>(left_) > convert<TCompareType>(right_);
838 template <typename TValue, typename TSpec>
840 operator > (SimpleType<TValue, TSpec> const & left_,
841 SimpleType<TValue, TSpec> const & right_)
844 return convert<TValue>(left_) > convert<TValue>(right_);
848 template <typename TSpec, typename TValue, typename TSpec2>
850 operator > (Proxy<TSpec> const & left_,
851 SimpleType<TValue, TSpec2> const & right_)
854 typedef Proxy<TSpec> TLeft;
855 typedef SimpleType<TValue, TSpec> TRight;
856 typedef typename CompareType<TLeft, TRight>::Type TCompareType;
857 return convert<TCompareType>(left_) > convert<TCompareType>(right_);
859 template <typename TSpec, typename TValue, typename TSpec2>
861 operator > (SimpleType<TValue, TSpec2> const & left_,
862 Proxy<TSpec> const & right_)
865 typedef SimpleType<TValue, TSpec> TLeft;
866 typedef Proxy<TSpec> TRight;
867 typedef typename CompareType<TLeft, TRight>::Type TCompareType;
868 return convert<TCompareType>(left_) > convert<TCompareType>(right_);
872 //____________________________________________________________________________
875 template <typename TValue, typename TSpec, typename TRight>
877 operator >= (SimpleType<TValue, TSpec> const & left_,
878 TRight const & right_)
881 typedef SimpleType<TValue, TSpec> TLeft;
882 typedef typename CompareType<TLeft, TRight>::Type TCompareType;
883 return convert<TCompareType>(left_) >= convert<TCompareType>(right_);
886 template <typename TLeft, typename TValue, typename TSpec>
888 operator >= (TLeft const & left_,
889 SimpleType<TValue, TSpec> const & right_)
892 typedef SimpleType<TValue, TSpec> TRight;
893 typedef typename CompareType<TRight, TLeft>::Type TCompareType;
894 return convert<TCompareType>(left_) >= convert<TCompareType>(right_);
897 template <typename TLeftValue, typename TLeftSpec, typename TRightValue, typename TRightSpec>
899 operator >= (SimpleType<TLeftValue, TLeftSpec> const & left_,
900 SimpleType<TRightValue, TRightSpec> const & right_)
903 typedef SimpleType<TLeftValue, TLeftSpec> TLeft;
904 typedef SimpleType<TRightValue, TRightSpec> TRight;
905 typedef typename CompareType<TLeft, TRight>::Type TCompareType;
906 return convert<TCompareType>(left_) >= convert<TCompareType>(right_);
909 template <typename TValue, typename TSpec>
911 operator >= (SimpleType<TValue, TSpec> const & left_,
912 SimpleType<TValue, TSpec> const & right_)
915 return convert<TValue>(left_) >= convert<TValue>(right_);
919 template <typename TSpec, typename TValue, typename TSpec2>
921 operator >= (Proxy<TSpec> const & left_,
922 SimpleType<TValue, TSpec2> const & right_)
925 typedef Proxy<TSpec> TLeft;
926 typedef SimpleType<TValue, TSpec> TRight;
927 typedef typename CompareType<TLeft, TRight>::Type TCompareType;
928 return convert<TCompareType>(left_) >= convert<TCompareType>(right_);
930 template <typename TSpec, typename TValue, typename TSpec2>
932 operator >= (SimpleType<TValue, TSpec2> const & left_,
933 Proxy<TSpec> const & right_)
936 typedef SimpleType<TValue, TSpec> TLeft;
937 typedef Proxy<TSpec> TRight;
938 typedef typename CompareType<TLeft, TRight>::Type TCompareType;
939 return convert<TCompareType>(left_) >= convert<TCompareType>(right_);
943 //////////////////////////////////////////////////////////////////////////////
945 template<typename _T, typename TSpec>
947 bool lexLess(SimpleType<_T, TSpec> const &_Left, SimpleType<_T, TSpec> const &_Right)
948 { // return lexicographical _Left < _Right
949 typedef typename _MakeUnsigned<_T>::Type TUnsigned;
950 return (TUnsigned)(_Left.value) < (TUnsigned)(_Right.value);
953 //////////////////////////////////////////////////////////////////////////////
955 template <typename TValue, typename TSpec>
956 inline SimpleType<TValue, TSpec> &
957 operator ++ (SimpleType<TValue, TSpec> & me)
962 template <typename TValue, typename TSpec>
963 inline SimpleType<TValue, TSpec>
964 operator ++ (SimpleType<TValue, TSpec> & me,
967 SimpleType<TValue, TSpec> dummy = me;
972 //////////////////////////////////////////////////////////////////////////////
974 template <typename TValue, typename TSpec>
975 inline SimpleType<TValue, TSpec> &
976 operator -- (SimpleType<TValue, TSpec> & me)
981 template <typename TValue, typename TSpec>
982 inline SimpleType<TValue, TSpec>
983 operator -- (SimpleType<TValue, TSpec> & me,
986 SimpleType<TValue, TSpec> dummy = me;
991 //////////////////////////////////////////////////////////////////////////////
992 //////////////////////////////////////////////////////////////////////////////
997 ..summary:Alphabet for DNA.
998 ..general:Class.SimpleType
1001 ...text:The @Metafunction.ValueSize@ of $Dna$ is 4.
1002 The nucleotides are enumerated this way: $'A' = 0, 'C' = 1, 'G' = 2, 'T' = 3$.
1003 ...text:Objects of type $Dna$ can be converted to various other types and vice versa.
1004 An object that has a value not in ${'A', 'C', 'G', 'T'}$ is converted to $'A'$.
1005 ...text:$Dna$ is typedef for $SimpleType<char,_Dna>$, while $_Dna$ is a helper
1006 specialization tag class.
1007 ..see:Metafunction.ValueSize
1011 typedef SimpleType<unsigned char,_Dna> Dna;
1013 template <> struct ValueSize< Dna > { enum { VALUE = 4 }; };
1014 template <> struct BitsPerValue< Dna > { enum { VALUE = 2 }; };
1016 //____________________________________________________________________________
1021 ..summary:Alphabet for DNA including 'N' character.
1022 ..general:Class.SimpleType
1025 ...text:The @Metafunction.ValueSize@ of $Dna5$ is 5.
1026 The nucleotides are enumerated this way: $'A' = 0, 'C' = 1, 'G' = 2, 'T' = 3$.
1027 The 'N' character ("unkown nucleotide") is encoded by 4.
1028 ...text:Objects of type $Dna5$ can be converted to various other types and vice versa.
1029 An object that has a value not in ${'A', 'C', 'G', 'T'}$ is converted to $'N'$.
1030 ...text:$Dna5$ is typedef for $SimpleType<char,_Dna5>$, while $_Dna5$ is a helper
1031 specialization tag class.
1032 ..see:Metafunction.ValueSize
1035 typedef SimpleType<unsigned char, _Dna5> Dna5;
1037 template <> struct ValueSize< Dna5 > { enum { VALUE = 5 }; };
1038 template <> struct BitsPerValue< Dna5 > { enum { VALUE = 3 }; };
1040 //____________________________________________________________________________
1045 ..summary:Iupac code for DNA.
1046 ..general:Class.SimpleType
1049 ...text:The @Metafunction.ValueSize@ of $Iupac$ is 16.
1050 The nucleotides are enumerated from 0 to 15 in this order:
1051 'U'=0, 'T', 'A', 'W', 'C', 'Y', 'M', 'H', 'G', 'K', 'R', 'D', 'S', 'B', 'V', 'N'=15.
1052 ...text:Objects of type $Iupac$ can be converted to various other types and vice versa.
1053 Unkown values are converted to $'N'$.
1054 ...text:$Iupac$ is typedef for $SimpleType<char,_Iupac>$, while $_Iupac$ is a helper
1055 specialization tag class.
1056 ..see:Metafunction.ValueSize
1059 typedef SimpleType<unsigned char, _Iupac> Iupac;
1061 template <> struct ValueSize< Iupac > { enum { VALUE = 16 }; };
1062 template <> struct BitsPerValue< Iupac > { enum { VALUE = 4 }; };
1065 //____________________________________________________________________________
1070 ..summary:Iupac code for amino acids.
1071 ..general:Class.SimpleType
1072 ..signature:AminoAcid
1074 ...text:The @Metafunction.ValueSize@ of $AminoAcid$ is 24.
1075 ...text:The amino acids are enumerated from 0 to 15 in this order:
1076 ...text:'A'=0, 'R', 'N', 'D', 'C', 'Q', 'E', 'G', 'H', 'I', 'L', 'K', 'M', 'F', 'P', 'S', 'T', 'W', 'Y', 'V'=19.
1077 ...text:The remaining 4 symbols are:
1078 ...text: 'B'=20 (Aspartic Acid, Asparagine), 'Z'=21 (Glutamic Acid, Glutamine), 'X'=22 (unknown), '*'=23 (terminator)
1079 ...text:Objects of type $AminoAcid$ can be converted to $char$ and vice versa.
1080 Unkown values are converted to $'X'$.
1081 ...text:$AminoAcid$ is typedef for $SimpleType<char,_AminoAcid>$, while $_AminoAcid$ is a helper
1082 specialization tag class.
1083 ..see:Metafunction.ValueSize
1085 struct _AminoAcid {};
1086 typedef SimpleType<unsigned char, _AminoAcid> AminoAcid;
1088 template <> struct ValueSize< AminoAcid > { enum { VALUE = 24 }; };
1089 template <> struct BitsPerValue< AminoAcid > { enum { VALUE = 5 }; };
1091 //////////////////////////////////////////////////////////////////////////////
1094 inline void assign(Ascii & c_target,
1098 c_target = _Translate_Table_Dna5_2_Ascii<>::VALUE[source.value];
1100 //____________________________________________________________________________
1102 inline void assign(Ascii & c_target,
1103 Dna5 const & source)
1106 c_target = _Translate_Table_Dna5_2_Ascii<>::VALUE[source.value];
1108 //____________________________________________________________________________
1110 inline void assign(Ascii & c_target, Iupac const & source)
1113 c_target = _Translate_Table_Iupac_2_Ascii<>::VALUE[source.value];
1115 //____________________________________________________________________________
1117 inline void assign(Ascii & c_target, AminoAcid const & source)
1120 c_target = _Translate_Table_AA_2_Ascii<>::VALUE[source.value];
1123 //////////////////////////////////////////////////////////////////////////////
1127 struct CompareType<Dna, Byte> { typedef Dna Type; };
1128 inline void assign(Dna & target, Byte c_source)
1131 target.value = _Translate_Table_Byte_2_Dna<>::VALUE[c_source];
1133 //____________________________________________________________________________
1136 struct CompareType<Dna, Ascii> { typedef Dna Type; };
1137 inline void assign(Dna & target, Ascii c_source)
1140 target.value = _Translate_Table_Ascii_2_Dna<>::VALUE[(unsigned char)c_source];
1142 //____________________________________________________________________________
1145 struct CompareType<Dna, Unicode> { typedef Dna Type; };
1146 inline void assign(Dna & target, Unicode c_source)
1149 target.value = _Translate_Table_Ascii_2_Dna<>::VALUE[(unsigned char) c_source];
1151 //____________________________________________________________________________
1154 struct CompareType<Dna, Dna5> { typedef Dna Type; };
1155 inline void assign(Dna & target, Dna5 const & c_source)
1158 target.value = c_source.value & 0x03;
1160 //____________________________________________________________________________
1163 struct CompareType<Dna, Iupac> { typedef Dna Type; };
1164 inline void assign(Dna & target, Iupac const & source)
1167 target.value = _Translate_Table_Iupac_2_Dna<>::VALUE[source.value];
1170 //////////////////////////////////////////////////////////////////////////////
1174 struct CompareType<Dna5, Byte> { typedef Dna5 Type; };
1175 inline void assign(Dna5 & target, Byte c_source)
1178 target.value = _Translate_Table_Byte_2_Dna5<>::VALUE[c_source];
1180 //____________________________________________________________________________
1183 struct CompareType<Dna5, Ascii> { typedef Dna5 Type; };
1184 inline void assign(Dna5 & target, Ascii c_source)
1187 target.value = _Translate_Table_Ascii_2_Dna5<>::VALUE[(unsigned char) c_source];
1189 //____________________________________________________________________________
1192 struct CompareType<Dna5, Unicode> { typedef Dna5 Type; };
1193 inline void assign(Dna5 & target, Unicode c_source)
1196 target.value = _Translate_Table_Ascii_2_Dna5<>::VALUE[(unsigned char) c_source];
1198 //____________________________________________________________________________
1201 struct CompareType<Dna5, Iupac> { typedef Dna5 Type; };
1202 inline void assign(Dna5 & target, Iupac const & source)
1205 target.value = _Translate_Table_Iupac_2_Dna5<>::VALUE[source.value];
1208 //____________________________________________________________________________
1211 struct CompareType<Dna5, Dna> { typedef Dna Type; };
1212 inline void assign(Dna5 & target, Dna const & c_source)
1215 target.value = c_source.value;
1218 //////////////////////////////////////////////////////////////////////////////
1222 struct CompareType<Iupac, Byte> { typedef Iupac Type; };
1223 inline void assign(Iupac & target, Byte c_source)
1226 target.value = _Translate_Table_Byte_2_Iupac<>::VALUE[c_source];
1228 //____________________________________________________________________________
1231 struct CompareType<Iupac, Ascii> { typedef Iupac Type; };
1232 inline void assign(Iupac & target, Ascii c_source)
1235 target.value = _Translate_Table_Ascii_2_Iupac<>::VALUE[(unsigned char) c_source];
1237 //____________________________________________________________________________
1240 struct CompareType<Iupac, Unicode> { typedef Iupac Type; };
1241 inline void assign(Iupac & target, Unicode c_source)
1244 target.value = _Translate_Table_Ascii_2_Iupac<>::VALUE[(unsigned char) c_source];
1246 //____________________________________________________________________________
1248 inline void assign(Iupac & target, Dna const & source)
1251 target.value = _Translate_Table_Dna5_2_Iupac<>::VALUE[source.value];
1253 //____________________________________________________________________________
1255 inline void assign(Iupac & target, Dna5 const & source)
1258 target.value = _Translate_Table_Dna5_2_Iupac<>::VALUE[source.value];
1261 //////////////////////////////////////////////////////////////////////////////
1262 //Amino Acid (5 bits)
1265 struct CompareType<AminoAcid, Byte> { typedef AminoAcid Type; };
1266 inline void assign(AminoAcid & target, Byte c_source)
1269 target.value = _Translate_Table_Byte_2_AA<>::VALUE[c_source];
1271 //____________________________________________________________________________
1274 struct CompareType<AminoAcid, Ascii> { typedef AminoAcid Type; };
1275 inline void assign(AminoAcid & target, Ascii c_source)
1278 target.value = _Translate_Table_Ascii_2_AA<>::VALUE[(unsigned char) c_source];
1280 //____________________________________________________________________________
1283 struct CompareType<AminoAcid, Unicode> { typedef AminoAcid Type; };
1284 inline void assign(AminoAcid & target, Unicode c_source)
1287 target.value = _Translate_Table_Ascii_2_AA<>::VALUE[(unsigned char) c_source];
1290 //////////////////////////////////////////////////////////////////////////////
1293 //////////////////////////////////////////////////////////////////////////////
1294 }// namespace SEQAN_NAMESPACE_MAIN
1296 #endif //#ifndef SEQAN_HEADER_...