os/ossrv/stdcpp/tsrc/Stdcpp_test/stdcxx/include/any.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /***************************************************************************
     2  *
     3  * any.h - definition of the rw_any_t class
     4  *
     5  * $Id: any.h 290028 2005-09-19 00:25:26Z sebor $
     6  *
     7  ***************************************************************************
     8  *
     9  * Copyright (c) 1994-2005 Quovadx,  Inc., acting through its  Rogue Wave
    10  * Software division. Licensed under the Apache License, Version 2.0 (the
    11  * "License");  you may  not use this file except  in compliance with the
    12  * License.    You    may   obtain   a   copy   of    the   License    at
    13  * http://www.apache.org/licenses/LICENSE-2.0.    Unless   required    by
    14  * applicable law  or agreed to  in writing,  software  distributed under
    15  * the License is distributed on an "AS IS" BASIS,  WITHOUT WARRANTIES OR
    16  * CONDITIONS OF  ANY KIND, either  express or implied.  See  the License
    17  * for the specific language governing permissions  and limitations under
    18  * the License.
    19  * 
    20  **************************************************************************/
    21 
    22 #ifndef RW_ANY_H_INCLUDED
    23 #define RW_ANY_H_INCLUDED
    24 
    25 
    26 #include <testdefs.h>
    27 #ifdef __SYMBIAN32__
    28 #include<wchar.h>
    29 #endif //__SYMBIAN32__
    30 
    31 class rw_any_t
    32 {
    33 public:
    34 
    35 #ifndef _RWSTD_NO_BOOL
    36     _TEST_EXPORT rw_any_t (bool);
    37 #endif   // _RWSTD_NO_BOOL
    38 
    39     _TEST_EXPORT rw_any_t (char);
    40     _TEST_EXPORT rw_any_t (signed char);
    41     _TEST_EXPORT rw_any_t (unsigned char);
    42 
    43     _TEST_EXPORT rw_any_t (signed short);
    44     _TEST_EXPORT rw_any_t (unsigned short);
    45 
    46     _TEST_EXPORT rw_any_t (signed int);
    47     _TEST_EXPORT rw_any_t (unsigned int);
    48 
    49     _TEST_EXPORT rw_any_t (signed long);
    50     _TEST_EXPORT rw_any_t (unsigned long);
    51 
    52 #ifdef _RWSTD_LONG_LONG
    53     _TEST_EXPORT rw_any_t (signed _RWSTD_LONG_LONG);
    54     _TEST_EXPORT rw_any_t (unsigned _RWSTD_LONG_LONG);
    55 #endif   // _RWSTD_LONG_LONG
    56 
    57     _TEST_EXPORT rw_any_t (float);
    58     _TEST_EXPORT rw_any_t (double);
    59 
    60 #ifndef _RWSTD_NO_LONG_DOUBLE
    61     _TEST_EXPORT rw_any_t (long double);
    62 #endif   // _RWSTD_NO_LONG_DOUBLE
    63 
    64     _TEST_EXPORT rw_any_t (const void*);
    65     _TEST_EXPORT  rw_any_t (const char*);
    66 
    67 #ifndef _RWSTD_NO_NATIVE_WCHAR_T
    68     _TEST_EXPORT rw_any_t (wchar_t);
    69 #endif   // _RWSTD_NO_NATIVE_WCHAR_T
    70 
    71 #ifndef _RWSTD_NO_WCHAR_T
    72     _TEST_EXPORT rw_any_t (const wchar_t*);
    73 #endif   // _RWSTD_NO_WCHAR_T
    74 
    75     _TEST_EXPORT rw_any_t (const rw_any_t&);
    76 
    77     _TEST_EXPORT ~rw_any_t ();
    78 
    79     _TEST_EXPORT rw_any_t& operator= (const rw_any_t&);
    80 
    81     _TEST_EXPORT const char* tostr (const char* = 0);
    82     _TEST_EXPORT const char* type_name () const;
    83 
    84     enum type_id_t {
    85         t_none,
    86         t_bool, t_schar, t_uchar, t_char,
    87         t_sshrt, t_ushrt, t_sint, t_uint, t_slong, t_ulong,
    88         t_sllong, t_ullong,
    89         t_flt, t_dbl, t_ldbl,
    90         t_wchar,
    91         t_pvoid,
    92         t_str,
    93         t_wstr
    94     };
    95 
    96 private:
    97 
    98     union uval_t {
    99 
   100 #ifndef _RWSTD_NO_LONG_DOUBLE
   101         long double ldbl_;
   102 #endif   // _RWSTD_NO_LONG_DOUBLE
   103         const void *pvoid_;
   104         double      dbl_;
   105 #ifdef _RWSTD_LONG_LONG
   106         signed _RWSTD_LONG_LONG   sllong_;
   107         unsigned _RWSTD_LONG_LONG ullong_;
   108 #endif   // _RWSTD_LONG_LONG
   109         float          flt_;
   110 #ifndef _RWSTD_NO_NATIVE_WCHAR_T
   111         wchar_t        wchar_;
   112 #endif   // _RWSTD_NO_NATIVE_WCHAR_T
   113         signed long    slong_;
   114         unsigned long  ulong_;
   115         signed int     sint_;
   116         unsigned int   uint_;
   117         signed short   sshrt_;
   118         unsigned short ushrt_;
   119         signed char    schar_;
   120         unsigned char  uchar_;
   121         char           char_;
   122 #ifndef _RWSTD_NO_BOOL
   123         bool           bool_;
   124 #endif   // _RWSTD_NO_BOOL
   125     } val_;
   126 
   127     char      *str_;
   128     type_id_t  tid_;
   129 };
   130 
   131 
   132 #define TOSTR(x)   rw_any_t (x).tostr ()
   133 
   134 
   135 #endif   // RW_ANY_H_INCLUDED