ConfDataWriter.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: ConfDataWriter.hpp 2549 2011-04-11 08:49:50Z yanweignss $"
00002 
00008 #ifndef GPSTK_CONFDATA_WRITER_HPP
00009 #define GPSTK_CONFDATA_WRITER_HPP
00010 
00011 
00012 //============================================================================
00013 //
00014 //  This file is part of GPSTk, the GPS Toolkit.
00015 //
00016 //  The GPSTk is free software; you can redistribute it and/or modify
00017 //  it under the terms of the GNU Lesser General Public License as published
00018 //  by the Free Software Foundation; either version 2.1 of the License, or
00019 //  any later version.
00020 //
00021 //  The GPSTk is distributed in the hope that it will be useful,
00022 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00023 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024 //  GNU Lesser General Public License for more details.
00025 //
00026 //  You should have received a copy of the GNU Lesser General Public
00027 //  License along with GPSTk; if not, write to the Free Software Foundation,
00028 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00029 //
00030 //  Wei Yan - Chinese Academy of Sciences  2009, 2010
00031 //
00032 //============================================================================
00033 
00034 
00035 #include <string>
00036 #include <map>
00037 #include "FFTextStream.hpp"
00038 #include "StringUtils.hpp"
00039 
00040 using namespace std;
00041 
00042 namespace gpstk
00043 {
00044 
00045         
00048 
00088         class ConfDataWriter:public FFTextStream
00089         {
00090         public:
00091 
00093       ConfDataWriter()
00094       { setVariableWidth(); setValuePrecision();}
00095 
00102                 ConfDataWriter(const char* file)
00103                         : FFTextStream(file, std::ios::out)
00104                 { writeHeader(); };
00105 
00106 
00113                 ConfDataWriter(const string& file)
00114                         : FFTextStream(file.c_str(), std::ios::out)
00115                 { writeHeader(); };
00116 
00117 
00119                 virtual void open(const char* fn);
00120 
00121 
00123                 virtual void open(const string& fn)
00124                 { open( fn.c_str() ); };
00125 
00126 
00129                 virtual void writeHeader();
00130          
00132                 void writeCommentLine(const string& comment);
00133          
00137                 void writeSeparatorLine(const string& s = "-",
00138                               const int&    n = 130);
00139 
00141                 void writeBlankLine(const int& n=1);
00142          
00150                 void writeVariable(const string& var, 
00151                          const string& val, 
00152                          const string& varComment = "",
00153                          const string& valComment = "");
00154                 
00155                    
00163       void writeVariable(const string& var,
00164                          const int&    val,
00165                          const string& varComment = "",
00166                          const string& valComment = "")
00167       { writeVariable(var,StringUtils::asString(val),varComment,valComment);}
00168                 
00169          
00177       void writeVariable(const string& var,
00178                          const double& val,
00179                          const string& varComment = "",
00180                          const string& valComment = "");
00181 
00182 
00183                    
00192                 void writeVariableList(const string& var,
00193                              const string  valList[],
00194                              const int&    n,
00195                              const string& varComment = "",
00196                              const string& valComment = "");
00197                 
00198 
00206       void writeVariableList(const string&         var,
00207                              vector<string>        valList,
00208                              const string&         varComment = "",
00209                              const string&         valComment = "");
00210                 
00211 
00220                 void writeVariableList(const string& var,
00221                              const int     valList[],
00222                              const int&    n,
00223                              const string& varComment = "",
00224                              const string& valComment = "");
00225                 
00226 
00235       void writeVariableList(const string& var,
00236                              const double  valList[],
00237                              const int&    n,
00238                              const string& varComment = "",
00239                              const string& valComment = "");
00240                 
00241       
00247                 void writeSection(const string& name,
00248                         const string& comment = "");
00249          
00252                 void writeEnd();
00253 
00256       void setVariableWidth(const int width = 0)
00257       { variableWidth = width;}
00258 
00261       void setValuePrecision(const int precision = 6)
00262       { valuePrecison = precision;}
00263 
00264         protected:
00265 
00267                 void formattedPutLine(const string& sline);
00268 
00269       int variableWidth;
00270       
00271       int valuePrecison;
00272 
00273         };  // End of class 'ConfDataWriter'
00274 
00276 
00277 }  // End of namespace gpstk
00278 
00279 
00280 
00281 #endif  //  GPSTK_CONFDATA_WRITER_HPP

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