# Class ModifiedString
Allows you to generate modified versions of a string in a non-inplace way.

Implements | ContainerConcept
All Subcl's | ModCyclicShapeModifiedString, ModPaddingString, ModReverseString, ModViewModifiedString
All Impl'd | AssignableConcept, ContainerConcept, DestructibleConcept
Defined in | <seqan/modifier.h>
Signature | `template <typename THost[, typename TSpec]> class ModifiedString;`

## Template Parameters

`THost` | The host sequence.
`TSpec` | The specialization tag, defaults to `void`.

## Member Function Overview

### Member Functions Inherited From AssignableConcept

- `operator=`

## Interface Function Overview

### Interface Functions Inherited From AssignableConcept

- `assign`
- `set`
- `move`

### Interface Functions Inherited From ContainerConcept

- `begin`
- `end`
- `length`
- `empty`
- `swap`
- `writeValue`
- `write`
- `getObjectId`
- `moveValue`
- `append`
- `appendValue`
- `shrinkToFit`
- `directionIterator`

## Interface Metafunction Overview

### Interface Metafunctions Inherited From ContainerConcept

- `DefaultGetIteratorSpec`
- `DefaultIteratorSpec`
- `Difference`
- `DirectionIterator`
- `GetValue`
- `Iterator`
- `Position`
- `Reference`
- `Size`
- `Value`

## Detailed Description

`THost` can also be a modified string, so you can create nest modified strings to create custom combinations.

### Examples

#### Using ModReverseString

    #include <seqan/basic.h>
    #include <seqan/sequence.h>
    #include <seqan/stream.h>  // for I/O
    #include <seqan/modifier.h>

    using namespace seqan;

    int main()
    {
        String<Dna> seq = "TATACGCGAAAA";
        ModifiedString<String<Dna>, ModReverse> myModifier(seq);

        std::cout << seq << std::endl;
        std::cout << myModifier << std::endl;
        replace(seq, 8, 12, "TTTT");
        std::cout << std::endl;
        std::cout << seq << std::endl;
        std::cout << myModifier << std::endl;

        return 0;
    }

Demo: demos/dox/modifier/modified_string.cpp

The output is als follows:

    TATACGCGAAAA
    AAAAGCGCATAT

    TATACGCGTTTT
    TTTTGCGCATAT

#### Using a custom functor for ModViewString

    #include <iostream>
    #include <seqan/stream.h>
    #include <seqan/modifier.h>

    using namespace seqan;

    // A user-defined modifier that transforms all characters to upper case.
    struct MyFunctor :
        public std::unary_function<char, char>
    {
        inline char operator()(char x) const
        {
            if (('a' <= x) && (x <= 'z'))
                return x + ('A' - 'a');

            return x;
        }

    };

    int main()
    {
        // Construct a String and a ModifiedString over it.
        String<char> myString = "A man, a plan, a canal-Panama";
        ModifiedString<String<char>, ModView<MyFunctor> > myModifier(myString);

        // Print the result and demonstrate that the changes to myString are also
        // visible through myModifier.
        std::cout << myString << "\n"
                  << myModifier << "\n";

        replace(myString, 9, 9, "master ");

        std::cout << myString << "\n"
                  << myModifier << "\n";

        return 0;
    }

Demo: demos/dox/modifier/modified_string_mod_view.cpp

The output is as follows:

    A man, a plan, a canal-Panama
    A MAN, A PLAN, A CANAL-PANAMA
    A man, a master plan, a canal-Panama
    A MAN, A MASTER PLAN, A CANAL-PANAMA

#### Using nested modified strings.

    #include <iostream>
    #include <seqan/modifier.h>
    #include <seqan/stream.h>

    using namespace seqan;

    int main()
    {
        // A nested modifier.
        typedef ModifiedString<String<Dna>, ModComplementDna>   TMyComplement;
        typedef ModifiedString<TMyComplement, ModReverse>       TMyReverseComplement;

        // The original string.
        String<Dna> myString = "attacgg";
        // A reverse complemented string.
        TMyReverseComplement myReverseComplement(myString);
        std::cout << myString << "\n"
                  << myReverseComplement << "\n";

        replace(myString, 1, 1, "cgt");
        std::cout << myString << "\n"
                  << myReverseComplement << "\n"
                  << DnaStringReverseComplement(myString) << "\n";

        return 0;
    }

Demo: demos/dox/modifier/modified_string_nested.cpp

The output is as follows:

    ATTACGG
    CCGTAAT
    ACGTTTACGG
    CCGTAAACGT
    CCGTAAACGT

#### Dox Sources

    /*!
     * @class ModifiedString
     *
     * @implements ContainerConcept
     *
     * @headerfile <seqan/modifier.h>
     *
     * @brief Allows you to generate modified versions of a string in a non-inplace
     *        way.
     *
     * @signature template <typename THost[, typename TSpec]> class ModifiedString;
     *
     * @tparam THost The host sequence.
     * @tparam TSpec The specialization tag, defaults to <tt>void</tt>.
     *
     * <tt>THost</tt> can also be a modified string, so you can create nest modified
     * strings to create custom combinations.
     *
     * @section Examples
     *
     * @subsection Using ModReverseString
     *
     * @include demos/dox/modifier/modified_string.cpp
     *
     * The output is als follows:
     *
     * @include demos/dox/modifier/modified_string.cpp.stdout
     *
     * @subsection Using a custom functor for ModViewString
     *
     * @include demos/dox/modifier/modified_string_mod_view.cpp
     *
     * The output is as follows:
     *
     * @include demos/dox/modifier/modified_string_mod_view.cpp.stdout
     *
     * @subsection Using nested modified strings.
     *
     * @include demos/dox/modifier/modified_string_nested.cpp
     *
     * The output is as follows:
     *
     * @include demos/dox/modifier/modified_string_nested.cpp.stdout
     */