- Timestamp:
- Jun 30, 2009, 5:57:27 AM (14 years ago)
- Location:
- trunk/lib
- Files:
-
- 5 added
- 5 edited
- 12 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Makefile.am
r768 r795 24 24 # along with svndigest. If not, see <http://www.gnu.org/licenses/>. 25 25 26 SUBDIRS = yat . 27 26 28 AM_CPPFLAGS = $(SVNDIGEST_CPPFLAGS) 27 29 AM_CXXFLAGS = $(SVNDIGEST_CXXFLAGS) … … 29 31 noinst_LIBRARIES = libsvndigest.a 30 32 31 noinst_HEADERS = AddStats.h Alias.h BlameStats.h ClassicStats.h ColumnStream.h\32 Comm andLine.h Commitment.h Configuration.h copyright_year.h css.h\33 Date.h Directory.h Exception.hFile.h first_page.h Functor.h \33 noinst_HEADERS = AddStats.h Alias.h BlameStats.h ClassicStats.h \ 34 Commitment.h Configuration.h copyright_year.h css.h\ 35 Date.h Directory.h File.h first_page.h Functor.h \ 34 36 Gnuplot.h GnuplotFE.h \ 35 37 HtmlBuf.h HtmlStream.h html_utility.h LineTypeParser.h \ 36 Node.h Option.h OptionArg.h OptionHelp.h OptionSwitch.h \38 Node.h 37 39 OptionVersion.h rmdirhier.h \ 38 40 Stats.h StatsCollection.h subversion_info.h SVN.h SVNblame.h \ … … 40 42 41 43 libsvndigest_a_SOURCES = AddStats.cc Alias.cc BlameStats.cc \ 42 ClassicStats.cc ColumnStream.cc\43 Comm andLine.cc Commitment.cc Configuration.cc copyright_year.cc \44 ClassicStats.cc \ 45 Commitment.cc Configuration.cc copyright_year.cc \ 44 46 css.cc Date.cc Directory.cc File.cc first_page.cc\ 45 47 Functor.cc Gnuplot.cc GnuplotFE.cc HtmlBuf.cc HtmlStream.cc \ 46 48 html_utility.cc LineTypeParser.cc Node.cc \ 47 Option .cc OptionHelp.cc OptionSwitch.cc OptionVersion.cc \49 OptionVersion.cc \ 48 50 rmdirhier.cc Stats.cc StatsCollection.cc subversion_info.cc SVN.cc \ 49 51 SVNblame.cc SVNinfo.cc SVNlog.cc SVNproperty.cc Trac.cc utility.cc -
trunk/lib/OptionVersion.cc
r791 r795 24 24 #include "copyright_year.h" 25 25 #include "OptionVersion.h" 26 #include "ColumnStream.h"27 #include "CommandLine.h"28 26 #include "subversion_info.h" 29 27 #include "utility.h" 28 29 #include "yat/ColumnStream.h" 30 #include "yat/CommandLine.h" 30 31 31 32 #include <subversion-1/svn_version.h> … … 39 40 namespace svndigest { 40 41 41 OptionVersion::OptionVersion( CommandLine& cmd, std::string flag,42 OptionVersion::OptionVersion(yat::utility::CommandLine& cmd, std::string flag, 42 43 std::string desc, OptionSwitch* const verbose) 43 : OptionSwitch(cmd, flag, desc, false), verbose_(verbose)44 : yat::utility::OptionSwitch(cmd, flag, desc, false), verbose_(verbose) 44 45 { 45 46 } … … 49 50 std::vector<std::string>::iterator last) 50 51 { 51 ColumnStream cs(std::cout, 1);52 yat::utility::ColumnStream cs(std::cout, 1); 52 53 cs.width(0)=79; 53 54 cs << PACKAGE_NAME << " " << PACKAGE_VERSION; -
trunk/lib/OptionVersion.h
r724 r795 25 25 */ 26 26 27 #include " OptionSwitch.h"27 #include "yat/OptionSwitch.h" 28 28 29 29 #include <string> 30 30 31 31 namespace theplu { 32 namespace yat { 33 namespace utility { 34 class CommandLine; 35 }} 32 36 namespace svndigest { 33 37 34 class CommandLine;35 38 /** 36 39 \brief Class for version option … … 39 42 version output. 40 43 */ 41 class OptionVersion : public OptionSwitch44 class OptionVersion : public yat::utility::OptionSwitch 42 45 { 43 46 public: … … 50 53 \param desc string used in help display 51 54 */ 52 OptionVersion( CommandLine& cmd, std::string name="version",55 OptionVersion(yat::utility::CommandLine& cmd, std::string name="version", 53 56 std::string desc="print version information and exit", 54 57 OptionSwitch* const verbose=NULL); -
trunk/lib/utility.cc
r768 r795 167 167 168 168 169 bool is_int(std::string s)170 {171 std::stringstream ss(s);172 int a;173 ss >> a;174 if(ss.fail())175 return false;176 // Check that nothing is left on stream177 std::string b;178 ss >> b;179 return b.empty();180 }181 182 183 169 std::string ltrim(std::string str) 184 170 { -
trunk/lib/utility.h
r768 r795 61 61 62 62 /** 63 \brief convert string to (numerical) type64 65 \throw runtime_error if conversion fails66 */67 template<typename T>68 T convert(const std::string& s);69 70 /**71 63 @brief Copy file \a source to \a target. 72 64 … … 118 110 /// 119 111 std::string htrim(std::string str); 120 121 /**122 @return true if string \a s fulfills regular expression \verbatim123 ^\w* \endverbatim \a other \verbatim \w*$ \endverbatim (case124 insensitive)125 */126 bool is_equal(std::string s, std::string other);127 128 ///129 /// @return true if \a str is an integer130 ///131 bool is_int(std::string str);132 133 ///134 /// @return true if string is "nan" (case-insensitive)135 ///136 bool is_nan(const std::string& s);137 112 138 113 /// … … 244 219 std::string); 245 220 246 // template implementations247 template<typename T>248 T convert(const std::string& s)249 {250 if (is_nan(s))251 return std::numeric_limits<T>::quiet_NaN();252 if (is_equal(s, "inf"))253 return std::numeric_limits<T>::infinity();254 if (is_equal(s, "-inf")) {255 if (std::numeric_limits<T>::is_signed)256 return -std::numeric_limits<T>::infinity();257 else258 throw std::runtime_error(std::string("convert(\"")+s+259 std::string("\"): type is unsigned") );260 }261 262 std::stringstream ss(s);263 T a;264 ss >> a;265 bool ok = true;266 if(ss.fail())267 ok = false;268 // Check that nothing is left on stream269 std::string b;270 ss >> b;271 if (!b.empty() || !ok)272 throw std::runtime_error(std::string("convert(\"")+s+std::string("\")"));273 return a;274 }275 276 221 }} // end of namespace svndigest end of namespace theplu 277 222 -
trunk/lib/yat/ColumnStream.cc
- Property svn:keywords deleted
r792 r795 1 // $Id $1 // $Id: ColumnStream.cc 1797 2009-02-12 18:07:10Z peter $ 2 2 3 3 /* 4 Copyright (C) 2007, 2008 Peter Johansson4 Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson 5 5 6 6 This file is part of svndigest, http://dev.thep.lu.se/svndigest … … 17 17 18 18 You should have received a copy of the GNU General Public License 19 along with svndigest. If not, see <http://www.gnu.org/licenses/>.19 along with yat. If not, see <http://www.gnu.org/licenses/>. 20 20 */ 21 21 … … 26 26 27 27 namespace theplu{ 28 namespace svndigest{ 28 namespace yat{ 29 namespace utility{ 29 30 30 31 ColumnStream::ColumnStream(std::ostream& os, size_t columns) … … 70 71 } 71 72 73 74 size_t& ColumnStream::margin(size_t c) 75 { 76 return margins_[c]; 77 } 78 79 72 80 void ColumnStream::next_column(void) 73 81 { … … 98 106 ss.get(c); 99 107 } 108 } 109 110 111 size_t& ColumnStream::width(size_t c) 112 { 113 return width_[c]; 100 114 } 101 115 … … 149 163 150 164 151 }} // end of namespace svndigest and namespacetheplu165 }}} // end of namespace utility, yat, and theplu -
trunk/lib/yat/ColumnStream.h
- Property svn:keywords deleted
r792 r795 1 #ifndef _theplu_ svndigest_column_stream_2 #define _theplu_ svndigest_column_stream_1 #ifndef _theplu_yat__utility_column_stream_ 2 #define _theplu_yat__utility_column_stream_ 3 3 4 // $Id $4 // $Id: ColumnStream.h 1887 2009-03-31 17:38:16Z peter $ 5 5 6 6 /* 7 Copyright (C) 2007, 2008 Peter Johansson8 Copyright (C) 200 8 Jari Häkkinen7 Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson 8 Copyright (C) 2009 Peter Johansson 9 9 10 10 This file is part of svndigest, http://dev.thep.lu.se/svndigest … … 21 21 22 22 You should have received a copy of the GNU General Public License 23 along with svndigest. If not, see <http://www.gnu.org/licenses/>.23 along with yat. If not, see <http://www.gnu.org/licenses/>. 24 24 */ 25 26 #include <ios fwd>25 #include <fstream> 26 #include <iostream> 27 27 #include <sstream> 28 28 #include <vector> 29 29 30 namespace theplu{ 31 namespace svndigest{ 30 namespace theplu { 31 namespace yat { 32 namespace utility { 32 33 33 34 /// … … 53 54 void flush(void); 54 55 55 inline size_t& margin(size_t c) { return margins_[c]; } 56 /** 57 \return reference to margin of column \a c 58 */ 59 size_t& margin(size_t c); 56 60 61 /** 62 \brief jump to next column 63 */ 57 64 void next_column(void); 58 65 … … 67 74 void set_column(size_t); 68 75 69 inline size_t& width(size_t c) { return width_[c]; } 76 /** 77 \return reference to width of column \a c 78 */ 79 size_t& width(size_t c); 70 80 71 81 private: … … 88 98 89 99 100 /** 101 \brief ColumnStream output operator 102 103 Requirement: T should have operator 104 operator<<(ostream&, const T&) 105 106 \relates ColumnStream 107 */ 90 108 template <typename T> 91 109 ColumnStream& operator<<(ColumnStream& s, const T& rhs) … … 97 115 } 98 116 99 }} // end of namespace svndigest and namespacetheplu117 }}} // end of namespace utility, yat, theplu 100 118 101 119 #endif -
trunk/lib/yat/CommandLine.cc
- Property svn:keywords deleted
r792 r795 1 // $Id $1 // $Id: CommandLine.cc 1874 2009-03-17 22:09:01Z peter $ 2 2 3 3 /* 4 4 Copyright (C) 2007 Jari Häkkinen, Peter Johansson, Markus Ringnér 5 Copyright (C) 2008 Peter Johansson 6 7 This file is part of svndigest, http://dev.thep.lu.se/svndigest 8 9 svndigest is free software; you can redistribute it and/or modify it 10 under the terms of the GNU General Public License as published by 11 the Free Software Foundation; either version 3 of the License, or 12 (at your option) any later version. 13 14 svndigest is distributed in the hope that it will be useful, but 15 WITHOUT ANY WARRANTY; without even the implied warranty of 5 Copyright (C) 2008 Jari Häkkinen, Peter Johansson 6 Copyright (C) 2009 Peter Johansson 7 8 This file is part of the yat library, http://dev.thep.lu.se/yat 9 10 The yat library is free software; you can redistribute it and/or 11 modify it under the terms of the GNU General Public License as 12 published by the Free Software Foundation; either version 3 of the 13 License, or (at your option) any later version. 14 15 The yat library is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 18 General Public License for more details. 18 19 19 20 You should have received a copy of the GNU General Public License 20 along with svndigest. If not, see <http://www.gnu.org/licenses/>.21 along with yat. If not, see <http://www.gnu.org/licenses/>. 21 22 */ 22 23 … … 39 40 40 41 namespace theplu { 41 namespace svndigest { 42 namespace yat { 43 namespace utility { 42 44 43 45 CommandLine::CommandLine(std::string str) 44 : description_(str), free_arg_max_(0) 46 : description_(str), free_arg_max_(0), parsed_(false) 45 47 {} 46 48 … … 56 58 if (long_options_.find(option.long_name())!=long_options_.end()) { 57 59 std::stringstream ss; 58 ss << " Commandline: two options with long_name: "60 ss << "yat::utility::Commandline: two options with long_name: " 59 61 << option.long_name(); 60 62 throw std::runtime_error(ss.str()); … … 65 67 if (short_options_.find(option.short_name())!=short_options_.end()) { 66 68 std::stringstream ss; 67 ss << " Commandline: two options with short_name: "69 ss << "yat::utility::Commandline: two options with short_name: " 68 70 << option.short_name(); 69 71 throw std::runtime_error(ss.str()); … … 102 104 void CommandLine::parse(int argc, char* argv[]) 103 105 { 106 parsed_=true; 104 107 using namespace std; 105 108 // just in case it is not pristine … … 119 122 if (is_long_option(*arg)) { 120 123 std::string key(arg->substr(2)); 121 std::stringstream ss (key);122 getline(ss , key, '=');124 std::stringstream ss2(key); 125 getline(ss2, key, '='); 123 126 std::string value; 124 getline(ss , value, '\0');127 getline(ss2, value, '\0'); 125 128 if (!value.empty()){ 126 129 *arg = value; … … 139 142 } 140 143 else if (iter==long_options_.end()) { 141 s s.str("");142 ss << ": unrecognized option `" << key << "'\n" << try_help();143 throw cmd_error(ss .str());144 std::stringstream ss3; 145 ss3 << ": unrecognized option `" << key << "'\n" << try_help(); 146 throw cmd_error(ss3.str()); 144 147 } 145 148 } … … 150 153 iter(short_options_.find((*arg)[i])); 151 154 if (iter==short_options_.end()) { 152 std::stringstream ss ;153 ss << ": invalid option -- " << (*arg)[i] << "\n"154 155 throw cmd_error(ss .str());155 std::stringstream ss2; 156 ss2 << ": invalid option -- " << (*arg)[i] << "\n" 157 << try_help() << "\n"; 158 throw cmd_error(ss2.str()); 156 159 } 157 160 else … … 162 165 free_arg_.push_back(*arg); 163 166 if (free_arg_.size()>free_arg_max_) { 164 std::stringstream ss ;165 ss << ": invalid option -- " << *arg << "\n"166 167 throw cmd_error(ss .str());167 std::stringstream ss2; 168 ss2 << ": invalid option -- " << *arg << "\n" 169 << try_help() << "\n"; 170 throw cmd_error(ss2.str()); 168 171 } 169 172 } … … 173 176 } 174 177 catch (cmd_error& e){ 175 std::stringstream ss ;176 ss << program_name_ << ": " << e.what();177 throw cmd_error(ss .str());178 std::stringstream ss2; 179 ss2 << program_name_ << ": " << e.what(); 180 throw cmd_error(ss2.str()); 178 181 } 179 182 183 } 184 185 186 bool CommandLine::parsed(void) const 187 { 188 return parsed_; 180 189 } 181 190 … … 227 236 228 237 229 }} // of namespace svndigestand theplu238 }}} // of namespace utility, yat, and theplu -
trunk/lib/yat/CommandLine.h
- Property svn:keywords deleted
r792 r795 1 #ifndef _theplu_ svndigest_commandline_2 #define _theplu_ svndigest_commandline_1 #ifndef _theplu_yat_utility_commandline_ 2 #define _theplu_yat_utility_commandline_ 3 3 4 //$Id $4 //$Id: CommandLine.h 1954 2009-05-07 15:30:58Z jari $ 5 5 6 6 /* 7 Copyright (C) 2007 Jari Häkkinen, Peter Johansson8 Copyright (C) 200 8Peter Johansson7 Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson 8 Copyright (C) 2009 Peter Johansson 9 9 10 This file is part of svndigest, http://dev.thep.lu.se/svndigest10 This file is part of the yat library, http://dev.thep.lu.se/yat 11 11 12 svndigest is free software; you can redistribute it and/or modify it13 under the terms of the GNU General Public License as published by14 the Free Software Foundation; either version 3 of the License, or15 (at your option) any later version.12 The yat library is free software; you can redistribute it and/or 13 modify it under the terms of the GNU General Public License as 14 published by the Free Software Foundation; either version 3 of the 15 License, or (at your option) any later version. 16 16 17 svndigest is distributed in the hope that it will be useful, but18 WITHOUT ANY WARRANTY; without even the implied warranty of17 The yat library is distributed in the hope that it will be useful, 18 but WITHOUT ANY WARRANTY; without even the implied warranty of 19 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 20 General Public License for more details. 21 21 22 22 You should have received a copy of the GNU General Public License 23 along with svndigest. If not, see <http://www.gnu.org/licenses/>.23 along with yat. If not, see <http://www.gnu.org/licenses/>. 24 24 */ 25 25 … … 35 35 36 36 namespace theplu { 37 namespace svndigest { 37 namespace yat { 38 namespace utility { 38 39 39 40 class Option; … … 50 51 51 52 CommandLine cmd; 52 OptionArg<std::string> dir(cmd, "d,dir", "output directory");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 57 OptionSwitch target(cmd, "T,target", "treat DEST as a normal file", true); 55 58 OptionSwitch verbose(cmd, "v,verbose", "explain what is being done"); 56 59 OptionSwitch version(cmd, "version", "output version and exit"); 60 std::stringstream copyright; 61 copyright << "example 1.0\n" 62 << "Copyright (C) 2007 Peter Johansson\n\n" 63 << "This is free software see the source for copying " 64 << "conditions. There is NO\nwarranty; not even for " 65 << "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"; 57 66 try { 58 67 cmd.parse(argc, argv); … … 60 69 catch (cmd_error& e){ 61 70 if (version.present()){ 62 std::cout << cmd.program_name() << " 1.0\n" 63 << "Copyright (C) 2007 Peter Johansson\n\n" 64 << "This is free software see the source for copying " 65 << "conditions. There is NO\nwarranty; not even for " 66 << "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"; 67 exit(0); 71 std::cout << copyright.str(); 72 return EXIT_SUCCESS; 68 73 } 69 std::c out<< e.what() << std::endl;70 return 1;74 std::cerr << e.what() << std::endl; 75 return EXIT_FAILURE; 71 76 } 77 if (version.present()){ 78 std::cout << copyright.str(); 79 return EXIT_SUCCESS; 80 } 72 81 ... 73 82 \endcode … … 126 135 127 136 /** 137 \brief has the commandline been parsed already 138 139 \return true if parse function has already been called 140 141 \since New in yat 0.5 142 */ 143 bool parsed(void) const; 144 145 /** 128 146 @return Name of more; more specifically argv[0] is 129 147 stripped so only string after the last '/' remains. … … 150 168 std::map<char, Option*> short_options_; 151 169 std::map<std::string, Option*> long_options_; 170 bool parsed_; 152 171 std::string program_name_; 153 172 }; … … 168 187 Option::print(void) function. 169 188 \see OptionHelp 189 190 \relates CommandLine 170 191 */ 171 192 std::ostream& operator<<(std::ostream&, const CommandLine&); 172 193 173 }} // end of namespace svndigestand theplu194 }}} // end of namespace utility, yat, and theplu 174 195 175 196 #endif -
trunk/lib/yat/Exception.h
- Property svn:keywords deleted
r792 r795 1 #ifndef _theplu_ svndigest_exception_2 #define _theplu_ svndigest_exception_1 #ifndef _theplu_yat_utility_exception_ 2 #define _theplu_yat_utility_exception_ 3 3 4 // $Id $4 // $Id: Exception.h 1797 2009-02-12 18:07:10Z peter $ 5 5 6 6 /* 7 Copyright (C) 200 8Peter Johansson7 Copyright (C) 2005, 2006, 2007, 2008 Jari Häkkinen, Peter Johansson 8 8 9 This file is part of svndigest, http://trac.thep.lu.se/svndigest9 This file is part of the yat library, http://dev.thep.lu.se/yat 10 10 11 svndigest is free software; you can redistribute it and/or modify it12 under the terms of the GNU General Public License as published by13 the Free Software Foundation; either version 2 of the License, or14 (at your option) any later version.11 The yat library is free software; you can redistribute it and/or 12 modify it under the terms of the GNU General Public License as 13 published by the Free Software Foundation; either version 3 of the 14 License, or (at your option) any later version. 15 15 16 svndigest is distributed in the hope that it will be useful, but17 WITHOUT ANY WARRANTY; without even the implied warranty of16 The yat library is distributed in the hope that it will be useful, 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 19 General Public License for more details. 20 20 21 21 You should have received a copy of the GNU General Public License 22 along with this program; if not, write to the Free Software 23 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 24 02111-1307, USA. 22 along with yat. If not, see <http://www.gnu.org/licenses/>. 25 23 */ 26 24 … … 29 27 30 28 namespace theplu { 31 namespace svndigest { 29 namespace yat { 30 namespace utility { 32 31 33 32 /** … … 63 62 }; 64 63 65 }} // of namespace svndigestand theplu64 }}} // of namespace utility, yat, and theplu 66 65 67 66 #endif -
trunk/lib/yat/Option.cc
- Property svn:keywords deleted
r792 r795 1 // $Id $1 // $Id: Option.cc 1797 2009-02-12 18:07:10Z peter $ 2 2 3 3 /* 4 Copyright (C) 2007 Jari Häkkinen, Peter Johansson5 Copyright (C) 200 8Peter Johansson4 Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson 5 Copyright (C) 2009 Peter Johansson 6 6 7 This file is part of svndigest, http://dev.thep.lu.se/svndigest7 This file is part of the yat library, http://dev.thep.lu.se/yat 8 8 9 svndigest is free software; you can redistribute it and/or modify it10 under the terms of the GNU General Public License as published by11 the Free Software Foundation; either version 3 of the License, or12 (at your option) any later version.9 The yat library is free software; you can redistribute it and/or 10 modify it under the terms of the GNU General Public License as 11 published by the Free Software Foundation; either version 3 of the 12 License, or (at your option) any later version. 13 13 14 svndigest is distributed in the hope that it will be useful, but15 WITHOUT ANY WARRANTY; without even the implied warranty of14 The yat library is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 17 General Public License for more details. 18 18 19 19 You should have received a copy of the GNU General Public License 20 along with svndigest. If not, see <http://www.gnu.org/licenses/>.20 along with yat. If not, see <http://www.gnu.org/licenses/>. 21 21 */ 22 22 … … 30 30 31 31 namespace theplu { 32 namespace svndigest { 32 namespace yat { 33 namespace utility { 34 33 35 34 36 Option::Option(CommandLine& cmd, std::string flag, std::string desc) … … 36 38 { 37 39 if (flag.empty()) 38 throw std::runtime_error(" svndigest: Option: given flag is empty");40 throw std::runtime_error("yat: Option: given flag is empty"); 39 41 if (flag.size()==1 || (flag.size()==2 && flag[1]==',')) 40 42 short_name_ = flag[0]; … … 86 88 bool Option::present(void) const 87 89 { 90 if (!cmd().parsed()) { 91 std::string s("Option::present called before Commandline was parsed"); 92 throw std::logic_error(s); 93 } 88 94 return present_; 89 95 } … … 147 153 } 148 154 149 }} // of namespace svndigestand theplu155 }}} // of namespace utility, yat, and theplu -
trunk/lib/yat/Option.h
- Property svn:keywords deleted
r792 r795 1 #ifndef _theplu_ svndigest_option_2 #define _theplu_ svndigest_option_1 #ifndef _theplu_yat_utility_option_ 2 #define _theplu_yat_utility_option_ 3 3 4 // $Id $4 // $Id: Option.h 1797 2009-02-12 18:07:10Z peter $ 5 5 6 6 /* 7 Copyright (C) 2007 Jari Häkkinen, Peter Johansson 8 Copyright (C) 2008 Peter Johansson 7 Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson 9 8 10 This file is part of svndigest, http://dev.thep.lu.se/svndigest9 This file is part of the yat library, http://dev.thep.lu.se/yat 11 10 12 svndigest is free software; you can redistribute it and/or modify it13 under the terms of the GNU General Public License as published by14 the Free Software Foundation; either version 3 of the License, or15 (at your option) any later version.11 The yat library is free software; you can redistribute it and/or 12 modify it under the terms of the GNU General Public License as 13 published by the Free Software Foundation; either version 3 of the 14 License, or (at your option) any later version. 16 15 17 svndigest is distributed in the hope that it will be useful, but18 WITHOUT ANY WARRANTY; without even the implied warranty of16 The yat library is distributed in the hope that it will be useful, 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 19 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 19 General Public License for more details. 21 20 22 21 You should have received a copy of the GNU General Public License 23 along with svndigest. If not, see <http://www.gnu.org/licenses/>.22 along with yat. If not, see <http://www.gnu.org/licenses/>. 24 23 */ 25 24 … … 29 28 30 29 namespace theplu { 31 namespace svndigest { 30 namespace yat { 31 namespace utility { 32 32 33 33 class CommandLine; … … 150 150 }; 151 151 152 }} // of namespace svndigest, and theplu152 }}} // of namespace utility, yat, and theplu 153 153 154 154 #endif -
trunk/lib/yat/OptionArg.h
- Property svn:keywords deleted
r792 r795 1 #ifndef _theplu_ svndigest_option_arg_2 #define _theplu_ svndigest_option_arg_1 #ifndef _theplu_yat_utility_option_arg_ 2 #define _theplu_yat_utility_option_arg_ 3 3 4 // $Id $4 // $Id: OptionArg.h 1797 2009-02-12 18:07:10Z peter $ 5 5 6 6 /* 7 Copyright (C) 2007 Jari Häkkinen, Peter Johansson8 Copyright (C) 200 8Peter Johansson7 Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson 8 Copyright (C) 2009 Peter Johansson 9 9 10 This file is part of svndigest, http://dev.thep.lu.se/svndigest10 This file is part of the yat library, http://dev.thep.lu.se/yat 11 11 12 svndigest is free software; you can redistribute it and/or modify it13 under the terms of the GNU General Public License as published by14 the Free Software Foundation; either version 3 of the License, or15 (at your option) any later version.12 The yat library is free software; you can redistribute it and/or 13 modify it under the terms of the GNU General Public License as 14 published by the Free Software Foundation; either version 3 of the 15 License, or (at your option) any later version. 16 16 17 svndigest is distributed in the hope that it will be useful, but18 WITHOUT ANY WARRANTY; without even the implied warranty of17 The yat library is distributed in the hope that it will be useful, 18 but WITHOUT ANY WARRANTY; without even the implied warranty of 19 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 20 General Public License for more details. 21 21 22 22 You should have received a copy of the GNU General Public License 23 along with svndigest. If not, see <http://www.gnu.org/licenses/>.23 along with yat. If not, see <http://www.gnu.org/licenses/>. 24 24 */ 25 25 … … 29 29 #include "utility.h" 30 30 31 #include <stdexcept> 31 32 #include <string> 32 33 #include <sstream> 33 34 34 35 namespace theplu { 35 namespace svndigest { 36 namespace yat { 37 namespace utility { 36 38 37 39 class CommandLine; … … 64 66 65 67 /** 66 \param arg string to be used in help output such as \verbatim 67 `=TARGET' \endverbatim in \verbatim `--target=TARGET' 68 \endvarbatim. See print3(). 68 \param arg string to be used in help output such as `=TARGET' 69 in `--target=TARGET'. See print3(). 70 71 \since New in yat 0.5. 69 72 */ 70 73 void print_arg(std::string arg) { print_arg_ = arg; } … … 73 76 \return value 74 77 */ 75 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 } 76 86 77 87 /** 78 88 \brief set value 89 90 \since new in yat 0.5 79 91 */ 80 92 void value(T v) { value_ = v; } … … 167 179 }; 168 180 169 }} // of namespace svndigestand theplu181 }}} // of namespace utility, yat, and theplu 170 182 171 183 #endif -
trunk/lib/yat/OptionHelp.cc
- Property svn:keywords deleted
r792 r795 1 // $Id $1 // $Id: OptionHelp.cc 1797 2009-02-12 18:07:10Z peter $ 2 2 3 3 /* 4 Copyright (C) 2007 Jari Häkkinen, Peter Johansson 5 Copyright (C) 2008 Jari Häkkinen 4 Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson 6 5 7 This file is part of svndigest, http://dev.thep.lu.se/svndigest6 This file is part of the yat library, http://dev.thep.lu.se/yat 8 7 9 svndigestis free software; you can redistribute it and/or8 The yat library is free software; you can redistribute it and/or 10 9 modify it under the terms of the GNU General Public License as 11 10 published by the Free Software Foundation; either version 3 of the 12 11 License, or (at your option) any later version. 13 12 14 svndigestis distributed in the hope that it will be useful,13 The yat library is distributed in the hope that it will be useful, 15 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU … … 18 17 19 18 You should have received a copy of the GNU General Public License 20 along with svndigest. If not, see <http://www.gnu.org/licenses/>.19 along with yat. If not, see <http://www.gnu.org/licenses/>. 21 20 */ 22 21 … … 24 23 #include "CommandLine.h" 25 24 26 #include <cstdlib>27 25 #include <sstream> 28 26 #include <string> 29 27 30 28 namespace theplu { 31 namespace svndigest { 29 namespace yat { 30 namespace utility { 31 32 32 33 33 OptionHelp::OptionHelp(CommandLine& cmd, std::string flag, … … 68 68 } 69 69 70 }} // of namespace svndigestand theplu70 }}} // of namespace utility, yat, and theplu -
trunk/lib/yat/OptionHelp.h
- Property svn:keywords deleted
r792 r795 1 #ifndef _theplu_ svndigest_option_help_2 #define _theplu_ svndigest_option_help_1 #ifndef _theplu_yat_utility_option_help_ 2 #define _theplu_yat_utility_option_help_ 3 3 4 // $Id $4 // $Id: OptionHelp.h 1797 2009-02-12 18:07:10Z peter $ 5 5 6 6 /* 7 Copyright (C) 200 8Peter Johansson7 Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson 8 8 9 This file is part of svndigest, http://trac.thep.lu.se/svndigest9 This file is part of the yat library, http://dev.thep.lu.se/yat 10 10 11 svndigest is free software; you can redistribute it and/or modify it12 under the terms of the GNU General Public License as published by13 the Free Software Foundation; either version 2 of the License, or14 (at your option) any later version.11 The yat library is free software; you can redistribute it and/or 12 modify it under the terms of the GNU General Public License as 13 published by the Free Software Foundation; either version 3 of the 14 License, or (at your option) any later version. 15 15 16 svndigest is distributed in the hope that it will be useful, but17 WITHOUT ANY WARRANTY; without even the implied warranty of16 The yat library is distributed in the hope that it will be useful, 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 19 General Public License for more details. 20 20 21 21 You should have received a copy of the GNU General Public License 22 along with this program; if not, write to the Free Software 23 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 24 02111-1307, USA. 22 along with yat. If not, see <http://www.gnu.org/licenses/>. 25 23 */ 26 24 … … 30 28 31 29 namespace theplu { 32 namespace svndigest { 30 namespace yat { 31 namespace utility { 33 32 34 33 class CommandLine; … … 37 36 38 37 When this option is found in parsing of commandline, it displays 39 a help output exits. 38 a help output and exits. A typical output looks like: 39 40 \verbatim 41 Usage: foo [OPTION]... 42 43 SYNOPSIS 44 45 Available options are: 46 -h, --help display this help and exit 47 -v, --verbose explain what is being done 48 49 Some extra information explaining something. 50 \endverbatim 51 52 The output consist of four blocks. The first block can be 53 modified with usage(void) function. The second is block is 54 typically a one-liner explaining the application and can be 55 modified with the synopsis(void) function. The third block 56 contain the description of the different options, see 57 operator<<(std::ostream&, const CommandLine&) for further 58 details. The last block can be modified with post_arguments(void) 59 function. 40 60 */ 41 61 class OptionHelp : public OptionSwitch … … 81 101 }; 82 102 83 }} // of namespace svndigestand theplu103 }}} // of namespace utility, yat, and theplu 84 104 85 105 #endif -
trunk/lib/yat/OptionSwitch.cc
- Property svn:keywords deleted
r792 r795 1 // $Id $1 // $Id: OptionSwitch.cc 1797 2009-02-12 18:07:10Z peter $ 2 2 3 3 /* 4 Copyright (C) 2007 Jari Häkkinen, Peter Johansson4 Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson 5 5 6 This file is part of svndigest, http://dev.thep.lu.se/svndigest6 This file is part of the yat library, http://dev.thep.lu.se/yat 7 7 8 svndigest is free software; you can redistribute it and/or modify it9 under the terms of the GNU General Public License as published by10 the Free Software Foundation; either version 3 of the License, or11 (at your option) any later version.8 The yat library is free software; you can redistribute it and/or 9 modify it under the terms of the GNU General Public License as 10 published by the Free Software Foundation; either version 3 of the 11 License, or (at your option) any later version. 12 12 13 svndigest is distributed in the hope that it will be useful, but14 WITHOUT ANY WARRANTY; without even the implied warranty of13 The yat library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 16 General Public License for more details. 17 17 18 18 You should have received a copy of the GNU General Public License 19 along with svndigest. If not, see <http://www.gnu.org/licenses/>.19 along with yat. If not, see <http://www.gnu.org/licenses/>. 20 20 */ 21 21 … … 26 26 27 27 namespace theplu { 28 namespace svndigest { 28 namespace yat { 29 namespace utility { 30 29 31 30 32 OptionSwitch::OptionSwitch(CommandLine& cmd, std::string flag, … … 76 78 77 79 78 }} // of namespace svndigestand theplu80 }}} // of namespace utility, yat, and theplu -
trunk/lib/yat/OptionSwitch.h
- Property svn:keywords deleted
r792 r795 1 #ifndef _theplu_ svndigest_option_switch_2 #define _theplu_ svndigest_option_switch_1 #ifndef _theplu_yat_utility_option_switch_ 2 #define _theplu_yat_utility_option_switch_ 3 3 4 // $Id $4 // $Id: OptionSwitch.h 1797 2009-02-12 18:07:10Z peter $ 5 5 6 6 /* 7 Copyright (C) 2007 Jari Häkkinen, Peter Johansson7 Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson 8 8 9 This file is part of svndigest, http://dev.thep.lu.se/svndigest9 This file is part of the yat library, http://dev.thep.lu.se/yat 10 10 11 svndigest is free software; you can redistribute it and/or modify it12 under the terms of the GNU General Public License as published by13 the Free Software Foundation; either version 3 of the License, or14 (at your option) any later version.11 The yat library is free software; you can redistribute it and/or 12 modify it under the terms of the GNU General Public License as 13 published by the Free Software Foundation; either version 3 of the 14 License, or (at your option) any later version. 15 15 16 svndigest is distributed in the hope that it will be useful, but17 WITHOUT ANY WARRANTY; without even the implied warranty of16 The yat library is distributed in the hope that it will be useful, 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 19 General Public License for more details. 20 20 21 21 You should have received a copy of the GNU General Public License 22 along with svndigest. If not, see <http://www.gnu.org/licenses/>.22 along with yat. If not, see <http://www.gnu.org/licenses/>. 23 23 */ 24 24 … … 28 28 29 29 namespace theplu { 30 namespace svndigest { 30 namespace yat { 31 namespace utility { 31 32 32 33 class CommandLine; … … 81 82 }; 82 83 83 }} // of namespace svndigest, and theplu84 }}} // of namespace utility, yat, and theplu 84 85 85 86 #endif
Note: See TracChangeset
for help on using the changeset viewer.