STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ... ATLSTL - Template Software for the Active Template Library COMSTL - The Standard Template Library meets the Component Object Model .netSTL - Standard Template Library meets the Microsoft.NET Common Language Runtime InetSTL - The Standard Template Library meets WinInet MFCSTL - Template Software for the Microsoft Foundation Classes UNIXSTL - Template Software for the UNIX Operating System WinSTL - where the Standard Template Library meets the Win32 API

Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

stlsoft_sign_traits.h

Go to the documentation of this file.
00001 /* 
00002  * File:        stlsoft_sign_traits.h
00003  *
00004  * Purpose:     sign_traits classes.
00005  *
00006  * Created:     16th January 2002
00007  * Updated:     11th September 2004
00008  *
00009  * Home:        http://stlsoft.org/
00010  *
00011  * Copyright (c) 2002-2004, Matthew Wilson and Synesis Software
00012  * All rights reserved.
00013  *
00014  * Redistribution and use in source and binary forms, with or without
00015  * modification, are permitted provided that the following conditions are met:
00016  *
00017  * - Redistributions of source code must retain the above copyright notice, this
00018  *   list of conditions and the following disclaimer.
00019  * - Redistributions in binary form must reproduce the above copyright notice,
00020  *   this list of conditions and the following disclaimer in the documentation
00021  *   and/or other materials provided with the distribution.
00022  * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
00023  *   any contributors may be used to endorse or promote products derived from
00024  *   this software without specific prior written permission.
00025  *
00026  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00027  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00029  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00030  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00031  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00032  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00033  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00034  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00035  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00036  * POSSIBILITY OF SUCH DAMAGE.
00037  *
00038  * 
00039 
00040 
00044 
00045 #ifndef STLSOFT_INCL_H_STLSOFT_SIGN_TRAITS
00046 #define STLSOFT_INCL_H_STLSOFT_SIGN_TRAITS
00047 
00048 #ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION
00049 # define STLSOFT_VER_H_STLSOFT_SIGN_TRAITS_MAJOR        2
00050 # define STLSOFT_VER_H_STLSOFT_SIGN_TRAITS_MINOR        0
00051 # define STLSOFT_VER_H_STLSOFT_SIGN_TRAITS_REVISION     1
00052 # define STLSOFT_VER_H_STLSOFT_SIGN_TRAITS_EDIT         25
00053 #endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */
00054 
00055 /* 
00056  * Includes
00057  */
00058 
00059 #ifndef STLSOFT_INCL_H_STLSOFT
00060 # include "stlsoft.h"               // Include the STLSoft root header
00061 #endif /* !STLSOFT_INCL_H_STLSOFT */
00062 #ifndef STLSOFT_INCL_H_STLSOFT_SIZE_TRAITS
00063 # include "stlsoft_size_traits.h"   // int_size_traits
00064 #endif /* !STLSOFT_INCL_H_STLSOFT_SIZE_TRAITS */
00065 
00066 /* 
00067  * Namespace
00068  */
00069 
00070 #ifndef _STLSOFT_NO_NAMESPACE
00071 namespace stlsoft
00072 {
00073 #endif /* _STLSOFT_NO_NAMESPACE */
00074 
00075 /* 
00076  * Classes
00077  */
00078 
00079 // struct sign_traits
00080 
00081 #ifdef __STLSOFT_DOCUMENTATION_SKIP_SECTION
00092 template <ss_typename_param_k T>
00093 struct sign_traits
00094 {
00095     enum
00096     {
00097             bytes   =   1
00098         ,   bits    =   8                        
00099     };
00100 
00101     typedef signed T    signed_type;    
00102     typedef unsigned T  unsigned_type;  
00103     typedef unsigned T  alt_sign_type;  
00104 };
00105 
00106 #else
00107 
00108 template <ss_typename_param_k T>
00109 struct sign_traits;
00110 
00111 /* char */
00112 STLSOFT_TEMPLATE_SPECIALISATION
00113 struct sign_traits<ss_char_a_t>
00114 {
00115     enum { bytes = 1, bits = 8 * bytes };
00116 
00117     typedef ss_uint8_t  signed_type;
00118     typedef ss_uint8_t  unsigned_type;
00119 //    typedef ss_uint8_t  alt_sign_type;
00120 };
00121 
00122 #ifdef __STLSOFT_CF_NATIVE_WCHAR_T_SUPPORT
00123 STLSOFT_TEMPLATE_SPECIALISATION
00124 struct sign_traits<ss_char_w_t>
00125 {
00126     enum { bytes = sizeof(ss_char_w_t), bits = 8 * bytes };
00127 
00128     typedef int_size_traits<bytes>::signed_type     signed_type;
00129     typedef int_size_traits<bytes>::unsigned_type   unsigned_type;
00130 };
00131 #endif /* __STLSOFT_CF_NATIVE_WCHAR_T_SUPPORT */
00132 
00133 /* s/uint8 */
00134 STLSOFT_TEMPLATE_SPECIALISATION
00135 struct sign_traits<ss_sint8_t>
00136 {
00137     enum { bytes = 1, bits = 8 * bytes };
00138 
00139     typedef ss_sint8_t  signed_type;
00140     typedef ss_uint8_t  unsigned_type;
00141     typedef ss_uint8_t  alt_sign_type;
00142 };
00143 
00144 STLSOFT_TEMPLATE_SPECIALISATION
00145 struct sign_traits<ss_uint8_t>
00146 {
00147     enum { bytes = 1, bits = 8 * bytes };
00148 
00149     typedef ss_sint8_t  signed_type;
00150     typedef ss_uint8_t  unsigned_type;
00151     typedef ss_sint8_t  alt_sign_type;
00152 };
00153 
00154 /* s/uint16 */
00155 STLSOFT_TEMPLATE_SPECIALISATION
00156 struct sign_traits<ss_sint16_t>
00157 {
00158     enum { bytes = 2, bits = 8 * bytes };
00159 
00160     typedef ss_sint16_t signed_type;
00161     typedef ss_uint16_t unsigned_type;
00162     typedef ss_uint16_t alt_sign_type;
00163 };
00164 
00165 STLSOFT_TEMPLATE_SPECIALISATION
00166 struct sign_traits<ss_uint16_t>
00167 {
00168     enum { bytes = 2, bits = 8 * bytes };
00169 
00170     typedef ss_sint16_t signed_type;
00171     typedef ss_uint16_t unsigned_type;
00172     typedef ss_sint16_t alt_sign_type;
00173 };
00174 
00175 /* s/uint32 */
00176 STLSOFT_TEMPLATE_SPECIALISATION
00177 struct sign_traits<ss_sint32_t>
00178 {
00179     enum { bytes = 4, bits = 8 * bytes };
00180 
00181     typedef ss_sint32_t signed_type;
00182     typedef ss_uint32_t unsigned_type;
00183     typedef ss_uint32_t alt_sign_type;
00184 };
00185 
00186 STLSOFT_TEMPLATE_SPECIALISATION
00187 struct sign_traits<ss_uint32_t>
00188 {
00189     enum { bytes = 4, bits = 8 * bytes };
00190 
00191     typedef ss_sint32_t signed_type;
00192     typedef ss_uint32_t unsigned_type;
00193     typedef ss_sint32_t alt_sign_type;
00194 };
00195 
00196 #ifdef STLSOFT_CF_64BIT_INT_SUPPORT
00197 /* s/uint64 */
00198 STLSOFT_TEMPLATE_SPECIALISATION
00199 struct sign_traits<ss_sint64_t>
00200 {
00201     enum { bytes = 8, bits = 8 * bytes };
00202 
00203     typedef ss_sint64_t signed_type;
00204     typedef ss_uint64_t unsigned_type;
00205     typedef ss_uint64_t alt_sign_type;
00206 };
00207 
00208 STLSOFT_TEMPLATE_SPECIALISATION
00209 struct sign_traits<ss_uint64_t>
00210 {
00211     enum { bytes = 8, bits = 8 * bytes };
00212 
00213     typedef ss_sint64_t signed_type;
00214     typedef ss_uint64_t unsigned_type;
00215     typedef ss_sint64_t alt_sign_type;
00216 };
00217 #endif /* !STLSOFT_CF_64BIT_INT_SUPPORT */
00218 
00219 #endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */
00220 
00221 /* 
00222 
00223 #ifndef _STLSOFT_NO_NAMESPACE
00224 } // namespace stlsoft
00225 #endif /* _STLSOFT_NO_NAMESPACE */
00226 
00227 /* 
00228 
00229 #endif /* !STLSOFT_INCL_H_STLSOFT_SIGN_TRAITS */
00230 
00231 /* 

STLSoft Libraries documentation © Synesis Software Pty Ltd, 2001-2004