Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
input.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Authors:
4 * Ted Gould <ted@gould.cx>
5 *
6 * Copyright (C) 2002-2004 Authors
7 *
8 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
9 */
10
11
12#ifndef INKSCAPE_EXTENSION_INPUT_H__
13#define INKSCAPE_EXTENSION_INPUT_H__
14
15#include <exception>
16#include <glib.h>
17#include "extension.h"
18
19class SPDocument;
20
21namespace Inkscape {
22namespace Extension {
23
24class Input : public Extension {
25 gchar *mimetype;
26 gchar *extension;
27 gchar *filetypename;
30public:
31 struct open_failed : public std::exception {
32 ~open_failed() noexcept override = default;
33 const char *what() const noexcept override { return "Open failed"; }
34 };
35 struct no_extension_found : public std::exception {
36 ~no_extension_found() noexcept override = default;
37 const char *what() const noexcept override { return "No suitable input extension found"; }
38 };
39 struct open_cancelled : public std::exception {
40 ~open_cancelled() noexcept override = default;
41 const char *what() const noexcept override { return "Open was cancelled"; }
42 };
43
44 Input(Inkscape::XML::Node *in_repr, ImplementationHolder implementation, std::string *base_directory);
45 ~Input() override;
46
47 bool check() override;
48
49 std::unique_ptr<SPDocument> open(char const *uri, bool is_importing = false);
50 gchar const * get_mimetype () const;
51 gchar const * get_extension () const;
52 const char * get_filetypename (bool translated=false) const;
53 const char * get_filetypetooltip (bool translated=false) const;
54 bool can_open_filename (gchar const *filename) const;
55
56 static Extension *find_by_mime(char const *mime);
57 static Extension *find_by_filename(char const *filename);
58};
59
60} } /* namespace Inkscape, Extension */
61#endif /* INKSCAPE_EXTENSION_INPUT_H__ */
62
63/*
64 Local Variables:
65 mode:c++
66 c-file-style:"stroustrup"
67 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
68 indent-tabs-mode:nil
69 fill-column:99
70 End:
71*/
72// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
The object that is the basis for the Extension system.
Definition extension.h:133
Util::HybridPointer< Implementation::Implementation > ImplementationHolder
Definition extension.h:141
bool check() override
Validate this extension.
Definition input.cpp:126
const char * get_filetypename(bool translated=false) const
Get the name of the filetype supported.
Definition input.cpp:200
gchar const * get_extension() const
Get the filename extension for this extension.
Definition input.cpp:175
gchar * filetypename
A userfriendly name for the file type.
Definition input.h:27
gchar * mimetype
What is the mime type this inputs?
Definition input.h:25
~Input() override
Destroys an Input extension.
Definition input.cpp:108
gchar * filetypetooltip
A more detailed description of the filetype.
Definition input.h:28
static Extension * find_by_filename(char const *filename)
Get an input extension by filename matching.
Definition input.cpp:257
static Extension * find_by_mime(char const *mime)
Get an input extension by mime-type matching.
Definition input.cpp:237
const char * get_filetypetooltip(bool translated=false) const
Get the tooltip for more information on the filetype.
Definition input.cpp:221
gchar * extension
The extension of the input files.
Definition input.h:26
gchar const * get_mimetype() const
Get the mime-type that describes this extension.
Definition input.cpp:165
std::unique_ptr< SPDocument > open(char const *uri, bool is_importing=false)
This function creates a document from a file.
Definition input.cpp:147
bool can_open_filename(gchar const *filename) const
Match filename to extension that can open it.
Definition input.cpp:185
Interface for refcounted XML nodes.
Definition node.h:80
Typed SVG document implementation.
Definition document.h:103
Inkscape::Extension::Extension: Frontend to certain, possibly pluggable, actions.
Helper class to stream background task notifications as a series of messages.
const char * what() const noexcept override
Definition input.h:37
~no_extension_found() noexcept override=default
~open_cancelled() noexcept override=default
const char * what() const noexcept override
Definition input.h:41
const char * what() const noexcept override
Definition input.h:33
~open_failed() noexcept override=default