TeAsciiFile.h

Go to the documentation of this file.
00001 /************************************************************************************
00002 TerraLib - a library for developing GIS applications.
00003 Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
00004 
00005 This code is part of the TerraLib library.
00006 This library is free software; you can redistribute it and/or
00007 modify it under the terms of the GNU Lesser General Public
00008 License as published by the Free Software Foundation; either
00009 version 2.1 of the License, or (at your option) any later version.
00010 
00011 You should have received a copy of the GNU Lesser General Public
00012 License along with this library.
00013 
00014 The authors reassure the license terms regarding the warranties.
00015 They specifically disclaim any warranties, including, but not limited to,
00016 the implied warranties of merchantability and fitness for a particular purpose.
00017 The library provided hereunder is on an "as is" basis, and the authors have no
00018 obligation to provide maintenance, support, updates, enhancements, or modifications.
00019 In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
00020 indirect, special, incidental, or consequential damages arising out of the use
00021 of this library and its documentation.
00022 *************************************************************************************/
00023 /*! \file TeAsciiFile.h
00024     \brief This file contains structures and definitions to deal ASCII files
00025 */
00026 #ifndef  __TERRALIB_INTERNAL_ASCIIFILE_H
00027 #define  __TERRALIB_INTERNAL_ASCIIFILE_H
00028 
00029 #include "TeDefines.h"
00030 #include "TeStdFile.h"
00031 #include "TeCoord2D.h"
00032 #include "TeBox.h"
00033 
00034 #include <stdio.h>
00035 
00036 #include <vector> 
00037 #include <string>
00038 using namespace std;
00039 
00040 //!  A class for handling reading/writing for ASCII files
00041 /*!  Simple wrapper around a stdio file. Clientes are all the 
00042          functions that imports from ASCII files. 
00043 
00044  \sa
00045   TeStdFile, TeSPRFile
00046 */
00047 class TL_DLL TeAsciiFile: public TeStdFile {
00048 
00049 public:
00050 
00051         //! Contructors
00052         TeAsciiFile(const string& name, const char* mode = "r");
00053         
00054         //! Destructor
00055         virtual ~TeAsciiFile();
00056 
00057         //! Writes a carriage return character
00058         void writeNewLine ()
00059         { fprintf ( file_, "\n" ); } 
00060         
00061         //! Goes to a new line 
00062         void findNewLine () ; 
00063 
00064         //! Reads a string
00065         string readString(); 
00066 
00067         //! Reads a full line up to carriage return
00068         string readLine(); 
00069 
00070         //! Writes a generic string to the file
00071         void writeString (const string& s);
00072 
00073         //! Reads a string whithin quotes
00074         string readQuotedString(); 
00075 
00076         //! Reads a comma-separated string ( with a skip character )
00077         string readStringCSV( const char sep = ',', bool skip = false, 
00078                                                   const char skip_char = ' ');
00079 
00080         //! Reads a character whithin quotes
00081         char readQuotedChar();
00082 
00083         //! Reads a character
00084         char readChar();
00085 
00086         //! Reads a comma-separated string(ignore spaces)
00087         string readStringCSVNoSpace( const char del = ',');
00088 
00089         //! Reads a comma-separated string (ignore quote )
00090         string readStringCSVNoQuote ( const char del = ',' );
00091 
00092         //! Reads an integer
00093         int readInt();
00094 
00095         //! Reads a comma-separated int
00096         int readIntCSV( const char del = ',');
00097 
00098         //! Reads a float
00099         double readFloat();
00100 
00101         //! Reads a comma-separated float
00102         double readFloatCSV( const char del = ',');
00103 
00104         //! Reads a 2D coordinate ( x, y )
00105         TeCoord2D readCoord2D();
00106 
00107         //! Reads a line and put in a stringlist
00108         void readStringList ( vector<string>& );
00109 
00110         //! Reads a comma-separated line string and put in a string list
00111         void readStringListCSV ( vector<string>&, const char sep = ',');
00112 
00113         //! Reads the first n strings from a comma separated line string and put in a string list
00114         void readNStringCSV ( vector<string>&, unsigned int n, const char sep = ',');
00115 
00116         //! Reads a bounding box
00117         TeBox readBox();
00118 
00119         //! Reads the entire content of the file, skipping new line characters only
00120         string readAll();
00121   
00122   /*!  Write a vector os coordinates pairs using the CSV file format (one line per coordinate
00123      pair).
00124     \param coordsVec The input coordinate pairs vector.
00125     \return true if ok, false on errors.
00126     \note 15 digits precision
00127   */
00128   bool writeCoordPairVect2CSV( const TeCoordPairVect& coordsVec );
00129 
00130   /*!  Read a vector os coordinates pairs using the CSV file format (one line per coordinate
00131      pair).
00132     \param coordsVec The input coordinate pairs vector.
00133     \return true if ok, false on errors.
00134   */
00135   bool readCoordPairVect2CSV( TeCoordPairVect& coordsVec );
00136 
00137 
00138   //! \brief Read Angle
00139   /*! Method to return the angle of a mid/mif file when it has a text
00140                 representation
00141         \return returns the text angle
00142         */
00143   double readAngle(const std::string &value);
00144 
00145   //! \brief Read a font name
00146   /*! Methodo to read a font name to text geometry
00147   */
00148   std::string readFont();
00149   
00150 private:
00151         
00152 // No copy allowed
00153 
00154         TeAsciiFile(const TeAsciiFile&);
00155         TeAsciiFile& operator=(const TeAsciiFile&);
00156 
00157 };
00158 #endif
00159 
00160 

Generated on Sun Jul 29 04:01:18 2012 for TerraLib - Development Source by  doxygen 1.5.3