-
Notifications
You must be signed in to change notification settings - Fork 388
Expand file tree
/
Copy pathWAbstractDataInfo.h
More file actions
117 lines (104 loc) · 3.16 KB
/
WAbstractDataInfo.h
File metadata and controls
117 lines (104 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2025 Emweb bv, Herent, Belgium.
*
* See the LICENSE file for terms of use.
*/
#ifndef W_ABSTRACT_DATA_INFO_H_
#define W_ABSTRACT_DATA_INFO_H_
#include "Wt/WDllDefs.h"
#include <string>
namespace Wt {
/*! \class WAbstractDataInfo Wt/WAbstractDataInfo Wt/WAbstractDataInfo
* \brief An abstract base class storing information of a resource
*
* This is an abstract class which is meant to store/compute
* information about a resource/file. Its primary use is to map URIs
* to file paths. This is to avoid confusion when rendering out these
* resources, so that depending on the context the resources is
* created under, locating the file correctly happens.
*/
class WT_API WAbstractDataInfo
{
public:
/*! \brief Returns a path to a file containing the data.
*
* This returns a path to a file containing the data. This should
* point to a path that exists on the system.
*
* By default this will throw an exception.
*
* \warning If you reimplement this function, you must also
* reimplement hasFilePath()
*
* \sa hasFilePath()
*/
virtual std::string filePath() const;
/*! \brief Returns the URL of the data.
*
* This returns the URL of the data. This can be both an absolute URL
* or a URL relative to the application's base URL.
*
* By default this will throw an exception.
*
* \warning If you reimplement this function, you must also
* reimplement hasUrl()
*
* \sa hasUrl()
*/
virtual std::string url() const;
/*! \brief Returns the data in data URI format.
*
* This returns the data in data URI format (see:
* https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Schemes/data).
*
* By default this will throw an exception.
*
* \warning If you reimplement this function, you must also
* reimplement hasDataUri()
*
* \sa hasDataUri()
*/
virtual std::string dataUri() const;
/*! \brief Returns the name of the Data.
*
* This returns the name of the data. This is mainly use for error
* reporting.
*
* By default this will return url() if hasUrl() is \p true. In case
* it is \p false, it will return filePath() if hasFilePath() is \p
* true, and it will return an empty string otherwise.
*/
virtual std::string name() const;
/*! \brief Returns whether this contains a path to a file.
*
* This returns whether filePath returns a path to a file containing
* the data.
*
* By default this returns \p false.
*
* \sa filePath()
*/
virtual bool hasFilePath() const { return false; }
/*! \brief Returns whether this contains a URL.
*
* This returns whether url() returns a URL of the data.
*
* By default this returns \p false.
*
* \sa url()
*/
virtual bool hasUrl() const { return false; }
/*! \brief Returns whether this can return the data in data URI format.
*
* This returns whether dataUri() returns the data in data URI
* format.
*
* By default this returns \p false.
*
* \sa dataUri()
*/
virtual bool hasDataUri() const { return false; }
};
}
#endif // W_ABSTRACT_DATA_INFO_H_