~blep/cppunit2/cpptl-range-xp

« back to all changes in this revision

Viewing changes to include/cpptl/value.h

  • Committer: Teho
  • Date: 2009-08-21 17:17:15 UTC
  • mfrom: (467.1.2 cpptl-integration)
  • Revision ID: teho@microtux-20090821171715-6rt51tcn2pkdz9mt
- added range features to detect contiguous range and use memcmp/wmemcmp when possible

Show diffs side-by-side

added added

removed removed

Lines of Context:
265
265
   const ValueType *type_;
266
266
};
267
267
 
268
 
// //////////////////////////////////////////////////////////////////
269
 
// //////////////////////////////////////////////////////////////////
270
 
// Value, free functions
271
 
// //////////////////////////////////////////////////////////////////
272
 
// //////////////////////////////////////////////////////////////////
273
 
 
274
 
/*
275
 
 * Notes: user can provides a specific implementation by overloding getValueType() for a given
276
 
 * type.
277
 
 * inline const ValueType &getValueType( const Type<T> & )
278
 
 */
279
 
 
280
 
#ifdef CPPTL_NO_FUNCTION_TEMPLATE_ORDERING
281
 
   struct HasDefaultValueTypeHelper
282
 
   {
283
 
   };
284
 
 
285
 
   inline HasDefaultValueTypeHelper getValueType( ... )
286
 
   {
287
 
      return HasDefaultValueTypeHelper();
288
 
   }
289
 
 
290
 
   template<class T>
291
 
   inline const ValueType &getValueTypeHelper( const ValueType &valueType, 
292
 
                                               const Type<T> &type )
293
 
   {
294
 
      return valueType;
295
 
   }
296
 
 
297
 
   template<class T>
298
 
   inline const ValueType &getValueTypeSelector( const Type<T> &type )
299
 
   {
300
 
      return getValueTypeHelper( getValueType(type), type );
301
 
   }
302
 
 
303
 
#  define CPPTL_GET_VALUE_TYPE( AType ) ::CppTL::getValueTypeSelector( ::CppTL::Type<AType>() )
304
 
 
305
 
# else
306
 
 
307
 
#  define CPPTL_GET_VALUE_TYPE( AType ) ::CppTL::getValueType( ::CppTL::Type<AType>() )
308
 
 
309
 
# endif
310
 
 
311
 
 
312
 
template<typename TargetValueType>
313
 
void initialize( Value &value, Type<TargetValueType> )
314
 
{
315
 
}
316
 
 
317
 
template<typename TargetValueType>
318
 
Value initialize( Type<TargetValueType> )
319
 
{
320
 
}
321
 
 
322
 
 
323
 
template<typename TargetValueType>
324
 
Value makeValue( const TargetValueType &value )
325
 
{
326
 
   const ValueType &type = CPPTL_GET_VALUE_TYPE( TargetValueType );
327
 
   return Value( type, &value );
328
 
}
329
 
 
330
 
template<typename TargetValueType>
331
 
void makeValue( Value &value, const TargetValueType &initialValue )
332
 
{
333
 
}
334
 
 
335
 
 
336
 
template<typename TargetValueType>
337
 
const TargetValueType &any_cast( const Value &value, Type<TargetValueType> )
338
 
{
339
 
}
340
 
 
341
 
template<typename TargetValueType>
342
 
TargetValueType &any_cast( Value &value, Type<TargetValueType> )
343
 
{
344
 
}
345
 
 
346
 
template<typename TargetValueType>
347
 
const TargetValueType *any_cast( const Value *value, Type<TargetValueType> )
348
 
{
349
 
}
350
 
 
351
 
template<typename TargetValueType>
352
 
TargetValueType *any_cast( Value *value, Type<TargetValueType> )
353
 
{
354
 
}
355
 
 
356
268
 
357
269
// //////////////////////////////////////////////////////////////////
358
270
// //////////////////////////////////////////////////////////////////
575
487
 
576
488
// default implementation of getValueType
577
489
# ifdef CPPTL_NO_FUNCTION_TEMPLATE_ORDERING
 
490
   struct HasDefaultValueTypeHelper
 
491
   {
 
492
   };
 
493
 
578
494
   template<class DataType>
579
495
   inline const ValueType &getValueTypeSelector( const HasDefaultValueTypeHelper &, 
580
496
                                                 const Type<DataType> & )
627
543
 
628
544
 
629
545
 
 
546
// //////////////////////////////////////////////////////////////////
 
547
// //////////////////////////////////////////////////////////////////
 
548
// Value, free functions
 
549
// //////////////////////////////////////////////////////////////////
 
550
// //////////////////////////////////////////////////////////////////
 
551
 
 
552
/*
 
553
 * Notes: user can provides a specific implementation by overloding getValueType() for a given
 
554
 * type.
 
555
 * inline const ValueType &getValueType( const Type<T> & )
 
556
 */
 
557
 
 
558
#ifdef CPPTL_NO_FUNCTION_TEMPLATE_ORDERING
 
559
   inline HasDefaultValueTypeHelper getValueType( ... )
 
560
   {
 
561
      return HasDefaultValueTypeHelper();
 
562
   }
 
563
 
 
564
   template<class T>
 
565
   inline const ValueType &getValueTypeHelper( const ValueType &valueType, 
 
566
                                               const Type<T> &type )
 
567
   {
 
568
      return valueType;
 
569
   }
 
570
 
 
571
   template<class T>
 
572
   inline const ValueType &getValueTypeSelector( const Type<T> &type )
 
573
   {
 
574
      return getValueTypeHelper( getValueType(type), type );
 
575
   }
 
576
 
 
577
#  define CPPTL_GET_VALUE_TYPE( AType ) ::CppTL::getValueTypeSelector( ::CppTL::Type<AType>() )
 
578
 
 
579
# else
 
580
 
 
581
#  define CPPTL_GET_VALUE_TYPE( AType ) ::CppTL::getValueType( ::CppTL::Type<AType>() )
 
582
 
 
583
# endif
 
584
 
 
585
 
 
586
template<typename TargetValueType>
 
587
void initialize( Value &value, Type<TargetValueType> )
 
588
{
 
589
}
 
590
 
 
591
template<typename TargetValueType>
 
592
Value initialize( Type<TargetValueType> )
 
593
{
 
594
}
 
595
 
 
596
 
 
597
template<typename TargetValueType>
 
598
Value makeValue( const TargetValueType &value )
 
599
{
 
600
   const ValueType &type = CPPTL_GET_VALUE_TYPE( TargetValueType );
 
601
   return Value( type, &value );
 
602
}
 
603
 
 
604
template<typename TargetValueType>
 
605
void makeValue( Value &value, const TargetValueType &initialValue )
 
606
{
 
607
}
 
608
 
 
609
 
 
610
template<typename TargetValueType>
 
611
const TargetValueType &any_cast( const Value &value, Type<TargetValueType> )
 
612
{
 
613
}
 
614
 
 
615
template<typename TargetValueType>
 
616
TargetValueType &any_cast( Value &value, Type<TargetValueType> )
 
617
{
 
618
}
 
619
 
 
620
template<typename TargetValueType>
 
621
const TargetValueType *any_cast( const Value *value, Type<TargetValueType> )
 
622
{
 
623
}
 
624
 
 
625
template<typename TargetValueType>
 
626
TargetValueType *any_cast( Value *value, Type<TargetValueType> )
 
627
{
 
628
}
 
629
 
 
630
 
 
631
 
 
632
 
630
633
 
631
634
// //////////////////////////////////////////////////////////////////
632
635
// //////////////////////////////////////////////////////////////////