FileDescriptor Class Reference

#include <FileDescriptor.hpp>

List of all members.

Public Types

enum  FormatType {
  am_fmt, gmsh, mesh, medit,
  raw, vtk
}
enum  FileType {
  binary, dos, formatDefault, mac,
  unices
}

Public Member Functions

const FileDescriptor::FormatTypeformat () const
const FileDescriptor::FileTypetype () const
const std::string cr () const
std::string formatName () const
std::string fileTypeName () const
 FileDescriptor (const FileDescriptor::FormatType &format, const FileDescriptor::FileType &type)
 FileDescriptor (const FileDescriptor &f)
 ~FileDescriptor ()

Static Public Member Functions

static FileDescriptor::FormatType formatType (const char *c)
static FileDescriptor::FileType fileType (const char *c)

Private Attributes

const FileDescriptor::FormatType __formatType
const FileDescriptor::FileType __fileType


Detailed Description

Definition at line 35 of file FileDescriptor.hpp.


Member Enumeration Documentation

Enumerator:
am_fmt 
gmsh 
mesh 
medit 
raw 
vtk 

Definition at line 38 of file FileDescriptor.hpp.

00038                   {
00039     am_fmt,
00040     gmsh,
00041     mesh,
00042     medit,
00043     raw,
00044     vtk
00045   };

Enumerator:
binary  binary format
dos  text format with MS-DOS end of line characters
formatDefault  default file type according to format
mac  text format with MAC-OS end of line characters
unices  text format with UN*X-like end of line characters

Definition at line 47 of file FileDescriptor.hpp.

00047                 {
00048     binary,                     
00049     dos,                        
00051     formatDefault,              
00053     mac,                        
00055     unices                      
00057   };


Constructor & Destructor Documentation

FileDescriptor::FileDescriptor ( const FileDescriptor::FormatType format,
const FileDescriptor::FileType type 
) [inline]

Constructor

Parameters:
format given file format
type given file type

Definition at line 259 of file FileDescriptor.hpp.

00261     : __formatType(format),
00262       __fileType(type)
00263   {
00264     ;
00265   }

FileDescriptor::FileDescriptor ( const FileDescriptor f  )  [inline]

Copy constructor

Parameters:
f given file descriptor

Definition at line 272 of file FileDescriptor.hpp.

00273     : __formatType(f.__formatType),
00274       __fileType(f.__fileType)
00275   {
00276     ;
00277   }

FileDescriptor::~FileDescriptor (  )  [inline]

Destructor

Definition at line 283 of file FileDescriptor.hpp.

00284   {
00285     ;
00286   }


Member Function Documentation

static FileDescriptor::FormatType FileDescriptor::formatType ( const char *  c  )  [inline, static]

Gets the format type according to its name

Parameters:
c name of the format
Returns:
the type of the format

Definition at line 67 of file FileDescriptor.hpp.

References am_fmt, fferr(), gmsh, medit, mesh, raw, ErrorHandler::unexpected, and vtk.

Referenced by FFLexer::isKeyword().

00068   {
00069     if (std::strcmp(c,"gmsh") == 0) {
00070       return FileDescriptor::gmsh;
00071     }
00072     if (std::strcmp(c,"mesh") == 0) {
00073       return FileDescriptor::mesh;
00074     }
00075     if (std::strcmp(c,"medit") == 0) {
00076       return FileDescriptor::medit;
00077     }
00078     if (std::strcmp(c,"opendx") == 0) {
00079       fferr(1) << "warning: \"opendx\" is deprecated, use \"raw\" keyword instead\n";
00080       return FileDescriptor::raw;
00081     }
00082     if (std::strcmp(c,"raw") == 0) {
00083       return FileDescriptor::raw;
00084     }
00085     if (std::strcmp(c,"vtk") == 0) {
00086       return FileDescriptor::vtk;
00087     }
00088     if (std::strcmp(c,"am_fmt") == 0) {
00089       return FileDescriptor::am_fmt;
00090     }
00091 
00092     throw ErrorHandler(__FILE__,__LINE__,
00093                        "Unknown File Type: '"+std::string(c)+"'",
00094                        ErrorHandler::unexpected);
00095     return FileDescriptor::raw;
00096   }

Here is the call graph for this function:

static FileDescriptor::FileType FileDescriptor::fileType ( const char *  c  )  [inline, static]

Gets the file type according to its name

Parameters:
c file type name
Returns:
the file type

Definition at line 106 of file FileDescriptor.hpp.

References binary, dos, mac, ErrorHandler::unexpected, and unices.

Referenced by FFLexer::isKeyword().

00107   {
00108     if (std::strcmp(c,"unix") == 0) {
00109       return FileDescriptor::unices;
00110     }
00111     if (std::strcmp(c,"dos") == 0) {
00112       return FileDescriptor::dos;
00113     }
00114     if (std::strcmp(c,"mac") == 0) {
00115       return FileDescriptor::mac;
00116     }
00117     if (std::strcmp(c,"binary") == 0) {
00118       return FileDescriptor::binary;
00119     }
00120     throw ErrorHandler(__FILE__,__LINE__,
00121                        "unknown file type",
00122                        ErrorHandler::unexpected);
00123     return FileDescriptor::unices;
00124   }

const FileDescriptor::FormatType& FileDescriptor::format (  )  const [inline]

Read-only access to the format

Returns:
__formatType

Definition at line 139 of file FileDescriptor.hpp.

References __formatType.

Referenced by ScalarFunctionReaderBuilder::getReader().

00140   {
00141     return __formatType;
00142   }

const FileDescriptor::FileType& FileDescriptor::type (  )  const [inline]

Read-only access to the file type

Returns:
__fileType

Definition at line 150 of file FileDescriptor.hpp.

References __fileType.

Referenced by WriterRaw::__saveScalarFunction().

00151   {
00152     return __fileType;
00153   }

const std::string FileDescriptor::cr (  )  const [inline]

Access to the valid cardriage return string

Returns:
CR

Definition at line 161 of file FileDescriptor.hpp.

References __fileType, binary, dos, formatDefault, mac, ErrorHandler::unexpected, and unices.

00162   {
00163     std::string CR;
00164 
00165     switch (__fileType) {
00166     case FileDescriptor::binary:
00167     case FileDescriptor::formatDefault:
00168     case FileDescriptor::unices: {
00169       CR = '\n';
00170       break;
00171     }
00172     case FileDescriptor::dos: {
00173 #ifndef __MINGW32__
00174       CR = "\r\n";
00175 #else // __MINGW32__
00176       CR = "\n";
00177 #endif // __MINGW32__
00178       break;
00179     }
00180     case FileDescriptor::mac: {
00181       CR = '\r';
00182       break;
00183     }
00184     default: {
00185       throw ErrorHandler(__FILE__,__LINE__,
00186                          "unknown file type",
00187                          ErrorHandler::unexpected);
00188     }
00189     }
00190     return CR;
00191   }

std::string FileDescriptor::formatName (  )  const [inline]

Converts format type to a string

Returns:
the format name

Definition at line 198 of file FileDescriptor.hpp.

References __formatType, am_fmt, gmsh, medit, mesh, raw, ErrorHandler::unexpected, and vtk.

Referenced by ScalarFunctionReaderBuilder::getReader().

00199   {
00200     switch (__formatType) {
00201     case am_fmt:
00202       return "am_fmt";
00203     case gmsh:
00204       return "gmsh";
00205     case mesh:
00206       return "mesh";
00207     case medit:
00208       return "medit";
00209     case raw:
00210       return "raw";
00211     case vtk:
00212       return "vtk";
00213     default:
00214       throw ErrorHandler(__FILE__,__LINE__,
00215                          "unknown file format",
00216                          ErrorHandler::unexpected);
00217       return "error";
00218     }
00219   }

std::string FileDescriptor::fileTypeName (  )  const [inline]

Converts format type to a string

Returns:
the format name

Definition at line 226 of file FileDescriptor.hpp.

References __fileType, binary, dos, formatDefault, mac, ErrorHandler::unexpected, and unices.

00227   {
00228     switch (__fileType) {
00229     case binary: {
00230       return "binary";
00231     }
00232     case dos: {
00233       return "dos";
00234     }
00235     case formatDefault: {
00236       return "unspecified";
00237     }
00238     case mac: {
00239       return "mac";
00240     }
00241     case unices: {
00242       return "unix";
00243     }
00244     default: {
00245       throw ErrorHandler(__FILE__,__LINE__,
00246                          "unknown file type",
00247                          ErrorHandler::unexpected);
00248       return "error";
00249     }
00250     }
00251   }


Member Data Documentation

Format type

Definition at line 128 of file FileDescriptor.hpp.

Referenced by format(), and formatName().

File type

Definition at line 130 of file FileDescriptor.hpp.

Referenced by cr(), fileTypeName(), and type().


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

Generated on Wed Nov 19 00:06:42 2008 for FreeFEM3D (aka ff3d) by  doxygen 1.5.6