Swiftray  1.0
text-context.h
Go to the documentation of this file.
1 #include <QDebug>
3 #include <iostream>
4 
5 #pragma once
6 
7 namespace Parser {
8 
9 class TextContext : public BaseContext {
10 public:
11  TextContext(BaseContext const &parent) : BaseContext(parent), x_(0), y_(0) {
12  qInfo() << "Enter text";
13  }
14 
15  template<class Range>
16  void set_text(Range const &text) {
17  text_content_.append(boost::begin(text), boost::end(text));
18  }
19 
20  template<class Range>
21  void set(tag::attribute::x, Range const &range) {
22  for (auto it = boost::begin(range), end = boost::end(range); it != end;
23  ++it)
24  std::cout << *it;
25  }
26 
27  template<class Range>
28  void set(tag::attribute::y, Range const &range) {
29  for (auto it = boost::begin(range), end = boost::end(range); it != end;
30  ++it)
31  std::cout << *it;
32  }
33 
34  using BaseContext::set;
35  using ObjectContext::set;
37 
38  void set(tag::attribute::x, double x) { x_ = x; }
39 
40  void set(tag::attribute::y, double y) { y_ = y; }
41 
42 private:
43  std::string text_content_;
44  double x_, y_;
45 };
46 
47 }
Definition: base-context.h:10
void set(tag::attribute::width, double val)
Definition: object-context.h:9
void set(tag::attribute::width, double val)
Definition: object-context.h:9
void set(svgpp::tag::attribute::display, svgpp::tag::value::none)
Definition: stylable-context.h:150
Definition: text-context.h:9
void set(tag::attribute::y, Range const &range)
Definition: text-context.h:28
TextContext(BaseContext const &parent)
Definition: text-context.h:11
void set(tag::attribute::x, Range const &range)
Definition: text-context.h:21
void set(tag::attribute::x, double x)
Definition: text-context.h:38
void set_text(Range const &text)
Definition: text-context.h:16
void set(tag::attribute::y, double y)
Definition: text-context.h:40
Definition: base-context.h:8