Coverage Report

Created: 2025-11-11 07:02

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wt/src/Wt/WDataInfo.h
Line
Count
Source
1
// This may look like C code, but it's really -*- C++ -*-
2
/*
3
 * Copyright (C) 2025 Emweb bv, Herent, Belgium.
4
 *
5
 * See the LICENSE file for terms of use.
6
 */
7
#ifndef WDATA_INFO_H_
8
#define WDATA_INFO_H_
9
10
#include "Wt/WAbstractDataInfo.h"
11
12
namespace Wt {
13
14
/*! \class WDataInfo Wt/WDataInfo Wt/WDataInfo
15
 *  \brief A class that stores informations about data
16
 *
17
 *  This is a barebone version of WAbstractDataInfo. It simply stores
18
 *  the information given to it.
19
 *
20
 *  \sa WDocRootDataInfo
21
 */
22
class WT_API WDataInfo : public WAbstractDataInfo
23
{
24
public:
25
  //! Creates an empty WDataInfo.
26
  WDataInfo();
27
28
  /*! \brief Creates a WDataInfo.
29
   *
30
   * Creates a WDataInfo with the given \p url and \p filePath.
31
   */
32
  WDataInfo(const std::string& url, const std::string& filePath);
33
34
  //! Sets the file path.
35
  void setFilePath(const std::string& filePath);
36
37
  /*! \brief Returns a path to a file containing the data.
38
   *
39
   * Throws if the file path is set to an empty string.
40
   *
41
   * \sa hasFilePath()
42
   */
43
  std::string filePath() const override;
44
45
  //! Sets the URL.
46
  void setUrl(const std::string& url);
47
48
  /*! \brief Returns the URL of the data.
49
   *
50
   * Throws if the URL is set to an empty string.
51
   *
52
   * \sa hasUrl()
53
   */
54
  std::string url() const override;
55
56
57
  //! Sets the data formated as data URI.
58
  void setDataUri(const std::string& dataUri);
59
60
  /*! \brief Returns the data in data URI format.
61
   *
62
   * Throws if the data URI is set to an empty string.
63
   *
64
   * \sa hasDataUri()
65
   */
66
  std::string dataUri() const override;
67
68
  /*! \brief Returns whether this contains a file path.
69
   *
70
   * This returns whether filePath() returns a non-empty string.
71
   *
72
   * \sa filePath()
73
   */
74
0
  bool hasFilePath() const override { return !filePath_.empty(); }
75
76
  /*! \brief Returns whether this contains a url.
77
   *
78
   * This returns whether url() returns a non-empty string.
79
   *
80
   * \sa url()
81
   */
82
0
  bool hasUrl() const override { return !url_.empty(); }
83
84
  /*! \brief Returns whether this can return the data in data URI format.
85
   *
86
   * This returns whether dataUri() returns a non-empty string.
87
   *
88
   * \sa dataUri()
89
   */
90
0
  virtual bool hasDataUri() const { return !dataUri_.empty(); }
91
92
private:
93
  std::string url_, filePath_, dataUri_;
94
};
95
96
}
97
98
99
100
#endif // WDATA_INFO_H_