- Timestamp:
- Sep 26, 2009, 12:57:46 AM (14 years ago)
- Location:
- trunk/lib/yat
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/yat/CommandLine.cc
r795 r824 1 // $Id: CommandLine.cc 1874 2009-03-17 22:09:01Z peter $1 // $Id: CommandLine.cc 2046 2009-09-02 21:42:32Z peter $ 2 2 3 3 /* … … 33 33 #include <functional> 34 34 #include <fstream> 35 #include < iostream>35 #include <ostream> 36 36 #include <sstream> 37 37 #include <stdexcept> -
trunk/lib/yat/CommandLine.h
r795 r824 2 2 #define _theplu_yat_utility_commandline_ 3 3 4 //$Id: CommandLine.h 1954 2009-05-07 15:30:58Z jari$4 //$Id: CommandLine.h 2054 2009-09-06 18:25:06Z peter $ 5 5 6 6 /* … … 26 26 #include <cctype> 27 27 #include <map> 28 #include <ios tream>28 #include <iosfwd> 29 29 #include <sstream> 30 30 #include <stdexcept> … … 52 52 CommandLine cmd; 53 53 OptionHelp help(cmd); 54 OptionInFile in(cmd, "i,in", 55 "Read input from file (rather than standard input)"); 56 OptionOutFile out(cmd, "o,out", "Place the output to file"); 54 OptionFile in(cmd, "i,in", 55 "Read input from file (rather than standard input)", 56 false, true, "r"); 57 OptionFile out(cmd, "o,out", "Place the output to file", false, false, "w"); 57 58 OptionSwitch target(cmd, "T,target", "treat DEST as a normal file", true); 58 59 OptionSwitch verbose(cmd, "v,verbose", "explain what is being done"); … … 79 80 return EXIT_SUCCESS; 80 81 } 82 StreamRedirect sr_out(std::cout, out.value(), out.present()); 83 StreamRedirect sr_in(std::cin, in.value(), in.present()); 81 84 ... 82 85 \endcode … … 129 132 /** 130 133 \brief parse the commandline 134 135 First the commandline is parsed to detect which options are 136 present, then each Option parses the its relevant part of 137 commandline (Option::parse()), and finally each Option is 138 validated (Option::validate()). 131 139 132 140 throw cmd_error if an error is detected. -
trunk/lib/yat/Option.h
r795 r824 2 2 #define _theplu_yat_utility_option_ 3 3 4 // $Id: Option.h 1797 2009-02-12 18:07:10Z peter $4 // $Id: Option.h 2046 2009-09-02 21:42:32Z peter $ 5 5 6 6 /* 7 7 Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson 8 Copyright (C) 2009 Peter Johansson 8 9 9 10 This file is part of the yat library, http://dev.thep.lu.se/yat … … 23 24 */ 24 25 25 #include <iostream>26 26 #include <string> 27 27 #include <vector> … … 104 104 \brief Validate the Option 105 105 106 This function is called after commandline is parsed. 106 This function is called by CommandLine::parse() after all 107 options have been detected and parsed (see Option::parse()). 107 108 */ 108 109 void validate(void); -
trunk/lib/yat/OptionArg.h
r795 r824 2 2 #define _theplu_yat_utility_option_arg_ 3 3 4 // $Id: OptionArg.h 1797 2009-02-12 18:07:10Z peter $4 // $Id: OptionArg.h 2046 2009-09-02 21:42:32Z peter $ 5 5 6 6 /* … … 45 45 "--support-gnu=value", POSIX-like "--support-posix value", as 46 46 well as shorter "-s value". The argument of an parameter is 47 retrived by the value() function 47 retrived by the value() function. The type \c T should be either 48 a string or a type supported by function convert(). 48 49 */ 49 50 template<typename T> -
trunk/lib/yat/OptionHelp.cc
r823 r824 1 // $Id: OptionHelp.cc 1797 2009-02-12 18:07:10Z peter $1 // $Id: OptionHelp.cc 2055 2009-09-08 18:23:43Z peter $ 2 2 3 3 /* … … 24 24 25 25 #include <cstdlib> 26 #include < sstream>26 #include <iostream> 27 27 #include <string> 28 28 -
trunk/lib/yat/deprecate.h
r795 r824 2 2 #define _theplu_yat_utility_deprecate_ 3 3 4 // $Id: deprecate.h 1707 2009-01-12 22:51:35Z peter $4 // $Id: deprecate.h 2062 2009-09-14 20:19:17Z peter $ 5 5 6 6 /* … … 41 41 #endif 42 42 43 // With GCC version < 4.3 deprecation of classes yields no 44 // warning. Therefore, we deprecate the constructors of those classes 45 // with this macro YAT_DEPRECATE_GCC_PRE4_3, which is mute for 46 // compiler GCC 4.3 and newer and for others compilers than GCC. 47 #ifndef YAT_DEPRECATE_GCC_PRE4_3 48 #if defined(__GNUC__) && ((__GNUC__<4) || (__GNUC__==4 && __GNUC_MINOR__<3)) 49 /// if GCC version before 4.3 define as YAT_DEPRECATE defined above 50 #define YAT_DEPRECATE_GCC_PRE4_3 YAT_DEPRECATE 51 #else 52 /// with GCC 4.3 and newer (or other compilers) define it as empty 53 #define YAT_DEPRECATE_GCC_PRE4_3 43 54 #endif 55 #endif 56 57 #endif -
trunk/lib/yat/utility.h
r795 r824 2 2 #define _theplu_yat_utility_utility_ 3 3 4 // $Id: utility.h 1971 2009-05-11 20:42:16Z peter $4 // $Id: utility.h 2055 2009-09-08 18:23:43Z peter $ 5 5 6 6 /* … … 205 205 if (is_equal(s, "inf")) 206 206 return std::numeric_limits<T>::infinity(); 207 if (is_equal(s, "-inf")) 207 if (is_equal(s, "-inf")) { 208 208 if (std::numeric_limits<T>::is_signed) 209 209 return -std::numeric_limits<T>::infinity(); … … 211 211 throw std::runtime_error(std::string("yat::utility::convert(\"")+s+ 212 212 std::string("\"): type is unsigned") ); 213 } 213 214 std::stringstream ss(s); 214 215 T a;
Note: See TracChangeset
for help on using the changeset viewer.