NAWA 0.9
Web Application Framework for C++
nawa::File Class Reference

#include <nawa/request/File.h>

Public Member Functions

virtual ~File ()
 
 File (std::shared_ptr< char[]> dataPtr, size_t size)
 
 File (std::string const &data)
 
 File (File const &other)
 
Fileoperator= (const File &other)
 
 File (File &&other) noexcept
 
Fileoperator= (File &&other) noexcept
 
std::string & filename () noexcept
 
std::string const & filename () const noexcept
 
Filefilename (std::string value) noexcept
 
std::string & contentType () noexcept
 
std::string const & contentType () const noexcept
 
FilecontentType (std::string value) noexcept
 
size_t size () const noexcept
 
std::string toString () const
 
void writeToDisk (std::string const &path) const
 

Detailed Description

Container for (especially POST-submitted) files.

Definition at line 35 of file File.h.

Constructor & Destructor Documentation

◆ ~File()

virtual nawa::File::~File ( )
virtual

◆ File() [1/4]

File::File ( std::shared_ptr< char[]>  dataPtr,
size_t  size 
)

Construct a File from data.

Parameters
dataPtrShared pointer to the file data.
sizeSize of the file.
Deprecated:
Files should be constructed from std::string objects instead.

Definition at line 55 of file File.cpp.

◆ File() [2/4]

File::File ( std::string const &  data)
explicit

Construct a file from data stored in a string.

Parameters
dataFile data.

Definition at line 59 of file File.cpp.

◆ File() [3/4]

nawa::File::File ( File const &  other)

Copy the File object which contains a reference to a file. Please note that this does not deep-copy the file in memory, just the reference!

Parameters
otherFile object to copy (the refence) from.

◆ File() [4/4]

nawa::File::File ( File &&  other)
noexcept

Member Function Documentation

◆ operator=() [1/2]

File & nawa::File::operator= ( const File other)

Copy-assign from another File object. Please note that this does not deep-copy the file in memory, just the reference!

Parameters
otherFile object to copy (the refence) from.
Returns
This File object.

◆ operator=() [2/2]

File & nawa::File::operator= ( File &&  other)
noexcept

◆ filename() [1/3]

std::string & nawa::File::filename ( )
noexcept

Original file name (submitted by sender).

Returns
Reference to file name.

◆ filename() [2/3]

std::string const & nawa::File::filename ( ) const
noexcept

◆ filename() [3/3]

File & nawa::File::filename ( std::string  value)
noexcept

◆ contentType() [1/3]

std::string & nawa::File::contentType ( )
noexcept

Content-Type string.

Returns
Reference to content-type string.

◆ contentType() [2/3]

std::string const & nawa::File::contentType ( ) const
noexcept

◆ contentType() [3/3]

File & nawa::File::contentType ( std::string  value)
noexcept

◆ size()

size_t File::size ( ) const
noexcept

Get file size in bytes.

Returns
File size.

Definition at line 65 of file File.cpp.

◆ toString()

std::string File::toString ( ) const

Copy the file into a std::string

Returns
std::string containing the whole file

Definition at line 69 of file File.cpp.

◆ writeToDisk()

void File::writeToDisk ( std::string const &  path) const

Write the file to disk. Throws a nawa::Excption with error code 1 on failure.

Parameters
pathFile name and path where to write the file.

Definition at line 73 of file File.cpp.


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