#include <MimeTypes.hpp>
|
| | MimeTypes (const std::string &path=MIME_TYPES_PATH) |
| | Constructs the MimeTypes object and loads MIME types from the specified file.
|
| | MimeTypes (const MimeTypes &other) |
| | Copy constructor.
|
| MimeTypes & | operator= (const MimeTypes &other) |
| | Assignment operator.
|
| const std::string | getMimeType (const std::string &extension) const |
| | Retrieves the MIME type associated with a given file extension.
|
| const std::string | getMimeExt (const std::string &mimeType) const |
| | Retrieves the file extension associated with a given MIME type.
|
| void | reload () |
| | Reloads the MIME types from the configuration file.
|
| | ~MimeTypes () |
|
| bool | wasChanged () |
| | checks if the MIME types file has been modified since the last load.
|
◆ MimeTypes() [1/2]
Constructs the MimeTypes object and loads MIME types from the specified file.
This constructor initializes the MIME types map by reading from the provided file path. It sets the last reload time to the last modification time of the file. If the file cannot be loaded, throws a runtime_error exception.
- Parameters
-
| path | Optional parameter path to the MIME types configuration file. Defaults to "MIME_TYPES_PATH". |
◆ MimeTypes() [2/2]
| http::MimeTypes::MimeTypes |
( |
const MimeTypes & | other | ) |
|
Copy constructor.
This constructor creates a new MimeTypes object as a copy of an existing one.
- Parameters
-
◆ ~MimeTypes()
| http::MimeTypes::~MimeTypes |
( |
| ) |
|
◆ findFirstNonSpace()
| size_t http::MimeTypes::findFirstNonSpace |
( |
const std::string & | str, |
|
|
size_t | startPos ) |
|
staticprivate |
◆ findFirstSpace()
| size_t http::MimeTypes::findFirstSpace |
( |
const std::string & | str | ) |
|
|
staticprivate |
◆ getMimeExt()
| const std::string http::MimeTypes::getMimeExt |
( |
const std::string & | mimeType | ) |
const |
Retrieves the file extension associated with a given MIME type.
This method looks up the file extension corresponding to the provided MIME type in the loaded MIME types map.
- Parameters
-
| extension | The MIME type for which to retrieve the file extension. |
- Returns
- The corresponding file extension as a string, or "txt" if the MIME type is not recognized.
◆ getMimeType()
| const std::string http::MimeTypes::getMimeType |
( |
const std::string & | extension | ) |
const |
Retrieves the MIME type associated with a given file extension.
This method looks up the MIME type corresponding to the provided file extension in the loaded MIME types map..
- Parameters
-
| extension | The file extension (without the leading dot) for which to retrieve the MIME type. |
- Returns
- The corresponding MIME type as a string, or "text/plain" if the extension is not recognized.
◆ operator=()
Assignment operator.
This operator assigns the contents of one MimeTypes object to another.
- Parameters
-
- Returns
- A reference to this MimeTypes object.
◆ reload()
| void http::MimeTypes::reload |
( |
| ) |
|
Reloads the MIME types from the configuration file.
This method reads the MIME types file specified by filePath_ and populates the mimeTypes_ map with the latest MIME type definitions. It updates the rtime_ to reflect the time of the last successful reload.
◆ wasChanged()
| bool http::MimeTypes::wasChanged |
( |
| ) |
|
|
private |
checks if the MIME types file has been modified since the last load.
◆ filePath_
| std::string http::MimeTypes::filePath_ |
|
private |
◆ mimeExt_
| std::map<std::string, std::string> http::MimeTypes::mimeExt_ |
|
private |
◆ mimeTypes_
| std::map<std::string, std::string> http::MimeTypes::mimeTypes_ |
|
private |
◆ rtime_
| struct timespec http::MimeTypes::rtime_ |
|
private |
The documentation for this class was generated from the following files: