Swiftray  1.0
use-context.h
Go to the documentation of this file.
1 #include <QDebug>
3 
4 #pragma once
5 
6 namespace Parser {
7 
8 class UseContext : public BaseContext {
9 public:
10  UseContext(BaseContext const &parent) : BaseContext(parent) {
11  qInfo() << "<use>";
12  }
13 
14  boost::optional<double> const &width() const { return width_; }
15 
16  boost::optional<double> const &height() const { return height_; }
17 
18  using BaseContext::set;
19 
20  template<class IRI>
21  void set(tag::attribute::xlink::href, tag::iri_fragment,
22  IRI const &fragment) {
23  fragment_id_.assign(boost::begin(fragment), boost::end(fragment));
24  }
25 
26  template<class IRI>
27  void set(tag::attribute::xlink::href, IRI const &fragment) {
28  std::cerr << "External references aren't supported\n";
29  }
30 
31  void set(tag::attribute::x, double val) { x_ = val; }
32 
33  void set(tag::attribute::y, double val) { y_ = val; }
34 
35  void set(tag::attribute::width, double val) { width_ = val; }
36 
37  void set(tag::attribute::height, double val) { height_ = val; }
38 
39  void on_exit_element();
40 
41 private:
42  std::string fragment_id_;
43  double x_, y_;
44  boost::optional<double> width_, height_;
45 };
46 
47 }
Definition: base-context.h:10
void set(tag::attribute::width, double val)
Definition: object-context.h:9
Definition: use-context.h:8
boost::optional< double > const & height() const
Definition: use-context.h:16
void set(tag::attribute::width, double val)
Definition: use-context.h:35
boost::optional< double > const & width() const
Definition: use-context.h:14
UseContext(BaseContext const &parent)
Definition: use-context.h:10
void set(tag::attribute::height, double val)
Definition: use-context.h:37
void set(tag::attribute::xlink::href, IRI const &fragment)
Definition: use-context.h:27
void set(tag::attribute::y, double val)
Definition: use-context.h:33
void set(tag::attribute::x, double val)
Definition: use-context.h:31
void set(tag::attribute::xlink::href, tag::iri_fragment, IRI const &fragment)
Definition: use-context.h:21
void on_exit_element()
Definition: svgpp-impl.cpp:200
Definition: base-context.h:8