Ignore:
Timestamp:
Jun 6, 2010, 1:24:05 AM (11 years ago)
Author:
Peter Johansson
Message:

sort options alphabetically. refs #307

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/yat/CommandLine.cc

    r1039 r1064  
    1 // $Id: CommandLine.cc 2210 2010-03-05 22:59:01Z peter $
     1// $Id: CommandLine.cc 2265 2010-06-05 23:12:10Z peter $
    22
    33/*
     
    3232
    3333#include <algorithm>
     34#include <cassert>
    3435#include <functional>
    3536#include <fstream>
     
    197198
    198199
     200  void CommandLine::sort(void)
     201  {
     202    sort(OptionCompare());
     203  }
     204
     205
    199206  std::vector<std::string> CommandLine::split(std::string str, char del) const
    200207  {
     
    237244
    238245
     246  bool CommandLine::OptionCompare::operator()(const Option* lhs,
     247                                              const Option* rhs) const
     248  {
     249    assert(lhs);
     250    assert(rhs);
     251    std::string lhs_str = lhs->long_name();
     252    if (lhs_str.empty())
     253      lhs_str = lhs->short_name();
     254    std::string rhs_str = rhs->long_name();
     255    if (rhs_str.empty())
     256      rhs_str = rhs->short_name();
     257    return lhs_str < rhs_str;
     258  }
     259
     260
    239261}}} // of namespace utility, yat, and theplu
Note: See TracChangeset for help on using the changeset viewer.