Changeset 795 for trunk/lib


Ignore:
Timestamp:
Jun 30, 2009, 5:57:27 AM (12 years ago)
Author:
Peter Johansson
Message:

refs #388

Create a sub-directory 'lib/yat' in which files from yat are
placed. The files may be updated via 'make fetch', see file README for
more details on how to change which files are updated/copied through
this mechanism.

The reason we do not use subversion's external mechanism is that we
don't want the files to be synchronised with yat automatically. We
want the update to be moderated by some developer.

I chose to fetch files using the svn client rather than wget because
the svn allows us to get an Id string with information from the yat
repository. 'wget' would just download the file as it appears on the
server that is the string is not expanded.

The file 'config_public.h' is created by configure just as in
yat. This implies that automake adds $(top_builddir)/lib/yat to the
include path so unless in a VPATH build $(top_srcdir)/lib/yat is in
the include path. As we have already added $(top_srcdir)/lib to the
include path, and there are both a lib/utility.h and a
lib/yat/utility.h it is not obvious which file is included when having
'include "utility.h"'. For this reason, when being in bin/ and test/
it is needed to include "../lib/utility.h" rather than "utility.h"
when we want to include 'lib/utility.h'.

Location:
trunk/lib
Files:
5 added
5 edited
12 moved

Legend:

Unmodified
Added
Removed
  • trunk/lib/Makefile.am

    r768 r795  
    2424# along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    2525
     26SUBDIRS = yat .
     27
    2628AM_CPPFLAGS = $(SVNDIGEST_CPPFLAGS)
    2729AM_CXXFLAGS = $(SVNDIGEST_CXXFLAGS)
     
    2931noinst_LIBRARIES = libsvndigest.a
    3032
    31 noinst_HEADERS = AddStats.h Alias.h BlameStats.h ClassicStats.h ColumnStream.h \
    32   CommandLine.h Commitment.h Configuration.h copyright_year.h css.h\
    33   Date.h Directory.h Exception.h File.h first_page.h Functor.h \
     33noinst_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 \
    3436  Gnuplot.h GnuplotFE.h \
    3537  HtmlBuf.h HtmlStream.h html_utility.h LineTypeParser.h \
    36   Node.h Option.h OptionArg.h OptionHelp.h OptionSwitch.h \
     38  Node.h
    3739  OptionVersion.h rmdirhier.h \
    3840  Stats.h StatsCollection.h subversion_info.h SVN.h SVNblame.h  \
     
    4042
    4143libsvndigest_a_SOURCES = AddStats.cc Alias.cc BlameStats.cc \
    42   ClassicStats.cc ColumnStream.cc \
    43   CommandLine.cc Commitment.cc Configuration.cc copyright_year.cc \
     44  ClassicStats.cc \
     45  Commitment.cc Configuration.cc copyright_year.cc \
    4446  css.cc Date.cc Directory.cc File.cc first_page.cc\
    4547  Functor.cc Gnuplot.cc GnuplotFE.cc  HtmlBuf.cc HtmlStream.cc \
    4648  html_utility.cc LineTypeParser.cc Node.cc \
    47   Option.cc OptionHelp.cc OptionSwitch.cc OptionVersion.cc \
     49  OptionVersion.cc \
    4850  rmdirhier.cc Stats.cc StatsCollection.cc subversion_info.cc SVN.cc \
    4951  SVNblame.cc SVNinfo.cc SVNlog.cc SVNproperty.cc Trac.cc utility.cc
  • trunk/lib/OptionVersion.cc

    r791 r795  
    2424#include "copyright_year.h"
    2525#include "OptionVersion.h"
    26 #include "ColumnStream.h"
    27 #include "CommandLine.h"
    2826#include "subversion_info.h"
    2927#include "utility.h"
     28
     29#include "yat/ColumnStream.h"
     30#include "yat/CommandLine.h"
    3031
    3132#include <subversion-1/svn_version.h>
     
    3940namespace svndigest {
    4041
    41   OptionVersion::OptionVersion(CommandLine& cmd, std::string flag,
     42  OptionVersion::OptionVersion(yat::utility::CommandLine& cmd, std::string flag,
    4243                               std::string desc, OptionSwitch* const verbose)
    43     : OptionSwitch(cmd, flag, desc, false), verbose_(verbose)
     44    : yat::utility::OptionSwitch(cmd, flag, desc, false), verbose_(verbose)
    4445  {
    4546  }
     
    4950                                std::vector<std::string>::iterator last)
    5051  {
    51     ColumnStream cs(std::cout, 1);
     52    yat::utility::ColumnStream cs(std::cout, 1);
    5253    cs.width(0)=79;
    5354    cs << PACKAGE_NAME << " " << PACKAGE_VERSION;
  • trunk/lib/OptionVersion.h

    r724 r795  
    2525*/
    2626
    27 #include "OptionSwitch.h"
     27#include "yat/OptionSwitch.h"
    2828
    2929#include <string>
    3030
    3131namespace theplu {
     32namespace yat {
     33namespace utility {
     34  class CommandLine;
     35}}
    3236namespace svndigest {
    3337
    34   class CommandLine;
    3538  /**
    3639     \brief Class for version option
     
    3942     version output.
    4043   */
    41   class OptionVersion : public OptionSwitch
     44  class OptionVersion : public yat::utility::OptionSwitch
    4245  {
    4346  public:
     
    5053       \param desc string used in help display
    5154    */
    52     OptionVersion(CommandLine& cmd, std::string name="version",
     55    OptionVersion(yat::utility::CommandLine& cmd, std::string name="version",
    5356                  std::string desc="print version information and exit",
    5457                  OptionSwitch* const verbose=NULL);
  • trunk/lib/utility.cc

    r768 r795  
    167167
    168168
    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 stream
    177     std::string b;
    178     ss >> b;
    179     return b.empty();
    180   }
    181 
    182 
    183169  std::string ltrim(std::string str)
    184170  {
  • trunk/lib/utility.h

    r768 r795  
    6161
    6262  /**
    63      \brief convert string to (numerical) type
    64 
    65      \throw runtime_error if conversion fails
    66    */
    67   template<typename T>
    68   T convert(const std::string& s);
    69 
    70   /**
    7163     @brief Copy file \a source to \a target.
    7264
     
    118110  ///
    119111  std::string htrim(std::string str);
    120 
    121   /**
    122      @return true if string \a s fulfills regular expression \verbatim
    123      ^\w* \endverbatim \a other \verbatim \w*$ \endverbatim (case
    124      insensitive)
    125   */
    126   bool is_equal(std::string s, std::string other);
    127 
    128   ///
    129   /// @return true if \a str is an integer
    130   ///
    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);
    137112
    138113  ///
     
    244219                    std::string);
    245220
    246   // template implementations
    247   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       else
    258         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 stream
    269     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 
    276221}} // end of namespace svndigest end of namespace theplu
    277222
  • 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 $
    22
    33/*
    4   Copyright (C) 2007, 2008 Peter Johansson
     4  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    55
    66  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    1717
    1818  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/>.
    2020*/
    2121
     
    2626
    2727namespace theplu{
    28 namespace svndigest{
     28namespace yat{
     29namespace utility{
    2930
    3031  ColumnStream::ColumnStream(std::ostream& os, size_t columns)
     
    7071  }
    7172
     73
     74  size_t& ColumnStream::margin(size_t c)
     75  {
     76    return margins_[c];
     77  }
     78
     79
    7280  void ColumnStream::next_column(void)
    7381  {
     
    98106    ss.get(c);
    99107    }
     108  }
     109
     110
     111  size_t& ColumnStream::width(size_t c)
     112  {
     113    return width_[c];
    100114  }
    101115
     
    149163
    150164
    151 }} // end of namespace svndigest and namespace theplu
     165}}} // 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_
    33
    4 // $Id$
     4// $Id: ColumnStream.h 1887 2009-03-31 17:38:16Z peter $
    55
    66/*
    7   Copyright (C) 2007, 2008 Peter Johansson
    8   Copyright (C) 2008 Jari Häkkinen
     7  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     8  Copyright (C) 2009 Peter Johansson
    99
    1010  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    2121
    2222  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/>.
    2424*/
    25 
    26 #include <iosfwd>
     25#include <fstream>
     26#include <iostream>
    2727#include <sstream>
    2828#include <vector>
    2929
    30 namespace theplu{
    31 namespace svndigest{
     30namespace theplu {
     31namespace yat {
     32namespace utility {
    3233
    3334  ///
     
    5354    void flush(void);
    5455
    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);
    5660
     61    /**
     62       \brief jump to next column
     63     */
    5764    void next_column(void);
    5865
     
    6774    void set_column(size_t);
    6875
    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);
    7080
    7181  private:
     
    8898
    8999
     100  /**
     101     \brief ColumnStream output operator
     102
     103     Requirement: T should have operator
     104     operator<<(ostream&, const T&)
     105
     106     \relates ColumnStream
     107   */
    90108  template <typename T>
    91109  ColumnStream& operator<<(ColumnStream& s, const T& rhs)
     
    97115  }
    98116
    99 }} // end of namespace svndigest and namespace theplu
     117}}} // end of namespace utility, yat, theplu
    100118
    101119#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 $
    22
    33/*
    44  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
    1617  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    1718  General Public License for more details.
    1819
    1920  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/>.
    2122*/
    2223
     
    3940
    4041namespace theplu {
    41 namespace svndigest {
     42namespace yat {
     43namespace utility {
    4244
    4345  CommandLine::CommandLine(std::string str)
    44     : description_(str), free_arg_max_(0)
     46    : description_(str), free_arg_max_(0), parsed_(false)
    4547  {}
    4648
     
    5658      if (long_options_.find(option.long_name())!=long_options_.end()) {
    5759        std::stringstream ss;
    58         ss << "Commandline: two options with long_name: "
     60        ss << "yat::utility::Commandline: two options with long_name: "
    5961           << option.long_name();
    6062        throw std::runtime_error(ss.str());
     
    6567      if (short_options_.find(option.short_name())!=short_options_.end()) {
    6668        std::stringstream ss;
    67         ss << "Commandline: two options with short_name: "
     69        ss << "yat::utility::Commandline: two options with short_name: "
    6870           << option.short_name();
    6971        throw std::runtime_error(ss.str());
     
    102104  void CommandLine::parse(int argc, char* argv[])
    103105  {   
     106    parsed_=true;
    104107    using namespace std;
    105108    // just in case it is not pristine
     
    119122        if (is_long_option(*arg)) {
    120123          std::string key(arg->substr(2));
    121           std::stringstream ss(key);
    122           getline(ss, key, '=');
     124          std::stringstream ss2(key);
     125          getline(ss2, key, '=');
    123126          std::string value;
    124           getline(ss, value, '\0');
     127          getline(ss2, value, '\0');
    125128          if (!value.empty()){
    126129            *arg = value;
     
    139142          }           
    140143          else if (iter==long_options_.end()) {
    141             ss.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());
    144147          }
    145148        }
     
    150153              iter(short_options_.find((*arg)[i]));
    151154            if (iter==short_options_.end()) {
    152               std::stringstream ss;
    153               ss << ": invalid option -- " << (*arg)[i] << "\n"
    154                  << try_help() << "\n";
    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());
    156159            }       
    157160            else
     
    162165          free_arg_.push_back(*arg);
    163166          if (free_arg_.size()>free_arg_max_) {
    164             std::stringstream ss;
    165             ss << ": invalid option -- " << *arg << "\n"
    166                << try_help() << "\n";
    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());
    168171          }
    169172        }
     
    173176    }
    174177    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());
    178181    }
    179182     
     183  }
     184
     185
     186  bool CommandLine::parsed(void) const
     187  {
     188    return parsed_;
    180189  }
    181190
     
    227236
    228237
    229 }} // of namespace svndigest and theplu
     238}}} // 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_
    33
    4 //$Id$
     4//$Id: CommandLine.h 1954 2009-05-07 15:30:58Z jari $
    55
    66/*
    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
     8  Copyright (C) 2009 Peter Johansson
    99
    10   This file is part of svndigest, http://dev.thep.lu.se/svndigest
     10  This file is part of the yat library, http://dev.thep.lu.se/yat
    1111
    12   svndigest is free software; you can redistribute it and/or modify it
    13   under the terms of the GNU General Public License as published by
    14   the Free Software Foundation; either version 3 of the License, or
    15   (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.
    1616
    17   svndigest is distributed in the hope that it will be useful, but
    18   WITHOUT ANY WARRANTY; without even the implied warranty of
     17  The yat library is distributed in the hope that it will be useful,
     18  but WITHOUT ANY WARRANTY; without even the implied warranty of
    1919  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    2020  General Public License for more details.
    2121
    2222  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/>.
    2424*/
    2525
     
    3535
    3636namespace theplu {
    37 namespace svndigest {
     37namespace yat {
     38namespace utility {
    3839
    3940  class Option;
     
    5051 
    5152     CommandLine cmd;
    52      OptionArg<std::string> dir(cmd, "d,dir", "output directory");
    5353     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");
    5457     OptionSwitch target(cmd, "T,target", "treat DEST as a normal file", true);
    5558     OptionSwitch verbose(cmd, "v,verbose", "explain what is being done");
    5659     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";
    5766     try {
    5867       cmd.parse(argc, argv);
     
    6069     catch (cmd_error& e){
    6170       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;
    6873       }
    69        std::cout << e.what() << std::endl;
    70        return 1;
     74       std::cerr << e.what() << std::endl;
     75       return EXIT_FAILURE;
    7176     } 
     77     if (version.present()){
     78       std::cout << copyright.str();     
     79       return EXIT_SUCCESS;
     80     }
    7281     ...
    7382     \endcode
     
    126135
    127136    /**
     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    /**
    128146       @return Name of more; more specifically argv[0] is
    129147       stripped so only string after the last '/' remains.
     
    150168    std::map<char, Option*> short_options_;
    151169    std::map<std::string, Option*> long_options_;
     170    bool parsed_;
    152171    std::string program_name_;
    153172  };
     
    168187     Option::print(void) function.
    169188     \see OptionHelp
     189
     190     \relates CommandLine
    170191  */
    171192  std::ostream& operator<<(std::ostream&, const CommandLine&);
    172193
    173 }} // end of namespace svndigest and theplu
     194}}} // end of namespace utility, yat, and theplu
    174195
    175196#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_
    33
    4 // $Id$
     4// $Id: Exception.h 1797 2009-02-12 18:07:10Z peter $
    55
    66/*
    7   Copyright (C) 2008 Peter Johansson
     7  Copyright (C) 2005, 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
    88
    9   This file is part of svndigest, http://trac.thep.lu.se/svndigest
     9  This file is part of the yat library, http://dev.thep.lu.se/yat
    1010
    11   svndigest is free software; you can redistribute it and/or modify it
    12   under the terms of the GNU General Public License as published by
    13   the Free Software Foundation; either version 2 of the License, or
    14   (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.
    1515
    16   svndigest is distributed in the hope that it will be useful, but
    17   WITHOUT ANY WARRANTY; without even the implied warranty of
     16  The yat library is distributed in the hope that it will be useful,
     17  but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    1919  General Public License for more details.
    2020
    2121  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/>.
    2523*/
    2624
     
    2927
    3028namespace theplu {
    31 namespace svndigest {
     29namespace yat {
     30namespace utility {
    3231
    3332  /**
     
    6362  };
    6463
    65 }} // of namespace svndigest and theplu
     64}}} // of namespace utility, yat, and theplu
    6665
    6766#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 $
    22
    33/*
    4   Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    5   Copyright (C) 2008 Peter Johansson
     4  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2009 Peter Johansson
    66
    7   This file is part of svndigest, http://dev.thep.lu.se/svndigest
     7  This file is part of the yat library, http://dev.thep.lu.se/yat
    88
    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.
     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.
    1313
    14   svndigest is distributed in the hope that it will be useful, but
    15   WITHOUT ANY WARRANTY; without even the implied warranty of
     14  The yat library is distributed in the hope that it will be useful,
     15  but WITHOUT ANY WARRANTY; without even the implied warranty of
    1616  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    1717  General Public License for more details.
    1818
    1919  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/>.
    2121*/
    2222
     
    3030
    3131namespace theplu {
    32 namespace svndigest {
     32namespace yat {
     33namespace utility {
     34
    3335
    3436  Option::Option(CommandLine& cmd, std::string flag, std::string desc)
     
    3638  {
    3739    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");
    3941    if (flag.size()==1 || (flag.size()==2 && flag[1]==','))
    4042      short_name_ = flag[0];
     
    8688  bool Option::present(void) const
    8789  {
     90    if (!cmd().parsed()) {
     91      std::string s("Option::present called before Commandline was parsed");
     92      throw std::logic_error(s);
     93    }
    8894    return present_;
    8995  }
     
    147153  }
    148154
    149 }} // of namespace svndigest and theplu
     155}}} // 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_
    33
    4 // $Id$
     4// $Id: Option.h 1797 2009-02-12 18:07:10Z peter $
    55
    66/*
    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
    98
    10   This file is part of svndigest, http://dev.thep.lu.se/svndigest
     9  This file is part of the yat library, http://dev.thep.lu.se/yat
    1110
    12   svndigest is free software; you can redistribute it and/or modify it
    13   under the terms of the GNU General Public License as published by
    14   the Free Software Foundation; either version 3 of the License, or
    15   (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.
    1615
    17   svndigest is distributed in the hope that it will be useful, but
    18   WITHOUT ANY WARRANTY; without even the implied warranty of
     16  The yat library is distributed in the hope that it will be useful,
     17  but WITHOUT ANY WARRANTY; without even the implied warranty of
    1918  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    2019  General Public License for more details.
    2120
    2221  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/>.
    2423*/
    2524
     
    2928
    3029namespace theplu {
    31 namespace svndigest {
     30namespace yat {
     31namespace utility {
    3232
    3333  class CommandLine;
     
    150150  };
    151151
    152 }} // of namespace svndigest, and theplu
     152}}} // of namespace utility, yat, and theplu
    153153
    154154#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_
    33
    4 // $Id$
     4// $Id: OptionArg.h 1797 2009-02-12 18:07:10Z peter $
    55
    66/*
    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
     8  Copyright (C) 2009 Peter Johansson
    99
    10   This file is part of svndigest, http://dev.thep.lu.se/svndigest
     10  This file is part of the yat library, http://dev.thep.lu.se/yat
    1111
    12   svndigest is free software; you can redistribute it and/or modify it
    13   under the terms of the GNU General Public License as published by
    14   the Free Software Foundation; either version 3 of the License, or
    15   (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.
    1616
    17   svndigest is distributed in the hope that it will be useful, but
    18   WITHOUT ANY WARRANTY; without even the implied warranty of
     17  The yat library is distributed in the hope that it will be useful,
     18  but WITHOUT ANY WARRANTY; without even the implied warranty of
    1919  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    2020  General Public License for more details.
    2121
    2222  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/>.
    2424*/
    2525
     
    2929#include "utility.h"
    3030
     31#include <stdexcept>
    3132#include <string>
    3233#include <sstream>
    3334
    3435namespace theplu {
    35 namespace svndigest {
     36namespace yat {
     37namespace utility {
    3638
    3739  class CommandLine;
     
    6466
    6567    /**
    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.
    6972     */
    7073    void print_arg(std::string arg) { print_arg_ = arg; }
     
    7376       \return value
    7477    */
    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    }
    7686
    7787    /**
    7888       \brief set value
     89
     90       \since new in yat 0.5
    7991    */
    8092    void value(T v) { value_ = v; }
     
    167179  };
    168180
    169 }} // of namespace svndigest and theplu
     181}}} // of namespace utility, yat, and theplu
    170182
    171183#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 $
    22
    33/*
    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
    65
    7   This file is part of svndigest, http://dev.thep.lu.se/svndigest
     6  This file is part of the yat library, http://dev.thep.lu.se/yat
    87
    9   svndigest is free software; you can redistribute it and/or
     8  The yat library is free software; you can redistribute it and/or
    109  modify it under the terms of the GNU General Public License as
    1110  published by the Free Software Foundation; either version 3 of the
    1211  License, or (at your option) any later version.
    1312
    14   svndigest is distributed in the hope that it will be useful,
     13  The yat library is distributed in the hope that it will be useful,
    1514  but WITHOUT ANY WARRANTY; without even the implied warranty of
    1615  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
     
    1817
    1918  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/>.
    2120*/
    2221
     
    2423#include "CommandLine.h"
    2524
    26 #include <cstdlib>
    2725#include <sstream>
    2826#include <string>
    2927
    3028namespace theplu {
    31 namespace svndigest {
     29namespace yat {
     30namespace utility {
     31
    3232
    3333  OptionHelp::OptionHelp(CommandLine& cmd, std::string flag,
     
    6868  }
    6969
    70 }} // of namespace svndigest and theplu
     70}}} // 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_
    33
    4 // $Id$
     4// $Id: OptionHelp.h 1797 2009-02-12 18:07:10Z peter $
    55
    66/*
    7   Copyright (C) 2008 Peter Johansson
     7  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    88
    9   This file is part of svndigest, http://trac.thep.lu.se/svndigest
     9  This file is part of the yat library, http://dev.thep.lu.se/yat
    1010
    11   svndigest is free software; you can redistribute it and/or modify it
    12   under the terms of the GNU General Public License as published by
    13   the Free Software Foundation; either version 2 of the License, or
    14   (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.
    1515
    16   svndigest is distributed in the hope that it will be useful, but
    17   WITHOUT ANY WARRANTY; without even the implied warranty of
     16  The yat library is distributed in the hope that it will be useful,
     17  but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    1919  General Public License for more details.
    2020
    2121  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/>.
    2523*/
    2624
     
    3028
    3129namespace theplu {
    32 namespace svndigest {
     30namespace yat {
     31namespace utility {
    3332
    3433  class CommandLine;
     
    3736
    3837     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.
    4060   */
    4161  class OptionHelp : public OptionSwitch
     
    81101  };
    82102
    83 }} // of namespace svndigest and theplu
     103}}} // of namespace utility, yat, and theplu
    84104
    85105#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 $
    22
    33/*
    4   Copyright (C) 2007 Jari Häkkinen, Peter Johansson
     4  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    55
    6   This file is part of svndigest, http://dev.thep.lu.se/svndigest
     6  This file is part of the yat library, http://dev.thep.lu.se/yat
    77
    8   svndigest is free software; you can redistribute it and/or modify it
    9   under the terms of the GNU General Public License as published by
    10   the Free Software Foundation; either version 3 of the License, or
    11   (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.
    1212
    13   svndigest is distributed in the hope that it will be useful, but
    14   WITHOUT ANY WARRANTY; without even the implied warranty of
     13  The yat library is distributed in the hope that it will be useful,
     14  but WITHOUT ANY WARRANTY; without even the implied warranty of
    1515  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    1616  General Public License for more details.
    1717
    1818  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/>.
    2020*/
    2121
     
    2626
    2727namespace theplu {
    28 namespace svndigest {
     28namespace yat {
     29namespace utility {
     30
    2931
    3032  OptionSwitch::OptionSwitch(CommandLine& cmd, std::string flag,
     
    7678
    7779
    78 }} // of namespace svndigest and theplu
     80}}} // 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_
    33
    4 // $Id$
     4// $Id: OptionSwitch.h 1797 2009-02-12 18:07:10Z peter $
    55
    66/*
    7   Copyright (C) 2007 Jari Häkkinen, Peter Johansson
     7  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    88
    9   This file is part of svndigest, http://dev.thep.lu.se/svndigest
     9  This file is part of the yat library, http://dev.thep.lu.se/yat
    1010
    11   svndigest is free software; you can redistribute it and/or modify it
    12   under the terms of the GNU General Public License as published by
    13   the Free Software Foundation; either version 3 of the License, or
    14   (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.
    1515
    16   svndigest is distributed in the hope that it will be useful, but
    17   WITHOUT ANY WARRANTY; without even the implied warranty of
     16  The yat library is distributed in the hope that it will be useful,
     17  but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    1919  General Public License for more details.
    2020
    2121  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/>.
    2323*/
    2424
     
    2828
    2929namespace theplu {
    30 namespace svndigest {
     30namespace yat {
     31namespace utility {
    3132
    3233  class CommandLine;
     
    8182  };
    8283
    83 }} // of namespace svndigest, and theplu
     84}}} // of namespace utility, yat, and theplu
    8485
    8586#endif
Note: See TracChangeset for help on using the changeset viewer.