BASIS  version 1.2.3 (revision 2104)
StandardTraits.h
00001 // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
00002 
00003 /******************************************************************************
00004  *
00005  *  file:  StandardTraits.h
00006  *
00007  *  Copyright (c) 2007, Daniel Aarno, Michael E. Smoot .
00008  *  All rights reverved.
00009  *
00010  *  See the file COPYING in the top directory of this distribution for
00011  *  more information.
00012  *
00013  *  THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
00014  *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00015  *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00016  *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00017  *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00018  *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00019  *  DEALINGS IN THE SOFTWARE.
00020  *
00021  *****************************************************************************/
00022 
00023 // This is an internal tclap file, you should probably not have to
00024 // include this directly
00025 
00026 #ifndef TCLAP_STANDARD_TRAITS_H
00027 #define TCLAP_STANDARD_TRAITS_H
00028 
00029 #include <sbia/basis/config.h> // To check for long long
00030 
00031 // If Microsoft has already typedef'd wchar_t as an unsigned 
00032 // short, then compiles will break because it's as if we're
00033 // creating ArgTraits twice for unsigned short. Thus...
00034 #ifdef _MSC_VER
00035 #ifndef _NATIVE_WCHAR_T_DEFINED
00036 #define TCLAP_DONT_DECLARE_WCHAR_T_ARGTRAITS
00037 #endif
00038 #endif
00039 
00040 namespace TCLAP {
00041 
00042 // ======================================================================
00043 // Integer types
00044 // ======================================================================
00045 
00046 /**
00047  * longs have value-like semantics.
00048  */
00049 template<>
00050 struct ArgTraits<long> {
00051     typedef ValueLike ValueCategory;
00052 };
00053 
00054 /**
00055  * ints have value-like semantics.
00056  */
00057 template<>
00058 struct ArgTraits<int> {
00059     typedef ValueLike ValueCategory;
00060 };
00061 
00062 /**
00063  * shorts have value-like semantics.
00064  */
00065 template<>
00066 struct ArgTraits<short> {
00067     typedef ValueLike ValueCategory;
00068 };
00069 
00070 /**
00071  * chars have value-like semantics.
00072  */
00073 template<>
00074 struct ArgTraits<char> {
00075     typedef ValueLike ValueCategory;
00076 };
00077 
00078 #ifdef HAVE_LONG_LONG
00079 /**
00080  * long longs have value-like semantics.
00081  */
00082 template<>
00083 struct ArgTraits<long long> {
00084     typedef ValueLike ValueCategory;
00085 };
00086 #endif
00087 
00088 // ======================================================================
00089 // Unsigned integer types
00090 // ======================================================================
00091 
00092 /**
00093  * unsigned longs have value-like semantics.
00094  */
00095 template<>
00096 struct ArgTraits<unsigned long> {
00097     typedef ValueLike ValueCategory;
00098 };
00099 
00100 /**
00101  * unsigned ints have value-like semantics.
00102  */
00103 template<>
00104 struct ArgTraits<unsigned int> {
00105     typedef ValueLike ValueCategory;
00106 };
00107 
00108 /**
00109  * unsigned shorts have value-like semantics.
00110  */
00111 template<>
00112 struct ArgTraits<unsigned short> {
00113     typedef ValueLike ValueCategory;
00114 };
00115 
00116 /**
00117  * unsigned chars have value-like semantics.
00118  */
00119 template<>
00120 struct ArgTraits<unsigned char> {
00121     typedef ValueLike ValueCategory;
00122 };
00123 
00124 // Microsoft implements size_t awkwardly. 
00125 #if defined(_MSC_VER) && defined(_M_X64)
00126 /**
00127  * size_ts have value-like semantics.
00128  */
00129 template<>
00130 struct ArgTraits<size_t> {
00131     typedef ValueLike ValueCategory;
00132 };
00133 #endif
00134 
00135 
00136 #ifdef HAVE_LONG_LONG
00137 /**
00138  * unsigned long longs have value-like semantics.
00139  */
00140 template<>
00141 struct ArgTraits<unsigned long long> {
00142     typedef ValueLike ValueCategory;
00143 };
00144 #endif
00145 
00146 // ======================================================================
00147 // Float types
00148 // ======================================================================
00149 
00150 /**
00151  * floats have value-like semantics.
00152  */
00153 template<>
00154 struct ArgTraits<float> {
00155     typedef ValueLike ValueCategory;
00156 };
00157 
00158 /**
00159  * doubles have value-like semantics.
00160  */
00161 template<>
00162 struct ArgTraits<double> {
00163     typedef ValueLike ValueCategory;
00164 };
00165 
00166 // ======================================================================
00167 // Other types
00168 // ======================================================================
00169 
00170 /**
00171  * bools have value-like semantics.
00172  */
00173 template<>
00174 struct ArgTraits<bool> {
00175     typedef ValueLike ValueCategory;
00176 };
00177 
00178 
00179 /**
00180  * wchar_ts have value-like semantics.
00181  */
00182 #ifndef TCLAP_DONT_DECLARE_WCHAR_T_ARGTRAITS
00183 template<>
00184 struct ArgTraits<wchar_t> {
00185     typedef ValueLike ValueCategory;
00186 };
00187 #endif
00188 
00189 /**
00190  * Strings have string like argument traits.
00191  */
00192 template<>
00193 struct ArgTraits<std::string> {
00194     typedef StringLike ValueCategory;
00195 };
00196 
00197 template<typename T>
00198 void SetString(T &dst, const std::string &src)
00199 {
00200     dst = src;
00201 }
00202 
00203 } // namespace
00204 
00205 #endif
00206