Spec
CStyle StringAllows adaption of strings to C-style strings.
Extends | String |
---|---|
All Extended | String |
All Impl'd | AssignableConcept, ContainerConcept, DestructibleConcept, ForwardContainerConcept, RandomAccessContainerConcept, ReversibleContainerConcept, SegmentableConcept, StringConcept, TextConcept |
Defined in | <seqan/sequence.h> |
Signature |
template <typename TValue, typename TCStyle>
class String<TValue, CStyle>;
|
Template Parameters
TValue |
The value type, that is the type of the items/characters stored in the string.Use Value to get the value type for a given class. |
---|
Member Function Overview
Member Functions Inherited From String
Member Functions Inherited From AssignableConcept
Member Functions Inherited From RandomAccessContainerConcept
Interface Function Overview
Interface Functions Inherited From String
Interface Functions Inherited From AssignableConcept
Interface Functions Inherited From ContainerConcept
writeValue
write
begin
end
length
empty
swap
getObjectId
moveValue
append
appendValue
shrinkToFit
directionIterator
Interface Functions Inherited From RandomAccessContainerConcept
Interface Functions Inherited From SegmentableConcept
Interface Functions Inherited From StringConcept
iter
append
appendValue
front
back
resize
clear
erase
eraseFront
eraseBack
capacity
computeGenerousCapacity
insert
insertValue
replace
Interface Functions Inherited From TextConcept
Interface Metafunction Overview
Interface Metafunctions Inherited From ContainerConcept
DefaultGetIteratorSpec
DefaultIteratorSpec
Difference
DirectionIterator
GetValue
Iterator
Position
Reference
Size
Value
Interface Metafunctions Inherited From SegmentableConcept
Interface Metafunctions Inherited From TextConcept
Detailed Description
Assigning a string TValue * to a CStyle String will not create a copy of the string but just copy pointers.
Remarks
The purpose of this class is to access to the content of a sequence in a "zero terminated string" style. This can be useful if SeqAn classes has to be integrated in programs that use char arrays to store strings. Instances of String<TValue, CStyle> can implicitely converted to a TValue * that points to a zero terminated CStyle of TValue.
The stored c-style string object can be set by constructors or assignment. The content of a c-style string can eighter be stored in a separate buffer, that is the source string is copied. Or the buffer of the source string itself is used instead, in this case the c-style string depends on the source string and gets invalid as soon as the buffer of the source string is destroyed.
Hence, this class is a kind of adaptor from an arbitrary SeqAn string to char arrays. Of course, the opposite way is possible too.
Examples
// Create a string str:
String<char> str = "this is a test string";
// Create a c-style string object for str:
String<char, CStyle> cStyle = str;
// Now use cStyle as char array:
strcmp(cStyle, "compare it to this string");
If the c-style string is needed only temporarily, the function toCString can be used:
String<char> str = "this is a test string";
strcmp(toCString(str), "compare it to this string");