base_actions.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef BASE_ACTIONS_H
00012 #define BASE_ACTIONS_H
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00041 template<class Data_Type>
00042 class Attribute_body : public Generator_body<Data_Type>
00043 {
00044 public:
00045 Attribute_body(const Xml_string& name)
00046 : name_(name), default_(NULL)
00047 {}
00048
00049 Attribute_body(const Xml_string& name, const Data_Type& def)
00050 : name_(name), default_(new Data_Type(def))
00051 {}
00052
00053 ~Attribute_body()
00054 {
00055 if (default_)
00056 delete default_;
00057 }
00058
00059 void begin(const Xml_string&, Xml_attr)
00060 {
00061 if (attr.contains(name_))
00062 dig->push(new Data_Type(attr[name_]));
00063 else if (default_)
00064 dig->push(new Data_Type(default_));
00065 else
00066 dig->push(NULL);
00067 }
00068 private:
00069 const Xml_string name_;
00070 const Data_Type* default_;
00071 };
00072
00073
00074 template <class Type>
00075 struct Attribute : public MakeGenerator<Attribute_body<Type>, const Xml_string&, const Type&>
00076 {
00077 Attribute(const Xml_string& name)
00078 : MakeGenerator<Attribute_body<Type>, const Xml_string&>::MakeGenerator(name) {}
00079
00080 Attribute(const Xml_string& name, const Type& def)
00081 : MakeGenerator<Attribute_body<Type>, const Xml_string&, const Type&>::MakeGenerator(name, def) {}
00082
00083 };
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 #endif
00152