/***************************************************************************
                          SIMPLY POWERFUL TOOLKIT (SPTK)
                          CExcelNumericFormat.h  -  description
                             -------------------
    begin                : Fri May 6 2004
    copyright            : (C) 2000-2006 by Alexey S.Parshin
    email                : alexeyp@gmail.com
 ***************************************************************************/

/***************************************************************************
   This library is free software; you can redistribute it and/or modify it 
   under the terms of the GNU Library General Public License as published by
   the Free Software Foundation; either version 2 of the License, or (at 
   your option) any later version.

   This library is distributed in the hope that it will be useful, but 
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
   General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; if not, write to the Free Software Foundation, 
   Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.

   Please report all bugs and problems to "alexeyp@gmail.com"
 ***************************************************************************/

#ifndef __CEXCELNUMERICFORMAT_H__
#define __CEXCELNUMERICFORMAT_H__

#include <sptk3/CVariant.h>

#include <sptk3/excel/CExcelRecordsBuffer.h>

#include <map>

namespace sptk {

   /// @addtogroup excel Excel Classes
   /// @{

   /// The numeric format descriptor
	class CExcelNumericFormat {
		CVariantType   m_kind;           ///< Format data type
		unsigned       m_index;          ///< Format index
		std::string    m_format;         ///< Format string
	public:
      /// Constructor
      /// @param kind CVariantType, format data type
      /// @param index unsigned, format index
      /// @param format CString, format string
		CExcelNumericFormat(CVariantType kind,unsigned index,std::string format);

      /// Default constructor.
      /// The missing 'kind' parameter is guessed from the format string
      /// @param index unsigned, format index
      /// @param format CString, format string
		CExcelNumericFormat(unsigned index=0,std::string format="");

      /// Copy constructor
      /// @param nf const CExcelNumericFormat&, numeric format to copy from
		CExcelNumericFormat(const CExcelNumericFormat& nf);

		CVariantType kind() const { return m_kind; }  ///< Returns format data type
		unsigned index() const { return m_index; }    ///< Returns format index

		std::string format() const { return m_format; }   ///< Returns format string
		void format(const char *f) { m_format = f; }  ///< Sets format string
	};

   /// The list of an Excel numeric formats
	class CExcelNumericFormats : public std::map<int,CExcelNumericFormat *> {
	public:
      /// Constructor
		CExcelNumericFormats()  {}

      /// Destructor
		~CExcelNumericFormats() { clear(); }

      /// Cleaner
		void clear();

      /// Encodes FORMAT records into internal Excel format
		void saveRecords(CExcelRecordsBuffer& records);
	};
   /// @}
}
#endif
