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: string_array.h,v 1.1 2008/08/25 16:20:04 langmead Exp $
19 ==========================================================================*/
21 #ifndef SEQAN_HEADER_SEQUENCE_STRING_ARRAY_H
22 #define SEQAN_HEADER_SEQUENCE_STRING_ARRAY_H
25 namespace SEQAN_NAMESPACE_MAIN
31 ..general:Class.String
32 ..summary:Fast but non-expandable string.
33 ..signature:String<TValue, Array<size> >
34 ..param.TValue:The value type, that is the type of the items/characters stored in the string.
35 ...remarks:Use @Metafunction.Value@ to get the value type for a given class.
36 ..param.size:A positive integer that specifies the capacity of the string.
37 ...remarks:Note that the capacity of a stack string cannot be changed later.
39 //////////////////////////////////////////////////////////////////////////////
41 template <unsigned int ISize>
44 //////////////////////////////////////////////////////////////////////////////
46 template <typename TValue, unsigned int ISize>
47 class String<TValue, Array<ISize> >
50 mutable TValue data_begin[ISize];
53 //____________________________________________________________________________
59 data_end = data_begin;
62 template <typename TSource>
63 String(TSource & source)
66 data_end = data_begin;
67 assign(*this, source);
69 template <typename TSource>
70 String(TSource const & source)
73 data_end = data_begin;
74 assign(*this, source);
76 String(String const & source)
79 data_end = data_begin;
80 assign(*this, source);
83 template <typename TSource>
84 String & operator =(TSource const & source)
87 assign(*this, source);
90 String & operator =(String const & source)
93 assign(*this, source);
101 //____________________________________________________________________________
103 template <typename TPos>
104 inline typename Reference<String>::Type
105 operator [] (TPos pos)
108 return value(*this, pos);
111 template <typename TPos>
112 inline typename Reference<String const>::Type
113 operator [] (TPos pos) const
116 return value(*this, pos);
119 //____________________________________________________________________________
121 friend inline typename Iterator<String, Standard>::Type
126 return me.data_begin;
128 friend inline typename Iterator<String const, Standard>::Type
129 begin(String const & me,
133 return me.data_begin;
136 //____________________________________________________________________________
138 friend inline typename Iterator<String, Standard>::Type
145 friend inline typename Iterator<String const, Standard>::Type
146 end(String const & me,
153 //____________________________________________________________________________
163 capacity(String const &)
168 //____________________________________________________________________________
171 .Internal._setLength.param.object.type:Spec.Array String
179 me.data_end = me.data_begin + new_length;
182 //____________________________________________________________________________
187 //////////////////////////////////////////////////////////////////////////////
189 template <typename TValue, unsigned int ISize>
190 struct DefaultOverflowImplicit<String<TValue, Array<ISize> > >
195 template <typename TValue, unsigned int ISize>
196 struct DefaultOverflowImplicit<String<TValue, Array<ISize> > const >
201 //////////////////////////////////////////////////////////////////////////////
203 template <typename TValue, unsigned int ISize>
204 struct DefaultOverflowExplicit<String<TValue, Array<ISize> > >
209 template <typename TValue, unsigned int ISize>
210 struct DefaultOverflowExplicit<String<TValue, Array<ISize> > const >
215 //////////////////////////////////////////////////////////////////////////////
217 template <typename TValue, unsigned int ISize>
218 struct IsContiguous< String<TValue, Array<ISize> > >
221 enum { VALUE = true };
224 //////////////////////////////////////////////////////////////////////////////
226 ///.Metafunction.LENGTH.param.T.type:Spec.Array String
227 template <typename TValue, unsigned int ISize>
228 struct LENGTH< String<TValue, Array<ISize> > >
230 enum { VALUE = ISize };
233 //////////////////////////////////////////////////////////////////////////////
235 } //namespace SEQAN_NAMESPACE_MAIN
237 #endif //#ifndef SEQAN_HEADER_...