#ifndef _TCL_LISTVAR_H_
#define _TCL_LISTVAR_H_

#include "tcl_var.h"

/**
 * \brief Represens shell variable of list type
 *
 * \date 01-11-2006
 *
 * \author Ondrej Svejdar
 *
 * \todo 
 *
 * \bug 
 *
 */
class TclListVar:public TclVar
{
	typedef list<string> t_values;
	t_values values;
	char* value;

	void update();
protected:
	void doSerialize(TiXmlElement& element) const;
	void doDeserialize(const TiXmlElement& element);
public:
	static TXmlObject* newObject()
	{
		return new TclListVar(TclInterp::defaultInterp);
	}

	typedef t_values::iterator iterator;
	typedef t_values::const_iterator const_iterator;
	
	static const char* type;
	const char* getType() const;

	/**
	 * \param interp interpret
	 */
	TclListVar(Ptr<TclInterp>& interp);

    /**
     * \brief Add new element at the end of the list
	 * \param value string to add
     */
    void push_back(const string& value);
	
	
	/**
	 * \brief Remove element at index index
	 * \param index 
	 */
	void remove(int index);
	
	
	/**
	 * \brief Clear all elements
	 */
	void clear();

	/**
	 * \brief Return iterator to beginning of the list
	 */
	const_iterator begin() const;
	
	/**
	 * \brief Return iterator to end of the list
	 */
	const_iterator end() const;


	/**
	 * \brief Returns size of list
	 * \return size of list
	 */
	int size() const;


	/**
	 * \brief Return list representation as string.
	 *
	 * For empty list returns "{}", for list with
	 * element "a" returns {a}, for list with element "a" and "b" {a b} and so on.
	 *
	 * \return list representation as string 
	 */
	const string& getText() const;
};

#endif/*_TCL_LISTVAR_H_*/
