00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00053 #ifndef STLSOFT_INCL_STLSOFT_PROPERTIES_HPP_FIELD_PROPERTIES
00054 #define STLSOFT_INCL_STLSOFT_PROPERTIES_HPP_FIELD_PROPERTIES
00055
00056 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00057 # define STLSOFT_VER_STLSOFT_PROPERTIES_HPP_FIELD_PROPERTIES_MAJOR 4
00058 # define STLSOFT_VER_STLSOFT_PROPERTIES_HPP_FIELD_PROPERTIES_MINOR 0
00059 # define STLSOFT_VER_STLSOFT_PROPERTIES_HPP_FIELD_PROPERTIES_REVISION 3
00060 # define STLSOFT_VER_STLSOFT_PROPERTIES_HPP_FIELD_PROPERTIES_EDIT 32
00061 #endif
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
00078 # include <stlsoft/stlsoft.h>
00079 #endif
00080
00081
00082
00083
00084
00085 #ifndef _STLSOFT_NO_NAMESPACE
00086 namespace stlsoft
00087 {
00088 #endif
00089
00090
00091
00092
00093
00135 template< ss_typename_param_k V
00136 , ss_typename_param_k R
00137 , ss_typename_param_k C
00138 >
00139 class field_property_get
00140 {
00141 public:
00142 typedef V value_type;
00143 typedef R reference_type;
00144 typedef C container_type;
00145 typedef field_property_get<V, R, C> class_type;
00146
00147 # if defined(STLSOFT_COMPILER_IS_DMC)
00148 public:
00149 # else
00150 private:
00151 # endif
00152 field_property_get()
00153 {}
00154 private:
00155 ss_explicit_k field_property_get(reference_type value)
00156 : m_value(value)
00157 {}
00158
00159 class_type& operator =(reference_type value)
00160 {
00161 m_value = value;
00162
00163 return *this;
00164 }
00165
00166 STLSOFT_DECLARE_TEMPLATE_PARAM_AS_FRIEND(C);
00167
00168 public:
00170 operator reference_type () const
00171 {
00172 return m_value;
00173 }
00174
00175
00176 private:
00177 value_type m_value;
00178
00179
00180 private:
00181 field_property_get(class_type const&);
00182 class_type& operator =(class_type const&);
00183 };
00184
00185
00206 template< ss_typename_param_k V
00207 , ss_typename_param_k R
00208 , ss_typename_param_k C
00209 >
00210 class field_property_set
00211 {
00212 public:
00213 typedef V value_type;
00214 typedef R reference_type;
00215 typedef C container_type;
00216 typedef field_property_set<V, R, C> class_type;
00217
00218 # if defined(STLSOFT_COMPILER_IS_DMC)
00219 public:
00220 # else
00221 private:
00222 # endif
00223 field_property_set()
00224 {}
00225 private:
00226 ss_explicit_k field_property_set(reference_type value)
00227 : m_value(value)
00228 {}
00229
00230 operator reference_type () const
00231 {
00232 return m_value;
00233 }
00234
00235 STLSOFT_DECLARE_TEMPLATE_PARAM_AS_FRIEND(C);
00236
00237 public:
00239 class_type& operator =(reference_type value)
00240 {
00241 m_value = value;
00242
00243 return *this;
00244 }
00245
00246 private:
00247 value_type m_value;
00248
00249
00250 private:
00251 field_property_set(class_type const&);
00252 class_type& operator =(class_type const&);
00253 };
00254
00255
00256 #if 1
00257
00261 template< ss_typename_param_k V
00262 , ss_typename_param_k R
00263 >
00264 class field_property_get_external
00265 {
00266 public:
00267 typedef V value_type;
00268 typedef R reference_type;
00269 typedef field_property_get_external<V, R> class_type;
00270
00271 public:
00272 field_property_get_external(value_type& value)
00273 : m_value(value)
00274 {}
00275
00276
00277 public:
00279 operator reference_type() const
00280 {
00281 return m_value;
00282 }
00283
00284
00285 private:
00286 value_type &m_value;
00287 };
00288
00289
00294 template< ss_typename_param_k V
00295 , ss_typename_param_k R
00296 >
00297 class field_property_set_external
00298 {
00299 public:
00300 typedef V value_type;
00301 typedef R reference_type;
00302 typedef field_property_get_external<V, R> class_type;
00303
00304 public:
00305 field_property_set_external(value_type& value)
00306 : m_value(value)
00307 {}
00308
00309
00310 public:
00312 field_property_set_external& operator =(reference_type value)
00313 {
00314 m_value = value;
00315
00316 return *this;
00317 }
00318
00319
00320 private:
00321 value_type &m_value;
00322 };
00323 #else
00324
00325 template< ss_typename_param_k V
00326 , ss_typename_param_k R
00327 , ss_ptrdiff_t (*PFnOff)()
00328 >
00329 class field_property_get_external
00330 {
00331 public:
00332 typedef V value_type;
00333 typedef R reference_type;
00334 typedef field_property_get_external<V, R, PFnOff> class_type;
00335
00336
00337 public:
00339 operator reference_type() const
00340 {
00341 ss_ptrdiff_t offset = (*PFnOff)();
00342 value_type *pV = (value_type*)((ss_byte_t*)this - offset);
00343
00344 return *pV;
00345 }
00346 };
00347
00348
00349 template< ss_typename_param_k V
00350 , ss_typename_param_k R
00351 , ss_ptrdiff_t (*PFnOff)()
00352 >
00353 class field_property_set_external
00354 {
00355 public:
00356 typedef V value_type;
00357 typedef R reference_type;
00358 typedef field_property_get_external<V, R, PFnOff> class_type;
00359
00360
00361 public:
00363 field_property_set_external& operator =(reference_type value)
00364 {
00365 ss_ptrdiff_t offset = (*PFnOff)();
00366 value_type *pV = (value_type*)((ss_byte_t*)this - offset);
00367
00368 *pV = value;
00369
00370 return *this;
00371 }
00372 };
00373 #endif
00374
00375
00376
00377
00378
00379
00380
00381 template< ss_typename_param_k V
00382 , ss_typename_param_k R
00383 , ss_typename_param_k C
00384 , ss_typename_param_k S
00385 >
00386 inline S& operator <<( S& s
00387 , field_property_get<V, R, C> const& prop)
00388 {
00389 s << static_cast<R>(prop);
00390
00391 return s;
00392 }
00393
00394
00395
00396 template< ss_typename_param_k V
00397 , ss_typename_param_k R
00398 , ss_typename_param_k S
00399 >
00400 inline S& operator <<( S& s
00401 , field_property_get_external<V, R> const& prop)
00402 {
00403 s << static_cast<R>(prop);
00404
00405 return s;
00406 }
00407
00409
00410
00411 #ifdef STLSOFT_UNITTEST
00412 # include "./unittest/field_properties_unittest_.h"
00413 #endif
00414
00415
00416
00417 #ifndef _STLSOFT_NO_NAMESPACE
00418 }
00419 #endif
00420
00421
00422
00423 #endif
00424
00425