Scribus
Open source desktop publishing at your fingertips
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
base_actions.h
1
/*
2
* base_actions.h
3
*
4
*
5
* Created by Andreas Vox on 02.06.06.
6
* Copyright 2006 under GPL2. All rights reserved.
7
*
8
*/
9
10
11
#ifndef BASE_ACTIONS_H
12
#define BASE_ACTIONS_H
13
14
/*****
15
16
Defines the following actions:
17
18
Attribute<D>( name, def) - -> D
19
Attribute<D>( name ) - -> D
20
*RefAttribute<D>( name ) - -> D
21
*Get<O,D>( gen<O>, fun ) - -> D
22
*Set<O,D>( gen<O>, fun, gen<D> ) - -> -
23
*Top<D>( n ) - -> D
24
*Bottom<D>( n ) - -> D
25
*WithText<O,D>( gen<O>, fun ) - -> -
26
*Invoke<O, F, A1, ...>(fun, a1, ...) O -> O
27
*InvokeLater<O, F, A1, ...>(fun, a1, ...) O -> O
28
*Call<F,A1, ..., An>(fun, a1, ..., an) - -> -
29
*CallLater<F,A1, ..., An>(fun, a1, ..., an) - -> -
30
*Filter<D,E> ( gen<D>, fun ) - -> E
31
*Combine<D,E,F> ( gen<D>, gen<D>, fun) - -> F
32
33
*****/
34
35
41
template
<
class
Data_Type>
42
class
Attribute_body
:
public
Generator_body<Data_Type>
43
{
44
public
:
45
Attribute_body
(
const
Xml_string& name)
46
: name_(name), default_(NULL)
47
{}
48
49
Attribute_body
(
const
Xml_string& name,
const
Data_Type& def)
50
: name_(name), default_(
new
Data_Type(def))
51
{}
52
53
~
Attribute_body
()
54
{
55
if
(default_)
56
delete
default_;
57
}
58
59
void
begin(
const
Xml_string&, Xml_attr)
60
{
61
if
(attr.contains(name_))
62
dig->push(
new
Data_Type(attr[name_]));
63
else
if
(default_)
64
dig->push(
new
Data_Type(default_));
65
else
66
dig->push(NULL);
67
}
68
private
:
69
const
Xml_string name_;
70
const
Data_Type* default_;
71
};
72
73
74
template
<
class
Type>
75
struct
Attribute
:
public
MakeGenerator<Attribute_body<Type>, const Xml_string&, const Type&>
76
{
77
Attribute
(
const
Xml_string& name)
78
: MakeGenerator<Attribute_body<Type>,
const
Xml_string&>::MakeGenerator(name) {}
79
80
Attribute
(
const
Xml_string& name,
const
Type& def)
81
: MakeGenerator<Attribute_body<Type>,
const
Xml_string&,
const
Type&>::MakeGenerator(name, def) {}
82
83
};
84
85
86
87
/*
88
template<class Functor>
89
class Call0 : public Action
90
{
91
public:
92
Call0(Functor f) : fun(f)
93
{}
94
95
void begin(const std::string, std::map<std::string,std::string> attr)
96
{
97
fun();
98
}
99
private:
100
Functor fun;
101
};
102
103
104
template<class Functor, class Arg1>
105
class Call1 : public Action
106
{
107
public:
108
Call1(Functor f, Generator<Arg1> a1) : fun(f), arg1(a1)
109
{}
110
111
void begin(const std::string, std::map<std::string,std::string> attr)
112
{
113
fun(arg1->eval(digester(), tag, attr));
114
}
115
private:
116
Functor fun;
117
Generator<Arg1> arg1;
118
};
119
120
template<class Functor, class Arg1, class Arg2>
121
class Call2 : public Action
122
{
123
public:
124
Call2(Functor f, Generator<Arg1>* a1, Generator<Arg2>* a2) : fun(f), arg1(a1), arg2(a2)
125
{}
126
127
void begin(const std::string, std::map<std::string,std::string> attr)
128
{
129
fun(arg1->eval(digester(), tag, attr),
130
arg2->eval(digester(), tag, attr));
131
}
132
private:
133
Functor fun;
134
Generator<Arg1> arg1;
135
Generator<Arg2> arg2;
136
};
137
138
/* Baustelle
139
template<class Obj_Type, class Data_Type>
140
class Invoke : public Action
141
{
142
public:
143
Invoke(void (Obj_Type::*inv)(Data_Type&)) : set_(set) {}
144
void end(const std::string);
145
private:
146
void (Obj_Type::*set_)(Data_Type&);
147
};
148
*/
149
150
151
#endif
152
Attribute
Definition:
base_actions.h:75
Attribute_body
Definition:
base_actions.h:42
scribus
desaxe
base_actions.h
Generated on Tue Sep 29 2015 09:14:57 for Scribus by
1.8.9.1