Changeset 1741
- Timestamp:
- Jan 22, 2009, 11:36:42 PM (14 years ago)
- Location:
- trunk/yat/utility
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/utility/CommandLine.cc
r1634 r1741 3 3 /* 4 4 Copyright (C) 2007 Jari Häkkinen, Peter Johansson, Markus Ringnér 5 Copyright (C) 2008 Peter Johansson5 Copyright (C) 2008, 2009 Peter Johansson 6 6 7 7 This file is part of the yat library, http://dev.thep.lu.se/yat … … 43 43 44 44 CommandLine::CommandLine(std::string str) 45 : description_(str), free_arg_max_(0) 45 : description_(str), free_arg_max_(0), parsed_(false) 46 46 {} 47 47 … … 103 103 void CommandLine::parse(int argc, char* argv[]) 104 104 { 105 parsed_=true; 105 106 using namespace std; 106 107 // just in case it is not pristine … … 182 183 183 184 185 bool CommandLine::parsed(void) const 186 { 187 return parsed_; 188 } 189 190 184 191 std::string CommandLine::program_name(void) const 185 192 { -
trunk/yat/utility/CommandLine.h
r1487 r1741 6 6 /* 7 7 Copyright (C) 2007 Jari Häkkinen, Peter Johansson 8 Copyright (C) 2008 Peter Johansson8 Copyright (C) 2008, 2009 Peter Johansson 9 9 10 10 This file is part of the yat library, http://dev.thep.lu.se/yat … … 127 127 128 128 /** 129 \brief has the commandline been parsed already 130 131 \return true if parse function has already been called 132 133 \since New in yat 0.5 134 */ 135 bool parsed(void) const; 136 137 /** 129 138 @return Name of more; more specifically argv[0] is 130 139 stripped so only string after the last '/' remains. … … 151 160 std::map<char, Option*> short_options_; 152 161 std::map<std::string, Option*> long_options_; 162 bool parsed_; 153 163 std::string program_name_; 154 164 }; -
trunk/yat/utility/Option.cc
r1487 r1741 3 3 /* 4 4 Copyright (C) 2007 Jari Häkkinen, Peter Johansson 5 Copyright (C) 2008 Peter Johansson5 Copyright (C) 2008, 2009 Peter Johansson 6 6 7 7 This file is part of the yat library, http://dev.thep.lu.se/yat … … 88 88 bool Option::present(void) const 89 89 { 90 if (!cmd().parsed()) { 91 std::string s("Option::present called before Commandline was parsed"); 92 throw std::logic_error(s); 93 } 90 94 return present_; 91 95 } -
trunk/yat/utility/OptionArg.h
r1632 r1741 6 6 /* 7 7 Copyright (C) 2007 Jari Häkkinen, Peter Johansson 8 Copyright (C) 2008 Peter Johansson8 Copyright (C) 2008, 2009 Peter Johansson 9 9 10 10 This file is part of the yat library, http://dev.thep.lu.se/yat … … 29 29 #include "utility.h" 30 30 31 #include <stdexcept> 31 32 #include <string> 32 33 #include <sstream> … … 75 76 \return value 76 77 */ 77 T value(void) const { return value_; } 78 T value(void) const 79 { 80 if (!cmd().parsed()) { 81 std::string s("OptionArg::value called before Commandline was parsed"); 82 throw std::logic_error(s); 83 } 84 return value_; 85 } 78 86 79 87 /**
Note: See TracChangeset
for help on using the changeset viewer.