DF-0
DF-0: Data processing Framework with Zero-overhead
Toggle main menu visibility
Loading...
Searching...
No Matches
content_type_by_file_extension.h
1
/**************************************************************************/
2
/* */
3
/* DF-0: Data processing Framework with Zero-overhead */
4
/* */
5
/* Copyright (c) DF-0 Team https://github.com/df0-io/df0 */
6
/* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-DF0-Commercial */
7
/* */
8
/**************************************************************************/
9
10
#ifndef DF0_CONTENT_TYPE_BY_FILE_EXTENSION_H
11
#define DF0_CONTENT_TYPE_BY_FILE_EXTENSION_H
12
13
#include "pipeline/element_base.hpp"
14
#include "content_type_export.h"
15
#include "data_source.h"
16
#include "document_elements.h"
17
21
namespace
df0::content_type::by_file_extension
22
{
23
34
DF0_CONTENT_TYPE_EXPORT
void
detect
(
data_source
& data);
35
44
DF0_CONTENT_TYPE_EXPORT std::optional<file_extension>
to_extension
(
const
mime_type
& mt);
45
55
class
detector
:
public
pipeline::transformer_element<detector>
56
{
57
public
:
58
continuation operator()(message_ptr msg,
const
message_callbacks
& emit_message)
59
{
60
if
(msg->is<
data_source
>())
61
{
62
data_source
& data = msg->get<
data_source
>();
63
detect
(data);
64
}
65
else
if
(msg->is<
document::image
>())
66
{
67
data_source
& data = msg->get<
document::image
>().source;
68
detect
(data);
69
}
70
return
emit_message(std::move(msg));
71
}
72
};
73
74
}
// namespace df0::content_type::by_file_extension
75
76
#endif
// DF0_CONTENT_TYPE_BY_FILE_EXTENSION_H
df0::content_type::by_file_extension::detector
Detector chain element.
Definition
content_type_by_file_extension.h:56
df0::data_source
Definition
data_source.h:136
df0::content_type::by_file_extension
Definition
content_type_by_file_extension.h:22
df0::content_type::by_file_extension::detect
DF0_CONTENT_TYPE_EXPORT void detect(data_source &data)
Detects and assigns content types to the provided data source using file extension.
df0::content_type::by_file_extension::to_extension
DF0_CONTENT_TYPE_EXPORT std::optional< file_extension > to_extension(const mime_type &mt)
Converts a mime type to a file extension.
df0::document::image
Definition
document_elements.h:117
df0::message_callbacks
Callback bundle used by pipeline elements to emit messages.
Definition
message.h:90
df0::mime_type
Wrapper for a MIME type string.
Definition
data_source.h:59
content_type_by_file_extension.h
Generated by
1.18.0