00001 // CSV_line.h (C) 2008 adolfo@di-mare.com 00002 00003 #ifdef English_dox 00004 /// Doxygen English documentation. 00005 #define English_dox "Doxygen English documentation" 00006 /// \def English_dox ///< Marks English documentation blocks. 00007 #endif 00008 00009 #ifdef English_dox 00010 /** \file CSV_line.h 00011 \brief C++ wrapper class for \c CSV.h. 00012 00013 \author Adolfo Di Mare <adolfo@di-mare.com> 00014 \date 2008 00015 */ 00016 #endif 00017 00018 #ifdef English_dox 00019 /// \def CSV_line_h ///< Avoids multiple inclusion. 00020 #endif 00021 00022 #ifndef CSV_line_h 00023 #define CSV_line_h 00024 00025 #include "CSV.h" 00026 00027 // CSV: Comma Separated Values [IETF RFC-4180]. 00028 // namespace csv { 00029 00030 #ifdef English_dox 00031 /// Uses \c getNextCSV() to scan and store complete CSV lines. 00032 /// - Oftentimes it helps a lot to \c chop() out trailing CR+LF's. 00033 /// - This class is derived from std::vector<std::string> and has 00034 /// all vector operations and interfaces. 00035 #endif 00036 class CSV_line : public std::vector<std::string> { 00037 public: 00038 CSV_line(); 00039 CSV_line( const std::string & str ); 00040 CSV_line( const char *pz_str , size_t n=0 ); 00041 CSV_line( const CSV_line & ); 00042 void setData( const std::string & str ); 00043 void setData( const char *pz_str , size_t n=0 ); 00044 friend class test_CSV; 00045 }; 00046 00047 #ifdef English_dox 00048 /// \class test_CSV; 00049 /// \brief Tests cases for \c CSV_line. 00050 #endif 00051 00052 #ifdef English_dox 00053 /// Constructor. 00054 #endif 00055 inline CSV_line::CSV_line() { } 00056 00057 #ifdef English_dox 00058 /// Constructor from string \c str. 00059 #endif 00060 inline CSV_line::CSV_line( const std::string & str ) { 00061 setData( str ); 00062 } 00063 00064 #ifdef English_dox 00065 /// Constructor from \c pz_str. 00066 #endif 00067 inline CSV_line::CSV_line( const char *pz_str , size_t n ) { 00068 setData( pz_str , n ); 00069 } 00070 00071 #ifdef English_dox 00072 /** \fn int CSV_line::setData( const std::string & str ); 00073 \brief Scans line \c str to extract all its CSV fields. 00074 - Stops scanning when a CSV field ends with \c "\n" (Line Feed). 00075 - Processes up to \c str.length() characters in \c str [ including \c char(0) ]. 00076 - Misplaced \c "\n" (Line Feed) characters are interpreted as comma 00077 \c ',' separators. 00078 - Removes the trailing \c "\n" (Line Feed) from the last CSV field. 00079 - Removes the trailing end of line marker \c "\r\n" from the last CSV field. 00080 00081 \dontinclude test_CSV.cpp 00082 \skipline test::setData() 00083 \until }} 00084 \see test_CSV::test_setData() 00085 */ 00086 #endif 00087 00088 #ifdef English_dox 00089 /** \fn int CSV_line::setData( const char *pz_str , size_t n ); 00090 \brief Scans line \c pz_str to extract all its CSV fields. 00091 - When <code> n <= 0 </code> computes the length with \c strlen(). 00092 - Processes all the \c n chars in \c pz_str [ including \c char(0) ]. 00093 - Stops scanning when a CSV field ends with \c "\n" (Line Feed). 00094 - Misplaced \c "\n" (Line Feed) characters are interpreted as comma 00095 \c ',' separators. 00096 - Removes the trailing \c "\n" (Line Feed) from the last CSV field. 00097 - Removes the trailing end of line marker \c "\r\n" from the last CSV field. 00098 00099 \dontinclude test_CSV.cpp 00100 \skipline test::setData() 00101 \until }} 00102 \see test_CSV::test_setData() 00103 */ 00104 #endif 00105 00106 // }; // namespace csv 00107 00108 #ifdef English_dox 00109 /// Defined by the C++ standard library 00110 namespace std { } // trick to include it into the Doxygen documentation 00111 #endif 00112 00113 #endif 00114 00115 // EOF: CSV_line.h
1.5.6