FormatUtils.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: FormatUtils.hpp 2938 2011-10-23 19:39:11Z yanweignss $"
00002 
00008 #ifndef GPSTK_FORMATUTILS_HPP
00009 #define GPSTK_FORMATUTILS_HPP
00010 
00011 //============================================================================
00012 //
00013 //  This file is part of GPSTk, the GPS Toolkit.
00014 //
00015 //  The GPSTk is free software; you can redistribute it and/or modify
00016 //  it under the terms of the GNU Lesser General Public License as published
00017 //  by the Free Software Foundation; either version 2.1 of the License, or
00018 //  any later version.
00019 //
00020 //  The GPSTk is distributed in the hope that it will be useful,
00021 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 //  GNU Lesser General Public License for more details.
00024 //
00025 //  You should have received a copy of the GNU Lesser General Public
00026 //  License along with GPSTk; if not, write to the Free Software Foundation,
00027 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028 //
00029 //  Wei Yan - Chinese Academy of Sciences . 2011
00030 //
00031 //============================================================================
00032 
00033 #include <vector>
00034 #include <string>
00035 #include "Any.hpp"
00036 
00037 namespace gpstk
00038 {
00111    class FormatUtils
00112    {
00113    public:
00114       static std::string format(const std::string& fmt, const Any& value);
00115       static std::string format(const std::string& fmt, const Any& value1, const Any& value2);
00116       static std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3);
00117       static std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4);
00118       static std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5);
00119       static std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6);
00120 
00121       
00122       static void format(std::string& result, const std::string& fmt, const Any& value);
00123       static void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2);
00124       static void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3);
00125       static void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4);
00126       static void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5);
00127       static void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6);
00128 
00129       static void format(std::string& result, const std::string& fmt, const std::vector<Any>& values);
00130       
00131    protected:
00132       FormatUtils(){}
00133 
00134       static void parseFlags(std::ostream& str, std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt);
00135       static void parseWidth(std::ostream& str, std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt);
00136       static void parsePrec(std::ostream& str, std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt);
00137       static char parseMod(std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt);
00138       static std::size_t parseIndex(std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt);
00139       static void prepareFormat(std::ostream& str, char type);
00140 
00141       static void writeAnyInt(std::ostream& str, const Any& any);
00142 
00143       static void formatOne(std::string& result, std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt, std::vector<Any>::const_iterator& itVal);
00144    };
00145 
00146 
00147 }   // End of namespace gpstk
00148 
00149 
00150 #endif  //GPSTK_FORMATUTILS_HPP
00151 

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