Removed OUTPUT_CVODE, OUTPUT_STDERR, OUTPUT_BASIC, and commented OUTPUT_SEND_MESSAGE.

git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/branches/ErrorHandling@5695 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2011-10-18 19:00:15 +00:00
parent 79541da631
commit 1fb2150c82
2 changed files with 87 additions and 146 deletions

View File

@ -30,7 +30,54 @@ PHRQ_io::
~PHRQ_io()
{
}
void
PHRQ_io::Set_database_file(FILE * in)
{
safe_close(this->database_file);
this->database_file = in;
}
void
PHRQ_io::Set_input_file(FILE * in)
{
safe_close(this->input_file);
this->input_file = in;
}
void
PHRQ_io::Set_output_file(FILE * out)
{
safe_close(this->output_file);
this->output_file = out;
}
void
PHRQ_io::Set_error_file(FILE * out)
{
safe_close(this->error_file);
this->error_file = out;
}
void
PHRQ_io::Set_log_file(FILE * out)
{
safe_close(this->log_file);
this->log_file = out;
}
void
PHRQ_io::Set_punch_file(FILE * out)
{
safe_close(this->punch_file);
this->punch_file = out;
}
void
PHRQ_io::Set_dump_file(FILE * out)
{
safe_close(this->dump_file);
this->dump_file = out;
}
void
PHRQ_io::close_input(void)
{
safe_close(input_file);
}
/* ---------------------------------------------------------------------- */
int PHRQ_io::
close_input_files(void)
@ -190,7 +237,6 @@ output_msg(int type, const char *format, va_list args)
}
break;
case OUTPUT_MESSAGE:
case OUTPUT_BASIC:
if (output_file != NULL && output_file_on)
{
vfprintf(output_file, format, args);
@ -224,14 +270,7 @@ output_msg(int type, const char *format, va_list args)
fflush(error_file);
}
break;
case OUTPUT_STDERR:
case OUTPUT_CVODE:
if (stderr != NULL)
{
vfprintf(stderr, format, args);
fflush(stderr);
}
break;
case OUTPUT_DUMP:
if (dump_file != NULL && dump_file_on)
{
@ -293,7 +332,6 @@ output_string(const int type, std::string str)
break;
case OUTPUT_CHECKLINE:
case OUTPUT_MESSAGE:
case OUTPUT_BASIC:
if (output_file != NULL && output_file_on)
{
fprintf(output_file, "%s", str.c_str());
@ -318,14 +356,7 @@ output_string(const int type, std::string str)
fflush(error_file);
}
break;
case OUTPUT_STDERR:
case OUTPUT_CVODE:
if (stderr != NULL)
{
fprintf(stderr, "%s", str.c_str());
fflush(stderr);
}
break;
case OUTPUT_DUMP:
if (dump_file != NULL && dump_file_on)
{
@ -464,9 +495,6 @@ output_isopen(const int type)
case OUTPUT_DUMP:
return (dump_file != NULL);
break;
case OUTPUT_STDERR:
return (stderr != NULL);
break;
default:
assert(false);
return (output_file != NULL);
@ -496,7 +524,6 @@ output_fflush(const int type)
case OUTPUT_MESSAGE:
case OUTPUT_CHECKLINE:
case OUTPUT_BASIC:
if (output_file)
fflush(output_file);
break;
@ -516,12 +543,6 @@ output_fflush(const int type)
fflush(log_file);
break;
case OUTPUT_CVODE:
case OUTPUT_STDERR:
if (stderr)
fflush(stderr);
break;
case OUTPUT_DUMP:
if (dump_file)
fflush(dump_file);
@ -549,7 +570,6 @@ output_rewind(const int type)
case OUTPUT_MESSAGE:
case OUTPUT_CHECKLINE:
case OUTPUT_BASIC:
if (output_file)
rewind(output_file);
break;
@ -569,12 +589,6 @@ output_rewind(const int type)
rewind(log_file);
break;
case OUTPUT_CVODE:
case OUTPUT_STDERR:
if (stderr)
rewind(stderr);
break;
case OUTPUT_DUMP:
if (dump_file)
rewind(dump_file);
@ -589,48 +603,37 @@ output_close(const int type)
switch (type)
{
case OUTPUT_ERROR:
if (error_file)
safe_close(error_file);
safe_close(error_file);
break;
case OUTPUT_WARNING:
if (error_file)
safe_close(error_file);
if (output_file)
safe_close(output_file);
safe_close(error_file);
safe_close(output_file);
break;
case OUTPUT_MESSAGE:
case OUTPUT_CHECKLINE:
case OUTPUT_BASIC:
if (output_file)
safe_close(output_file);
safe_close(output_file);
break;
case OUTPUT_PUNCH:
if (punch_file)
safe_close(punch_file);
safe_close(punch_file);
break;
case OUTPUT_SCREEN:
if (error_file)
safe_close(error_file);
safe_close(error_file);
break;
case OUTPUT_LOG:
if (log_file)
safe_close(log_file);
break;
case OUTPUT_CVODE:
case OUTPUT_STDERR:
if (stderr)
safe_close(stderr);
safe_close(log_file);
break;
case OUTPUT_DUMP:
if (dump_file)
safe_close(dump_file);
safe_close(dump_file);
break;
default:
assert(false);
break;
}
}
@ -647,6 +650,7 @@ safe_close(FILE * file_ptr)
file_ptr != NULL)
{
fclose(file_ptr);
file_ptr = NULL;
}
}

113
PHRQ_io.h
View File

@ -18,11 +18,8 @@ typedef enum
OUTPUT_LOG,
OUTPUT_CHECKLINE,
OUTPUT_GUI_ERROR,
OUTPUT_BASIC,
OUTPUT_CVODE,
OUTPUT_DUMP,
OUTPUT_STDERR,
OUTPUT_SEND_MESSAGE,
//OUTPUT_SEND_MESSAGE,
OUTPUT_ECHO,
OUTPUT_PUNCH_END_ROW
} output_type;
@ -58,90 +55,30 @@ typedef enum
bool output_isopen(int type);
void fpunchf(const char *name, const char *format, va_list args);
void Set_io_error_count(int i)
{
this->io_error_count = i;
}
int Get_io_error_count(void)
{
return this->io_error_count;
}
void Set_input_file(FILE * in)
{
if (this->input_file != NULL &&
this->input_file != stderr &&
this->input_file != stdout)
{
fclose(this->input_file);
}
this->input_file = in;
}
void Set_output_file(FILE * out)
{
if (this->output_file != NULL &&
this->output_file != stderr &&
this->output_file != stdout)
{
fclose(this->output_file);
}
this->output_file = out;
}
void Set_database_file(FILE * in)
{
if (this->database_file != NULL &&
this->database_file != stdin)
{
fclose(this->database_file);
}
this->database_file = in;
}
void close_input(void)
{
if (input_file != stdin)
{
fclose(input_file);
}
}
void Set_output_file_on(bool tf)
{
this->output_file_on = tf;
}
void Set_log_file_on(bool tf)
{
this->log_file_on = tf;
}
void Set_punch_file_on(bool tf)
{
this->punch_file_on = tf;
}
void Set_error_file_on(bool tf)
{
this->error_file_on = tf;
}
void Set_dump_file_on(bool tf)
{
this->dump_file_on = tf;
}
bool Get_output_file_on(void)
{
return this->output_file_on;
}
bool Get_log_file_on(void)
{
return this->log_file_on;
}
bool Get_punch_file_on(void)
{
return this->punch_file_on;
}
bool Get_error_file_on(void)
{
return this->error_file_on;
}
bool Get_dump_file_on(void)
{
return this->dump_file_on;
}
void Set_io_error_count(int i) {this->io_error_count = i;};
int Get_io_error_count(void) {return this->io_error_count;};
void Set_database_file(FILE * in);
void Set_input_file(FILE * in);
void Set_output_file(FILE * out);
void Set_error_file(FILE * out);
void Set_log_file(FILE * out);
void Set_punch_file(FILE * out);
void Set_dump_file(FILE * out);
void PHRQ_io::close_input(void);
void Set_output_file_on(bool tf) {this->output_file_on = tf;};
void Set_log_file_on(bool tf) {this->log_file_on = tf;};
void Set_punch_file_on(bool tf) {this->punch_file_on = tf;};
void Set_error_file_on(bool tf) {this->error_file_on = tf;};
void Set_dump_file_on(bool tf) {this->dump_file_on = tf;};
bool Get_output_file_on(void) {return this->output_file_on;};
bool Get_log_file_on(void) {return this->log_file_on;};
bool Get_punch_file_on(void) {return this->punch_file_on;};
bool Get_error_file_on(void) {return this->error_file_on;};
bool Get_dump_file_on(void) {return this->dump_file_on;};
// data
protected:
FILE *input_file;