Main Page Namespace List Class Hierarchy Alphabetical List Data Structures File List Namespace Members Data Fields Globals

# ExCFile Class Reference

`#include <ExCFile.h>`

Inheritance diagram for ExCFile:

## Public Methods
| ExCFile ()
| ExCFile (string s)
| ExCFile (string s, int m)
virtual | ~ExCFile ()
bool | open (void)
bool | close (void)
void | setOpenMode (int)
ios_base::openmode | getOpenMode (int)
void | setFileName (string s)
std::string | getFileName (void)
bool | exist (void)
vector< std::string > | getContent (void)
bool | add (std::string)
bool | addLine (void)
## Protected Attributes
string | filename
ios_base::openmode | mode

## Constructor & Destructor Documentation

ExCFile | ( |  | ) | `[inline]`

| Definition at line 88 of file ExCFile.h.
    00088 {};

ExCFile | ( | string | s | ) | `[inline]`

| Definition at line 89 of file ExCFile.h. References filename.
    00089 { filename = s; };

ExCFile | ( | string | s,
|  | int | m
| ) | `[inline]`

| Definition at line 90 of file ExCFile.h. References filename, and setOpenMode().
    00090 { filename = s, setOpenMode (m); };

~ExCFile | ( |  | ) | `[virtual]`

| Definition at line 72 of file ExCFile.cpp.
    00072                    {
    00073 }

## Member Function Documentation

bool add | ( | std::string |  | ) |

| Definition at line 48 of file ExCFile.cpp. References filename. Referenced by ExCOptions::create_options_file().
    00048                               {
    00049         ofstream p;
    00050         p.open (filename.data (), ios::app);
    00051         if (p.fail ()) {
    00052                 std::cerr << "Erreur ouverture" << std::endl;
    00053                 return false;
    00054         }
    00055         p << f << std::endl;
    00056         p.close ();
    00057         return true;
    00058 }

bool addLine | ( | void |  | ) |

| Definition at line 60 of file ExCFile.cpp. References filename. Referenced by ExCOptions::create_options_file().
    00060                            {
    00061         ofstream p;
    00062         p.open (filename.data (), ios::app);
    00063         if (p.fail ()) {
    00064                 std::cerr << "Erreur ouverture" << std::endl;
    00065                 return false;
    00066         }
    00067         p << std::endl;
    00068         p.close ();
    00069         return true;
    00070 }

bool close | ( | void |  | ) |

bool exist | ( | void |  | ) |

| Definition at line 75 of file ExCFile.cpp. References filename, getOpenMode(), and RO. Referenced by ExCOptions::init(), and ExManagerCommand::LoadCommandFile().
    00075                          {
    00076         fstream file;
    00077         file.open (filename.data(), getOpenMode (RO));
    00078         if (! file.fail ()) {
    00079                 file.close();
    00080                 return true;
    00081         }
    00082         return false;
    00083 }

vector< string > getContent | ( | void |  | ) |

| Reimplemented in ExCFileReader. Definition at line 85 of file ExCFile.cpp. References filename, getOpenMode(), and RO. Referenced by ExCOptions::load().
    00085                                         {
    00086         string d;
    00087         vector<string> v;
    00088         fstream file;
    00089         file.open (filename.data (), getOpenMode (RO));
    00090         if (! file.fail ()) {
    00091                 while (! std::getline (file, d).eof ()) {
    00092                         v.push_back (d);
    00093                 }
    00094         }
    00095         file.close ();
    00096         return v;
    00097 }

std::string getFileName | ( | void |  | ) | `[inline]`

| Definition at line 98 of file ExCFile.h. References filename.
    00098 { return filename; };

ios_base::openmode getOpenMode | ( | int |  | ) |

| Definition at line 37 of file ExCFile.cpp. References RO, RW, RWA, WO, and WOA. Referenced by exist(), ExCFileReader::getContent(), getContent(), and ExCFileWriter::setContent().
    00037                                                {
    00038         switch (mode) {
    00039                 case RO: return ios::in; break;
    00040                 case WO: return ios::out; break;
    00041                 case WOA: return ios::out | ios::app; break;
    00042                 case RW: return ios::in | ios::out; break;
    00043                 case RWA: return ios::in | ios::out | ios::app; break;
    00044                 default: return ios::in; break;
    00045         }
    00046 }

bool open | ( | void |  | ) |

void setFileName | ( | string | s | ) | `[inline]`

| Definition at line 97 of file ExCFile.h. References filename.
    00097 { filename = s; };

void setOpenMode | ( | int |  | ) |

| Definition at line 26 of file ExCFile.cpp. References mode, RO, RW, RWA, WO, and WOA. Referenced by ExCFile(), ExCOptions::init(), and ExCOptions::load().
    00026                                    {
    00027         switch (mode) {
    00028                 case RO: this->mode = fstream::in; break;
    00029                 case WO: this->mode = fstream::out; break;
    00030                 case WOA: this->mode = fstream::out | fstream::app; break;
    00031                 case RW: this->mode = fstream::in | fstream::out; break;
    00032                 case RWA: this->mode = fstream::in | fstream::out | fstream::app; break;
    00033                 default: this->mode = fstream::in; break;
    00034         }
    00035 }

## Field Documentation

string filename`[protected]`

| Definition at line 85 of file ExCFile.h. Referenced by add(), addLine(), ExCFile(), exist(), ExCFileReader::getContent(), getContent(), getFileName(), ExCFileWriter::setContent(), and setFileName().

ios_base::openmode mode`[protected]`

| Definition at line 86 of file ExCFile.h. Referenced by setOpenMode().

The documentation for this class was generated from the following files:

- ExCFile.h
- ExCFile.cpp