CommandOptionWithTimeArg.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: CommandOptionWithTimeArg.cpp 274 2006-10-27 14:24:35Z rickmach $"
00002 
00003 
00004 
00005 //============================================================================
00006 //
00007 //  This file is part of GPSTk, the GPS Toolkit.
00008 //
00009 //  The GPSTk is free software; you can redistribute it and/or modify
00010 //  it under the terms of the GNU Lesser General Public License as published
00011 //  by the Free Software Foundation; either version 2.1 of the License, or
00012 //  any later version.
00013 //
00014 //  The GPSTk is distributed in the hope that it will be useful,
00015 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 //  GNU Lesser General Public License for more details.
00018 //
00019 //  You should have received a copy of the GNU Lesser General Public
00020 //  License along with GPSTk; if not, write to the Free Software Foundation,
00021 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 //  
00023 //  Copyright 2004, The University of Texas at Austin
00024 //
00025 //============================================================================
00026 
00027 //============================================================================
00028 //
00029 //This software developed by Applied Research Laboratories at the University of
00030 //Texas at Austin, under contract to an agency or agencies within the U.S. 
00031 //Department of Defense. The U.S. Government retains all rights to use,
00032 //duplicate, distribute, disclose, or release this software. 
00033 //
00034 //Pursuant to DoD Directive 523024 
00035 //
00036 // DISTRIBUTION STATEMENT A: This software has been approved for public 
00037 //                           release, distribution is unlimited.
00038 //
00039 //=============================================================================
00040 
00041 
00042 
00043 
00044 
00045 
00051 #include "StringUtils.hpp"
00052 #include "CommandOptionWithTimeArg.hpp"
00053 
00054 using namespace std;
00055 
00056 namespace gpstk
00057 {
00058    string CommandOptionWithTimeArg :: checkArguments()
00059    {
00060       string errstr = CommandOptionWithAnyArg::checkArguments();
00061 
00062       if (errstr != string())
00063          return errstr;
00064 
00065       vector<string>::size_type vecindex;
00066       for(vecindex = 0; vecindex < value.size(); vecindex++)
00067       {
00068          string thisTimeSpec = getTimeSpec(vecindex);
00069          if (thisTimeSpec != string())
00070          {
00071             try {
00072                DayTime dt;
00073                dt.setToString(value[vecindex], thisTimeSpec);
00074                times.push_back(dt);
00075             }
00076             catch (...)
00077             {
00078                errstr += "\"" + value[vecindex] + "\" is not a valid time.";
00079             }
00080          }
00081          else
00082             errstr += "\"" + value[vecindex] + "\" is not a valid time.";
00083       }
00084 
00085       return errstr;
00086    }
00087 
00088    string CommandOptionWithSimpleTimeArg :: getTimeSpec
00089    (vector<string>::size_type index) const
00090    {
00091       int numwords = gpstk::StringUtils::numWords(value[index]);
00092       string thisTimeSpec;
00093       switch (numwords)
00094       {
00095          case 1:
00096             thisTimeSpec = "%m/%d/%Y";
00097             break;
00098          case 2:
00099             thisTimeSpec = "%Y %j";
00100             break;
00101          case 3:
00102             thisTimeSpec = "%Y %j %s";
00103             break;
00104       }
00105 
00106       return thisTimeSpec;
00107    }
00108 
00109 } // namespace gpstk

Generated on Tue May 22 03:30:56 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1