/***************************************************************************
 *   Copyright (C) 2004 by Armando Navarro-Vazquez                         *
 *   uscqoanv@cesga.es                                                     *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program 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 General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef JCAMPDXPARSER_H
#define JCAMPDXPARSER_H

#include <vector>
#include <string>
#include <map>

#include <nmrparser.h>

/**
A Parser for the JCAMPDX file format
 
@author Armando Navarro-Vazquez
*/
class Spectrum;
class JCAMPDXParser : public SpectrumParser
{
public:
  JCAMPDXParser(QString& file);

  ~JCAMPDXParser();

  Spectrum* ParseFile();
private:
Spectrum* GetSpectrum(std::ifstream& file,std::string& line);
private:
  
  float GetValue(const std::string& val, int& dup,bool& diff);
  void GetData(Spectrum& spectrum,std::ifstream& jcampfile);
  void GetTable(Spectrum& spectrum, std::ifstream& jcampfile);
  void BuildMap();

class jctokenizer : public std::vector<std::string>
  {
  public:
    jctokenizer(const std::string &rStr, const std::string &rDelimiters = " ,\n");
  };
  std::map< char, int > m_diffmap;

};

#endif
