#ifndef LISTSTRING_HPP
#define LISTSTRING_HPP

#include <string>
#include <iostream>

/** @brief Double linked List, with bugs */
class ListString
{
    unsigned m_size;

    /** Internal private class, you usually call it *Maillon* */
    struct Cell; // Classe interne en PIMPL

    Cell * const m_first;
    Cell * const m_last;

public:    
    class Position;

    ListString();
    ~ListString();
    void push_back(const std::string & value);
    void insert(const Position &p, const std::string & value);
    Position find(const std::string & value) const;
    Position begin() const;

    friend std::ostream& operator<<(std::ostream & os, const ListString & list);
    unsigned int size() const;
};



/** @brief Une position dans la liste */
class ListString::Position {
    friend class ListString;
    Cell* m_cell;
protected:
    Position(Cell *cell);
public:
    /** @brief Move to the next cell in the list */
    void inc();
    /** @brief return true if the Position holds a value */
    bool valid() const;
    /** @brief Return the value contained in the cell */
    const std::string & value() const;
};


std::ostream& operator<<(std::ostream & os, const ListString & list);

void affiche(ListString liste);

#endif // LISTSTRING_HPP
