// file: param_file.h
//
// this file defines the param_file class
//

// make sure definitions are only made once
//
#ifndef __ISIP_PARAM_FILE
#define __ISIP_PARAM_FILE

// isip include files
//
#ifndef __ISIP_INTEGRAL
#include <integral.h>
#endif

// Param_file: a class that handles parsing parameter files
//

class Param_file {
  
  //---------------------------------------------------------------------------
  //
  // protected data
  //
  //---------------------------------------------------------------------------
protected:
  
  // the debug level
  //
  int_4 debug_level_d;

  // the name of the parameter file
  //
  char_1* param_file_d;

  // magic string that will appear at the beginning of the file
  //
  char_1* magic_string_d;

  // storage for the parameters and values
  //
  char_1** params_d; 
  char_1** values_d;

  // define delimiters and formats
  //
  char_1 terminator_char_d;
  char_1 assignment_char_d;
  char_1 comment_char_d;
  
  char_1* parse_statement_format_d;
  char_1* load_statement_format_d;
  
  // count the number of parameters
  //
  int_4 num_params_d;
  
  //---------------------------------------------------------------------------
  //
  // public methods
  //
  //---------------------------------------------------------------------------
public:
 
  // required methods
  //
  char_1* name_cc();
  volatile void error_handler_cc(char_1* method, char_1* message);
  int_4 size_cc();
  
  // constructors/destructors
  // 
  // default behavior is name = value;
  // use overloaded if need to change behavior
  //
  ~Param_file();
  Param_file();
  Param_file(char_1 terminator_char, char_1 assignment_char,
	     char_1 comment_char);
  
  // initialization methods
  //
  logical_1 init_cc(char_1* param_file, char_1* magic_str);
  logical_1 init_cc(char_1* param_file);
  
  // set methods
  //
  logical_1 set_cc(char_1* name, char_1* value);
  
  // get methods
  //
  logical_1 get_cc(char_1* value, char_1* param);
  logical_1 get_cc(int_4& value, char_1* param);
  logical_1 get_cc(float_4& value, char_1* param);
  
  // return the number of params
  //
  logical_1 get_num_params_cc(int_4& num_params);
  logical_1 get_param_names_cc(char_1** param_list);
  
  // debugging methods
  //
  logical_1 set_debug_cc(int_4 value);
  logical_1 debug_cc(FILE* fp, char_1* message);

  // these are public so that it can be used by other classes
  //
  // tokenizer method
  //
  logical_1 tokenize_cc(char_1** values, int_4& num_vals,
			char_1* string_to_tokenize, char_1 delimiter);

  logical_1 compact_tokens_cc(char_1** values, int_4& num_values_a,
			      char_1* symbols_a);
  
  // methods to get rid of some character from the string
  // 
  logical_1 edge_strip_cc(char_1* buffer, char_1* chars_to_strip);
  logical_1 full_strip_cc(char_1* buffer, char_1* chars);

  // pad out symbols to aid in tokenization
  //
  logical_1 symbol_pad_cc(char_1*& buffer, int_4 length, char_1* symbols);

  
  // count the number of tokens
  //
  logical_1 token_count_cc(int_4& num_vals, char_1 delimiter,
                         char_1* string_to_tokenize);  

  // string to number conversion methods
  //
  logical_1 convert_string_cc(int_4& value, char_1* string);
  logical_1 convert_string_cc(float_4& value, char_1* string);
  
  //---------------------------------------------------------------------------
  //
  // private methods
  //
  //---------------------------------------------------------------------------
private:

  // methods that load data from parameter files
  //
  logical_1 load_cc(FILE* fp_a);
  
  // parse methods
  //
  int_4 pre_parse_cc(char_1* buffer);
  logical_1 parse_cc(char_1* buffer, int_4 length);

  // build the parse string from class data
  //
  logical_1 set_parse_string_cc();
  
};
 
// end of include file
// 
#endif
