tclap 1.2.2
StandardTraits.h
Go to the documentation of this file.
1// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
2
3/******************************************************************************
4 *
5 * file: StandardTraits.h
6 *
7 * Copyright (c) 2007, Daniel Aarno, Michael E. Smoot .
8 * All rights reserved.
9 *
10 * See the file COPYING in the top directory of this distribution for
11 * more information.
12 *
13 * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 * DEALINGS IN THE SOFTWARE.
20 *
21 *****************************************************************************/
22
23// This is an internal tclap file, you should probably not have to
24// include this directly
25
26#ifndef TCLAP_STANDARD_TRAITS_H
27#define TCLAP_STANDARD_TRAITS_H
28
29#ifdef HAVE_CONFIG_H
30#include <config.h> // To check for long long
31#endif
32
33// If Microsoft has already typedef'd wchar_t as an unsigned
34// short, then compiles will break because it's as if we're
35// creating ArgTraits twice for unsigned short. Thus...
36#ifdef _MSC_VER
37#ifndef _NATIVE_WCHAR_T_DEFINED
38#define TCLAP_DONT_DECLARE_WCHAR_T_ARGTRAITS
39#endif
40#endif
41
42namespace TCLAP {
43
44// ======================================================================
45// Integer types
46// ======================================================================
47
51template<>
52struct ArgTraits<long> {
54};
55
59template<>
60struct ArgTraits<int> {
62};
63
67template<>
68struct ArgTraits<short> {
70};
71
75template<>
76struct ArgTraits<char> {
78};
79
80#ifdef HAVE_LONG_LONG
84template<>
85struct ArgTraits<long long> {
87};
88#endif
89
90// ======================================================================
91// Unsigned integer types
92// ======================================================================
93
97template<>
98struct ArgTraits<unsigned long> {
100};
101
105template<>
106struct ArgTraits<unsigned int> {
108};
109
113template<>
114struct ArgTraits<unsigned short> {
116};
117
121template<>
122struct ArgTraits<unsigned char> {
124};
125
126// Microsoft implements size_t awkwardly.
127#if defined(_MSC_VER) && defined(_M_X64)
131template<>
132struct ArgTraits<size_t> {
133 typedef ValueLike ValueCategory;
134};
135#endif
136
137
138#ifdef HAVE_LONG_LONG
142template<>
143struct ArgTraits<unsigned long long> {
144 typedef ValueLike ValueCategory;
145};
146#endif
147
148// ======================================================================
149// Float types
150// ======================================================================
151
155template<>
156struct ArgTraits<float> {
158};
159
163template<>
164struct ArgTraits<double> {
166};
167
168// ======================================================================
169// Other types
170// ======================================================================
171
175template<>
176struct ArgTraits<bool> {
178};
179
180
184#ifndef TCLAP_DONT_DECLARE_WCHAR_T_ARGTRAITS
185template<>
186struct ArgTraits<wchar_t> {
188};
189#endif
190
194template<>
195struct ArgTraits<std::string> {
197};
198
199template<typename T>
200void SetString(T &dst, const std::string &src)
201{
202 dst = src;
203}
204
205} // namespace
206
207#endif
208
Definition: Arg.h:58
void SetString(T &dst, const std::string &src)
Arg traits are used to get compile type specialization when parsing argument values.
Definition: ArgTraits.h:79
T::ValueCategory ValueCategory
Definition: ArgTraits.h:80
A string like argument value type is a value that can be set using operator=(string).
Definition: ArgTraits.h:48
A value like argument value type is a value that can be set using operator>>.
Definition: ArgTraits.h:38