Changeset 1058


Ignore:
Timestamp:
Apr 24, 2010, 6:36:59 PM (13 years ago)
Author:
Peter Johansson
Message:

update to latest yat

Location:
trunk/lib
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/OptionVersion.cc

    r1021 r1058  
    3737#endif
    3838
     39#include <cstdlib>
    3940#include <iostream>
    4041#include <sstream>
     
    9192#endif
    9293    }
    93     exit(0);
     94    exit(EXIT_SUCCESS);
    9495  }
    9596
  • trunk/lib/OptionVersion.h

    r847 r1058  
    55
    66/*
    7   Copyright (C) 2008, 2009 Peter Johansson
     7  Copyright (C) 2008, 2009, 2010 Peter Johansson
    88
    99  This file is part of svndigest, http://trac.thep.lu.se/svndigest
     
    5757                  OptionSwitch* const verbose=NULL);
    5858
     59    /**
     60       \brief set version string
     61    */
     62    void version(const std::string&);
     63
    5964  private:
    6065    OptionSwitch* const verbose_;
  • trunk/lib/yat/CommandLine.h

    r1039 r1058  
    22#define _theplu_yat_utility_commandline_
    33
    4 //$Id: CommandLine.h 2202 2010-02-21 18:39:13Z peter $
     4//$Id: CommandLine.h 2247 2010-04-22 00:54:34Z peter $
    55
    66/*
     
    164164  private:
    165165    friend std::ostream& operator<<(std::ostream& os, const CommandLine& cl);
    166     void add_private(std::string, Option&);
    167166    bool is_long_option(std::string str) const;
    168167    bool is_short_option(std::string str) const;
  • trunk/lib/yat/OptionHelp.cc

    r1027 r1058  
    1 // $Id: OptionHelp.cc 2121 2009-12-13 16:17:07Z peter $
     1// $Id: OptionHelp.cc 2246 2010-04-22 00:53:23Z peter $
    22
    33/*
     
    5050    std::cout << cmd() << "\n";
    5151    std::cout << post_cmd_;
    52     exit(0);
     52    exit(EXIT_SUCCESS);
    5353  }
    5454
  • trunk/lib/yat/utility.h

    r1039 r1058  
    22#define _theplu_yat_utility_utility_
    33
    4 // $Id: utility.h 2210 2010-03-05 22:59:01Z peter $
     4// $Id: utility.h 2248 2010-04-22 00:57:13Z peter $
    55
    66/*
     
    149149
    150150     \note Requirement on T: utility::convert<T> must be supported
     151     (from yat 0.7 T=string is also supported)
    151152
    152153     \since New in yat 0.6
     
    173174     
    174175     \note Requirement on T: utility::convert<T> must be supported
     176     (from yat 0.7 T=string is also supported)
    175177
    176178     \since New in yat 0.6
     
    179181  void load(std::istream& is, std::vector<T>& vec, char sep='\0');
    180182 
     183// private namespace
     184namespace detail {
     185  /**
     186     Functor used in load function
     187   */
     188  template<typename T>
     189  struct VectorPusher
     190  {
     191    /**
     192       convert element to T and push on vec's back
     193
     194       \internal
     195     */
     196    void operator()(const std::string& element, std::vector<T>& vec)
     197    {
     198      if (!element.size())
     199        vec.push_back(std::numeric_limits<T>::quiet_NaN());
     200      else {
     201        vec.push_back(theplu::yat::utility::convert<T>(element));
     202      }
     203    }
     204  };
     205
     206  /**
     207     specialization for string
     208
     209     \internal
     210   */
     211  template<>
     212  struct VectorPusher<std::string>
     213  {
     214    /**
     215       push element on vec's back
     216     */
     217    void operator()(const std::string& element, std::vector<std::string>& vec)
     218    {
     219      vec.push_back(element);
     220    }
     221  };
     222
     223} // end of namespace detail
     224
     225
    181226  // template implementations
    182227
     
    287332  void load(std::istream& is, std::vector<T>& vec, char sep='\0')
    288333  {
     334    detail::VectorPusher<T> pusher;
    289335    std::string element;
    290336    bool ok=true;
    291     while(ok) {
     337    while(true) {
    292338      if(sep=='\0')
    293339        ok=(is>>element);
     
    297343        break;
    298344     
    299       if (!element.size())
    300         vec.push_back(std::numeric_limits<T>::quiet_NaN());
    301       else {
    302         vec.push_back(convert<T>(element));
    303       }
     345      pusher(element, vec);
    304346    }
    305347  }           
Note: See TracChangeset for help on using the changeset viewer.