cgicc::FormFile Class Reference

Class representing a file submitted via an HTML form. More...

#include <cgicc/FormFile.h>


Public Member Functions

Overloaded Operators
bool operator== (const FormFile &file) const
 Compare two FormFiles for equality.
bool operator!= (const FormFile &file) const
 Compare two FormFiles for inequality.
FormFileoperator= (const FormFile &file)
 Assign one FormFile to another.
Accessor Methods
Information on the uploaded file

void writeToStream (std::ostream &out) const
 Write this file data to the specified stream.
std::string getName () const
 Get the name of the form element.
std::string getFilename () const
 Get the basename of the file on the remote machine.
std::string getDataType () const
 Get the MIME type of the file data.
std::string getData () const
 Get the file data.
std::string::size_type getDataLength () const
 Get the length of the file data.


Detailed Description

Class representing a file submitted via an HTML form.

FormFile is an immutable class reprenting a file uploaded via the HTTP file upload mechanism. If you are going to use file upload in your CGI application, remember to set the ENCTYPE of the form to multipart/form-data.

   <form method="post" action="http://change_this_path/cgi-bin/upload.cgi" 
   enctype="multipart/form-data">
   
See also:
FormEntry

Definition at line 64 of file FormFile.h.


Constructor & Destructor Documentation

cgicc::FormFile::FormFile (  )  [inline]

Default constructor.

Shouldn't be used.

Definition at line 79 of file FormFile.h.

cgicc::FormFile::FormFile ( const std::string &  name,
const std::string &  filename,
const std::string &  dataType,
const std::string &  data 
)

Create a new FormFile.

This is usually not called directly, but by Cgicc.

Parameters:
name The name of the form element.
filename The filename of the file on the remote machine.
dataType The MIME content type of the data, if specified, or 0.
data The file data.

Definition at line 31 of file FormFile.cpp.

cgicc::FormFile::FormFile ( const FormFile file  )  [inline]

Copy constructor.

Sets the name, filename, datatype, and data to those of file

Parameters:
file The FormFile to copy.

Definition at line 103 of file FormFile.h.

cgicc::FormFile::~FormFile (  )  [inline]

Destructor.

Delete this FormFile object

Definition at line 112 of file FormFile.h.

cgicc::FormFile::FormFile (  )  [inline]

Default constructor.

Shouldn't be used.

Definition at line 79 of file FormFile.h.

cgicc::FormFile::FormFile ( const std::string &  name,
const std::string &  filename,
const std::string &  dataType,
const std::string &  data 
)

Create a new FormFile.

This is usually not called directly, but by Cgicc.

Parameters:
name The name of the form element.
filename The filename of the file on the remote machine.
dataType The MIME content type of the data, if specified, or 0.
data The file data.

Definition at line 31 of file FormFile.cpp.

cgicc::FormFile::FormFile ( const FormFile file  )  [inline]

Copy constructor.

Sets the name, filename, datatype, and data to those of file

Parameters:
file The FormFile to copy.

Definition at line 103 of file FormFile.h.

cgicc::FormFile::~FormFile (  )  [inline]

Destructor.

Delete this FormFile object

Definition at line 112 of file FormFile.h.


Member Function Documentation

bool cgicc::FormFile::operator== ( const FormFile file  )  const

Compare two FormFiles for equality.

FormFiles are equal if they have the same filename.

Parameters:
file The FormFile to compare to this one.
Returns:
true if the two FormFiles are equal, false otherwise.

Definition at line 43 of file FormFile.cpp.

References fDataType, fFilename, fName, and cgicc::stringsAreEqual().

bool cgicc::FormFile::operator!= ( const FormFile file  )  const [inline]

Compare two FormFiles for inequality.

FormFiles are equal if they have the same filename.

Parameters:
file The FormFile to compare to this one.
Returns:
false if the two FormFiles are equal, true otherwise.

Definition at line 139 of file FormFile.h.

cgicc::FormFile & cgicc::FormFile::operator= ( const FormFile file  ) 

Assign one FormFile to another.

Sets the name, filename, datatype, and data to those of file

Parameters:
file The FormFile to copy.
Returns:
A reference to this.

Definition at line 51 of file FormFile.cpp.

References fData, fDataType, fFilename, and fName.

void cgicc::FormFile::writeToStream ( std::ostream &  out  )  const

Write this file data to the specified stream.

This is useful for saving uploaded data to disk

Parameters:
out The ostream to which to write.

Definition at line 62 of file FormFile.cpp.

References getData(), and getDataLength().

std::string cgicc::FormFile::getName (  )  const [inline]

Get the name of the form element.

The name of the form element is specified in the HTML form that called the CGI application.

Returns:
The name of the form element.

Definition at line 184 of file FormFile.h.

Referenced by cgicc::FF_compare::operator()().

std::string cgicc::FormFile::getFilename (  )  const [inline]

Get the basename of the file on the remote machine.

The filename is stripped of all leading directory information

Returns:
The basename of the file on the remote machine.

Definition at line 194 of file FormFile.h.

std::string cgicc::FormFile::getDataType (  )  const [inline]

Get the MIME type of the file data.

This will be of the form text/plain or image/jpeg

Returns:
The MIME type of the file data.

Definition at line 204 of file FormFile.h.

std::string cgicc::FormFile::getData (  )  const [inline]

Get the file data.

This returns the raw file data as a string

Returns:
The file data.

Definition at line 214 of file FormFile.h.

Referenced by writeToStream().

std::string::size_type cgicc::FormFile::getDataLength (  )  const [inline]

Get the length of the file data.

The length of the file data is usually measured in bytes.

Returns:
The length of the file data, in bytes.

Definition at line 224 of file FormFile.h.

Referenced by writeToStream().


The documentation for this class was generated from the following files:
Generated on Tue Jul 3 15:44:37 2007 for GNUCgicc by  doxygen 1.5.1