- Main Page
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Mers::Models::Base::Io::Mof::BaseModelReader Class Reference

`#include <BaseModelReader.h>`

List of all members.

## Public Types
enum | BaseModelFileType { BMBinary001 = 0x0001, BMBinaryLatest = BMBinary001, BMText001 = 0x0001 | BaseModelTextFileType, BMTextLatest = BMText001 }
## Static Public Member Functions
static int | loadBaseModel (const char *filename, BaseModel *&model)
static int | loadBaseModel (const char *filename, BaseModel &model)
static int | saveBaseModel (const char *filename, BaseModelFileType saveType, BaseModel const &model)
static int | saveBaseModel (FILE *file, BaseModelFileType saveType, BaseModel const &model)
static char const * | bmFileTypeToString (BaseModelFileType fileType)
static bool | isTextFileFormat (BaseModelFileType fileType)
## Static Protected Member Functions
static char const * | getBMFileHeader (BaseModelFileType fileType)

## Detailed Description

Handles reading and writting of BaseModel object files. It operates on BaseModel and derivative classes.

Author:
  Paul H. Elliott

Definition at line 34 of file BaseModelReader.h.

## Member Enumeration Documentation

enum Mers::Models::Base::Io::Mof::BaseModelReader::BaseModelFileType

BaseModelFileType is setup so the version # is the lower 12 bits and the 13th bit is set to 1 if this is a text format, or 0 if it's a binary format.

Definition at line 41 of file BaseModelReader.h.

## Member Function Documentation

int BaseModelReader::loadBaseModel | ( | const char * | filename,
|  | BaseModel *& | model |
| ) |  |  | `[static]`

Loads the file specified by filename into the model.

Parameters:

  | filename | pointer to the string name of the file being opened.
  | model | handle to the model object to be filled by the reader. it is assumed that the model is empty or is being incrementally updated, so the model should already be clear if that is the desired initial state.

Returns:
  0 on success or non zero if an error occured with opening or parsing the file.

Definition at line 35 of file BaseModelReader.cpp.

int BaseModelReader::loadBaseModel | ( | const char * | filename,
|  | BaseModel & | model |
| ) |  |  | `[static]`

Loads the file specified by filename into the model.

Parameters:

  | filename | pointer to the string name of the file being opened.
  | model | handle to the model object to be filled by the reader. it is assumed that the model is empty or is being incrementally updated, so the model should already be clear if that is the desired initial state.

Returns:
  0 on success or non zero if an error occured with opening or parsing the file

Definition at line 54 of file BaseModelReader.cpp.

int BaseModelReader::saveBaseModel | ( | const char * | filename,
|  | BaseModelFileType | saveType,
|  | BaseModel const & | model |
| ) |  |  | `[static]`

Saves a model to the specified BM File Type, if supported.

Currently supported BM File Types:
BMText001

Parameters:

  | filename | the name of the file to use as the save file, without the file extension.
  | saveType | the format/version of the file to save. This must be from the list of supported BM File Types or the call will fail.
  | model | the model that will be exported to the file.

Returns:
  0 on success or non-zero if an error occured.

Definition at line 84 of file BaseModelReader.cpp.

References Mers::Utils::Lang::String::c_str(), and isTextFileFormat().

Here is the call graph for this function:

int BaseModelReader::saveBaseModel | ( | FILE * | file,
|  | BaseModelFileType | saveType,
|  | BaseModel const & | model |
| ) |  |  | `[static]`

Saves a model to the specified CCA File Type, if supported.

Currently supported CCA File Types:
BMText001

Parameters:

  | file | the file to use as the save file.
  | saveType | the format/version of the file to save. This must be from the list of supported BM File Types or the call will fail.
  | model | the model that will be exported to the file.

Returns:
  0 on success or non-zero if an error occured.

Definition at line 114 of file BaseModelReader.cpp.

References bmFileTypeToString(), getBMFileHeader(), Mers::Models::Base::BaseModel::getDomains(), Mers::Utils::Containers::DynamicArray::getLength(), Mers::Models::Base::BaseModel::getVariables(), and Mers::Models::Base::BaseModelVariable::variableTypeToString().

Here is the call graph for this function:

char const * BaseModelReader::bmFileTypeToString | ( | BaseModelFileType | fileType | ) | `[static]`

Returns the string name of a CCAFileType enumerated type.

Parameters:

  | fileType | the enumerated type for which the string is being fetched.

Returns:
  a handle to a static string if the enumerated type was found or NULL if the type was invalid.

Definition at line 183 of file BaseModelReader.cpp.

Referenced by saveBaseModel().

bool BaseModelReader::isTextFileFormat | ( | BaseModelFileType | fileType | ) | `[static]`

Returns true iff this is a CCA text file type.

Parameters:

  | fileType | the file type in question.

Returns:
  true if the CCAFileType is text file type.

Definition at line 197 of file BaseModelReader.cpp.

Referenced by saveBaseModel().

char const * BaseModelReader::getBMFileHeader | ( | BaseModelFileType | fileType | ) | `[static, protected]`

Returns the header string for the specified fileType.

Parameters:

  | fileType | the file for which the file header is retrieved.

Returns:
  a valid static character string if the header was found or NULL if the header was not found.

Definition at line 204 of file BaseModelReader.cpp.

Referenced by saveBaseModel().

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

- /Users/fpy/titan-1-5-MBARI/Mers/Models/Base/Io/Mof/BaseModelReader.h
- /Users/fpy/titan-1-5-MBARI/Mers/Models/Base/Io/Mof/BaseModelReader.cpp