/* Cfour (C++ Common Console Classes)
 * Copyright (C) 2001 Jeffrey Bakker
 *
 * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *
 *  Author:              Jeffrey Bakker
 *  Filename:            cfconf.h
 *  File version:        1.0
 *
 *  ===========================================================================
 *
 *  Created on: Sept 2nd, 2001
 *
 *  ===========================================================================
 *
 *  Remark:
 *
 *  This is the class defintion for CFconf, a class which provides methods
 *  and data members for managing configuration files using XML tags.
 *
 *
 *  The CFconf class is incomplete, but what is there so far does compile.
 *  Currently, it can't handle any complex XML data structures, like any
 *  level of nesting or using subsections in a configuration file. This
 *  will change in the future versions of cfour.
 *
 *  ===========================================================================
 * _______. ..
 */


#ifndef _C4_ONF_H 
#define _C4_ONF_H 

#include <string> 
#include <vector> 
#include "cffile.h" 
#include "cfdatapair.h" 
using namespace std;

class CFconf {

 public:

  // constructors
  CFconf();
  CFconf(string filename, char io);
  //~CFconf();

  // file methods
  void load();
  void save();
  void backup();

  bool open_ifile(string file);
  bool open_ofile(string file);

  // conversion methods
  void set_doctype(string type);
  void XML_ize(CFdatapair pair);
  void deXML_ize(string pair);
  void to___XML();
  void from_XML();

  void read_new(CFdatapair inpair);
  void write_new();

  string s_tag(string tagname);
  string tag_e(string tagname);
  string _tag_(string tagname);

  void start();
  void end();

  void printpairs();

  void add(string name, string value);
  bool edit(string name, string value);

  // data memebers
  CFfile rcIO;

 protected:

  string rcfile;
  string doctype;
  vector<CFdatapair> Pairdata;
  vector<string>     XMLdata;
};

#endif  // _C4_ONF_H