IO Class Reference
Single point control for generated file output, renaming, etc.
More...
#include <io.h>
Collaboration diagram for IO:
[legend]List of all members.
|
Public Member Functions |
| ~IO () |
void | fopen (const char *outFn) |
| Handle file openning.
|
void | fclose () |
| Closes the file.
|
void | rename () |
| Rename the temp file back to original name.
|
void | fputs (const char *s) |
| Write the character string to the output file.
|
Static Public Member Functions |
static IO & | instance () |
static void | build () |
Private Member Functions |
| IO () |
| IO (const IO &) |
| Users can not copy one.
|
IO & | operator= (const IO &) |
| Users can not assign one.
|
Private Attributes |
FILE * | mp_fpOut |
| A single file pointer for the output file.
|
int | m_flush |
int | m_print |
std::string | m_outFn |
std::string | m_fn |
std::string | m_fnBak |
Static Private Attributes |
static IO * | msp_io = 0 |
static SingletonDestroyer<
IO > | ms_destroyer |
Detailed Description
Single point control for generated file output, renaming, etc.
- Description
- The
IO
object is a front end object for pushing strings to the output file. This class encapsulates whether to flush the buffer for debugging or even to print. Also it controls the renaming.
- Design Considerations
-
The output behavior of the generated file is controlled by user input.
-
However the tokens are printed out all over.
-
This class provides a single place where the control over the output happens in one place. Not spread out all over.
Constructor & Destructor Documentation
|
Constructor uses options to set m_print and m_flush |
Member Function Documentation
static void IO::build |
( |
|
) |
[inline, static] |
|
|
Set static instance variable. Also registers this singleton instances with the routine that destroys it at the end. |
|
Closes the file.
- Description
- Closes the openned file. It can safely called on an already closed file.
|
void IO::fopen |
( |
const char * |
outFn |
) |
|
|
|
Handle file openning.
- Description
- If the filter option is on then set mp_fpOut to stdout. Otherwise open a temp file based on the original input name. So if the input file is foo.C then open foo.new.C
- Design Considerations
- None.
|
void IO::fputs |
( |
const char * |
s |
) |
|
|
|
Write the character string to the output file.
- Description
- Uses the C stdio ::fputs function to print the actual string.
- Design Considerations
- Checks m_flush to see if it should flush after each time.
|
static IO& IO::instance |
( |
|
) |
[inline, static] |
|
|
Returns the static instance. IO::Build() must be called first. - See also:
- IO::Build()
|
|
Rename the temp file back to original name.
- Description
- Change the temp file name back to the original name. Rename the Original file to be the same with an added ~
|
Member Data Documentation
|
When true, every call to fputs flushes the buffer. This is only used for debugging purposes as it is slow. |
|
The back up name for the file. It is part of the renaming code. |
|
The name of the output file. It is part of the renaming code. |
|
It must be true if there is to be any data sent to the output file. It is only false when just writing the function names. |
|
A single file pointer for the output file.
- Description
- There can only be one open output file at a time. This means that we can have a static pointer for them.
- Design Considerations
- The current output file must be available to the errStr routine so that the output buffer can be flushed when there is an error.
|
|
The placeholder so that the IO singleton will be cleaned up. |
|
The singleton instance for IO. |
The documentation for this class was generated from the following files: