22//
33// Module_Property.h: Rcpp R/C++ interface class library -- Rcpp modules
44//
5- // Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
5+ // Copyright (C) 2010 - 2017 Dirk Eddelbuettel and Romain Francois
66//
77// This file is part of Rcpp.
88//
2626template <typename Class, typename PROP>
2727class CppProperty_GetMethod : public CppProperty <Class> {
2828public:
29- typedef PROP (Class::*GetMethod)(void ) ;
30- typedef CppProperty<Class> prop_class ;
29+ typedef PROP (Class::*GetMethod)(void );
30+ typedef CppProperty<Class> prop_class;
3131
32- CppProperty_GetMethod ( GetMethod getter_, const char * doc = 0 ) :
32+ CppProperty_GetMethod (GetMethod getter_, const char * doc = 0 ) :
3333 prop_class (doc), getter(getter_), class_name(DEMANGLE(PROP)){}
3434
35- SEXP get (Class* object) { return Rcpp::wrap ( (object->*getter)() ) ; }
36- void set (Class*, SEXP) { throw std::range_error (" property is read only" ) ; }
37- bool is_readonly (){ return true ; }
35+ SEXP get (Class* object) { return Rcpp::wrap ((object->*getter)()) ; }
36+ void set (Class*, SEXP) { throw std::range_error (" property is read only" ); }
37+ bool is_readonly (){ return true ; }
3838 std::string get_class (){ return class_name; }
3939
4040private:
41- GetMethod getter ;
42- std::string class_name ;
41+ GetMethod getter;
42+ std::string class_name;
4343
44- } ;
44+ };
4545
4646// getter through a const member function
4747template <typename Class, typename PROP>
4848class CppProperty_GetConstMethod : public CppProperty <Class> {
4949public:
50- typedef PROP (Class::*GetMethod)(void ) const ;
51- typedef CppProperty<Class> prop_class ;
50+ typedef PROP (Class::*GetMethod)(void ) const ;
51+ typedef CppProperty<Class> prop_class;
5252
53- CppProperty_GetConstMethod ( GetMethod getter_ , const char * doc = 0 ) :
53+ CppProperty_GetConstMethod (GetMethod getter_ , const char * doc = 0 ) :
5454 prop_class (doc), getter(getter_), class_name(DEMANGLE(PROP)){}
5555
56- SEXP get (Class* object) { return Rcpp::wrap ( (object->*getter)() ) ; }
57- void set (Class*, SEXP) { throw std::range_error (" property is read only" ) ; }
58- bool is_readonly (){ return true ; }
56+ SEXP get (Class* object) { return Rcpp::wrap ((object->*getter)()) ; }
57+ void set (Class*, SEXP) { throw std::range_error (" property is read only" ); }
58+ bool is_readonly (){ return true ; }
5959 std::string get_class (){ return class_name; }
6060
6161private:
62- GetMethod getter ;
63- std::string class_name ;
62+ GetMethod getter;
63+ std::string class_name;
6464
65- } ;
65+ };
6666
6767
6868// getter through a free function taking a pointer to Class
6969template <typename Class, typename PROP>
7070class CppProperty_GetPointerMethod : public CppProperty <Class> {
7171public:
72- typedef PROP (*GetMethod)(Class*) ;
73- typedef CppProperty<Class> prop_class ;
72+ typedef PROP (*GetMethod)(Class*);
73+ typedef CppProperty<Class> prop_class;
7474
75- CppProperty_GetPointerMethod ( GetMethod getter_ , const char * doc = 0 ) :
75+ CppProperty_GetPointerMethod (GetMethod getter_ , const char * doc = 0 ) :
7676 prop_class (doc), getter(getter_), class_name(DEMANGLE(PROP)){}
7777
78- SEXP get (Class* object) { return Rcpp::wrap ( getter (object) ) ; }
79- void set (Class*, SEXP) { throw std::range_error (" property is read only" ) ; }
80- bool is_readonly (){ return true ; }
78+ SEXP get (Class* object) { return Rcpp::wrap (getter (object)) ; }
79+ void set (Class*, SEXP) { throw std::range_error (" property is read only" ); }
80+ bool is_readonly (){ return true ; }
8181 std::string get_class (){ return class_name; }
8282
8383private:
84- GetMethod getter ;
85- std::string class_name ;
86- } ;
84+ GetMethod getter;
85+ std::string class_name;
86+ };
8787
8888
8989// getter and setter through member functions
9090template <typename Class, typename PROP>
9191class CppProperty_GetMethod_SetMethod : public CppProperty <Class> {
9292public:
93- typedef PROP (Class::*GetMethod)(void ) ;
94- typedef void (Class::*SetMethod)(PROP) ;
95- typedef CppProperty<Class> prop_class ;
93+ typedef PROP (Class::*GetMethod)(void );
94+ typedef void (Class::*SetMethod)(PROP);
95+ typedef CppProperty<Class> prop_class;
9696
97- CppProperty_GetMethod_SetMethod ( GetMethod getter_, SetMethod setter_, const char * doc = 0 ) :
97+ CppProperty_GetMethod_SetMethod (GetMethod getter_, SetMethod setter_, const char * doc = 0 ) :
9898 prop_class (doc), getter(getter_), setter(setter_), class_name(DEMANGLE(PROP)){}
9999
100100 SEXP get (Class* object) {
101- return Rcpp::wrap ( (object->*getter)() ) ;
101+ return Rcpp::wrap ((object->*getter)()) ;
102102 }
103- void set (Class* object, SEXP value) throw(std::range_error,Rcpp::not_compatible){
104- (object->*setter)(
105- Rcpp::as< typename Rcpp::traits::remove_const_and_reference< PROP >::type >( value )
106- ) ;
103+ void set (Class* object, SEXP value) {
104+ (object->*setter)(Rcpp::as< typename Rcpp::traits::remove_const_and_reference< PROP >::type >(value));
107105 }
108- bool is_readonly (){ return false ; }
106+ bool is_readonly (){ return false ; }
109107 std::string get_class (){ return class_name; }
110108
111109private:
112- GetMethod getter ;
113- SetMethod setter ;
114- std::string class_name ;
115- } ;
110+ GetMethod getter;
111+ SetMethod setter;
112+ std::string class_name;
113+ };
116114template <typename Class, typename PROP>
117115class CppProperty_GetConstMethod_SetMethod : public CppProperty <Class> {
118116public:
119- typedef PROP (Class::*GetMethod)(void ) const ;
120- typedef void (Class::*SetMethod)(PROP) ;
121- typedef CppProperty<Class> prop_class ;
117+ typedef PROP (Class::*GetMethod)(void ) const ;
118+ typedef void (Class::*SetMethod)(PROP);
119+ typedef CppProperty<Class> prop_class;
122120
123- CppProperty_GetConstMethod_SetMethod ( GetMethod getter_, SetMethod setter_, const char * doc = 0 ) :
121+ CppProperty_GetConstMethod_SetMethod (GetMethod getter_, SetMethod setter_, const char * doc = 0 ) :
124122 prop_class (doc), getter(getter_), setter(setter_), class_name(DEMANGLE(PROP)){}
125123
126124 SEXP get (Class* object) {
127- return Rcpp::wrap ( (object->*getter)() ) ;
125+ return Rcpp::wrap ((object->*getter)()) ;
128126 }
129127 void set (Class* object, SEXP value) {
130- (object->*setter)(
131- Rcpp::as< typename Rcpp::traits::remove_const_and_reference< PROP >::type >( value )
132- ) ;
128+ (object->*setter)(Rcpp::as< typename Rcpp::traits::remove_const_and_reference< PROP >::type >(value));
133129 }
134- bool is_readonly (){ return false ; }
130+ bool is_readonly (){ return false ; }
135131 std::string get_class (){ return class_name; }
136132
137133private:
138- GetMethod getter ;
139- SetMethod setter ;
140- std::string class_name ;
134+ GetMethod getter;
135+ SetMethod setter;
136+ std::string class_name;
141137
142- } ;
138+ };
143139
144140
145141
@@ -148,116 +144,108 @@ class CppProperty_GetConstMethod_SetMethod : public CppProperty<Class> {
148144template <typename Class, typename PROP>
149145class CppProperty_GetMethod_SetPointer : public CppProperty <Class> {
150146public:
151- typedef PROP (Class::*GetMethod)(void ) ;
152- typedef void (*SetMethod)(Class*,PROP) ;
153- typedef CppProperty<Class> prop_class ;
147+ typedef PROP (Class::*GetMethod)(void );
148+ typedef void (*SetMethod)(Class*,PROP);
149+ typedef CppProperty<Class> prop_class;
154150
155- CppProperty_GetMethod_SetPointer ( GetMethod getter_, SetMethod setter_, const char * doc = 0 ) :
151+ CppProperty_GetMethod_SetPointer (GetMethod getter_, SetMethod setter_, const char * doc = 0 ) :
156152 prop_class (doc), getter(getter_), setter(setter_), class_name(DEMANGLE(PROP)){}
157153
158154 SEXP get (Class* object) {
159- return Rcpp::wrap ( (object->*getter)() ) ;
155+ return Rcpp::wrap ((object->*getter)()) ;
160156 }
161- void set (Class* object, SEXP value) throw(std::range_error,Rcpp::not_compatible){
162- setter ( object,
163- Rcpp::as< typename Rcpp::traits::remove_const_and_reference< PROP >::type >( value )
164- ) ;
157+ void set (Class* object, SEXP value) {
158+ setter (object, Rcpp::as< typename Rcpp::traits::remove_const_and_reference< PROP >::type >(value));
165159 }
166- bool is_readonly (){ return false ; }
160+ bool is_readonly (){ return false ; }
167161 std::string get_class (){ return class_name; }
168162
169163private:
170- GetMethod getter ;
171- SetMethod setter ;
172- std::string class_name ;
164+ GetMethod getter;
165+ SetMethod setter;
166+ std::string class_name;
173167
174- } ;
168+ };
175169template <typename Class, typename PROP>
176170class CppProperty_GetConstMethod_SetPointer : public CppProperty <Class> {
177171public:
178- typedef PROP (Class::*GetMethod)(void ) const ;
179- typedef void (*SetMethod)(Class*,PROP) ;
180- typedef CppProperty<Class> prop_class ;
172+ typedef PROP (Class::*GetMethod)(void ) const ;
173+ typedef void (*SetMethod)(Class*,PROP);
174+ typedef CppProperty<Class> prop_class;
181175
182- CppProperty_GetConstMethod_SetPointer ( GetMethod getter_, SetMethod setter_, const char * doc = 0 ) :
176+ CppProperty_GetConstMethod_SetPointer (GetMethod getter_, SetMethod setter_, const char * doc = 0 ) :
183177 prop_class (doc), getter(getter_), setter(setter_), class_name(DEMANGLE(PROP)){}
184178
185179 SEXP get (Class* object) {
186- return Rcpp::wrap ( (object->*getter)() ) ;
180+ return Rcpp::wrap ((object->*getter)()) ;
187181 }
188182 void set (Class* object, SEXP value) {
189- setter ( object,
190- Rcpp::as< typename Rcpp::traits::remove_const_and_reference< PROP >::type >( value )
191- ) ;
183+ setter (object, Rcpp::as< typename Rcpp::traits::remove_const_and_reference< PROP >::type >(value));
192184 }
193- bool is_readonly (){ return false ; }
185+ bool is_readonly (){ return false ; }
194186 std::string get_class (){ return class_name; }
195187
196188private:
197- GetMethod getter ;
198- SetMethod setter ;
199- std::string class_name ;
189+ GetMethod getter;
190+ SetMethod setter;
191+ std::string class_name;
200192
201- } ;
193+ };
202194
203195// getter through pointer function, setter through member function
204196template <typename Class, typename PROP>
205197class CppProperty_GetPointer_SetMethod : public CppProperty <Class> {
206198public:
207- typedef PROP (*GetMethod)(Class*) ;
208- typedef void (Class::*SetMethod)(PROP) ;
209- typedef CppProperty<Class> prop_class ;
199+ typedef PROP (*GetMethod)(Class*);
200+ typedef void (Class::*SetMethod)(PROP);
201+ typedef CppProperty<Class> prop_class;
210202
211- CppProperty_GetPointer_SetMethod ( GetMethod getter_, SetMethod setter_, const char * doc = 0 ) :
203+ CppProperty_GetPointer_SetMethod (GetMethod getter_, SetMethod setter_, const char * doc = 0 ) :
212204 prop_class (doc), getter(getter_), setter(setter_), class_name(DEMANGLE(PROP)){}
213205
214206 SEXP get (Class* object) {
215- return Rcpp::wrap ( getter (object) ) ;
207+ return Rcpp::wrap (getter (object)) ;
216208 }
217209 void set (Class* object, SEXP value) {
218- (object->*setter)(
219- Rcpp::as< typename Rcpp::traits::remove_const_and_reference< PROP >::type >( value )
220- ) ;
210+ (object->*setter)(Rcpp::as< typename Rcpp::traits::remove_const_and_reference< PROP >::type >(value));
221211 }
222- bool is_readonly (){ return false ; }
212+ bool is_readonly (){ return false ; }
223213 std::string get_class (){ return class_name; }
224214
225215private:
226- GetMethod getter ;
227- SetMethod setter ;
228- std::string class_name ;
216+ GetMethod getter;
217+ SetMethod setter;
218+ std::string class_name;
229219
230- } ;
220+ };
231221
232222// getter and setter through pointer functions
233223// getter through pointer function, setter through member function
234224template <typename Class, typename PROP>
235225class CppProperty_GetPointer_SetPointer : public CppProperty <Class> {
236226public:
237- typedef PROP (*GetMethod)(Class*) ;
238- typedef void (*SetMethod)(Class*,PROP) ;
239- typedef CppProperty<Class> prop_class ;
227+ typedef PROP (*GetMethod)(Class*);
228+ typedef void (*SetMethod)(Class*,PROP);
229+ typedef CppProperty<Class> prop_class;
240230
241- CppProperty_GetPointer_SetPointer ( GetMethod getter_, SetMethod setter_, const char * doc = 0 ) :
231+ CppProperty_GetPointer_SetPointer (GetMethod getter_, SetMethod setter_, const char * doc = 0 ) :
242232 prop_class (doc), getter(getter_), setter(setter_), class_name(DEMANGLE(PROP)){}
243233
244234 SEXP get (Class* object) {
245- return Rcpp::wrap ( getter (object) ) ;
235+ return Rcpp::wrap (getter (object)) ;
246236 }
247237 void set (Class* object, SEXP value) {
248- setter ( object,
249- Rcpp::as< typename Rcpp::traits::remove_const_and_reference< PROP >::type >( value )
250- ) ;
238+ setter (object, Rcpp::as< typename Rcpp::traits::remove_const_and_reference< PROP >::type >(value));
251239 }
252- bool is_readonly (){ return false ; }
240+ bool is_readonly (){ return false ; }
253241 std::string get_class (){ return class_name; }
254242
255243private:
256- GetMethod getter ;
257- SetMethod setter ;
258- std::string class_name ;
244+ GetMethod getter;
245+ SetMethod setter;
246+ std::string class_name;
259247
260- } ;
248+ };
261249
262250
263251#endif
0 commit comments