// CSV_line.h (C) 2008 adolfo@di-mare.com #ifdef English_dox /// Doxygen English documentation. #define English_dox "Doxygen English documentation" /// \def English_dox ///< Marks English documentation blocks. #endif #ifdef English_dox /** \file CSV_line.h \brief C++ wrapper class for \c CSV.h. \author Adolfo Di Mare \date 2008 */ #endif #ifdef English_dox /// \def CSV_line_h ///< Avoids multiple inclusion. #endif #ifndef CSV_line_h #define CSV_line_h #include "CSV.h" // CSV: Comma Separated Values [IETF RFC-4180]. // namespace csv { #ifdef English_dox /// Uses \c getNextCSV() to scan and store complete CSV lines. /// - Oftentimes it helps a lot to \c chop() out trailing CR+LF's. /// - This class is derived from std::vector and has /// all vector operations and interfaces. #endif class CSV_line : public std::vector { public: CSV_line(); CSV_line( const std::string & str ); CSV_line( const char *pz_str , size_t n=0 ); CSV_line( const CSV_line & ); void setData( const std::string & str ); void setData( const char *pz_str , size_t n=0 ); friend class test_CSV; }; #ifdef English_dox /// \class test_CSV; /// \brief Tests cases for \c CSV_line. #endif #ifdef English_dox /// Constructor. #endif inline CSV_line::CSV_line() { } #ifdef English_dox /// Copy constructor. #endif inline CSV_line::CSV_line( const CSV_line & ) { } #ifdef English_dox /// Constructor from string \c str. #endif inline CSV_line::CSV_line( const std::string & str ) { setData( str ); } #ifdef English_dox /// Constructor from \c pz_str. #endif inline CSV_line::CSV_line( const char *pz_str , size_t n ) { setData( pz_str , n ); } #ifdef English_dox /** \fn int CSV_line::setData( const std::string & str ); \brief Scans line \c str to extract all its CSV fields. - Stops scanning when a CSV field ends with \c "\n" (Line Feed). - Processes up to \c str.length() characters in \c str [ including \c char(0) ]. - Misplaced \c "\n" (Line Feed) characters are interpreted as comma \c ',' separators. - Removes the trailing \c "\n" (Line Feed) from the last CSV field. - Removes the trailing end of line marker \c "\r\n" from the last CSV field. \dontinclude test_CSV.cpp \skipline test::setData() \until }} \see test_CSV::test_setData() */ #endif #ifdef English_dox /** \fn int CSV_line::setData( const char *pz_str , size_t n ); \brief Scans line \c pz_str to extract all its CSV fields. - When n <= 0 computes the length with \c strlen(). - Processes all the \c n chars in \c pz_str [ including \c char(0) ]. - Stops scanning when a CSV field ends with \c "\n" (Line Feed). - Misplaced \c "\n" (Line Feed) characters are interpreted as comma \c ',' separators. - Removes the trailing \c "\n" (Line Feed) from the last CSV field. - Removes the trailing end of line marker \c "\r\n" from the last CSV field. \dontinclude test_CSV.cpp \skipline test::setData() \until }} \see test_CSV::test_setData() */ #endif // }; // namespace csv #ifdef English_dox /// Defined by the C++ standard library namespace std { } // trick to include it into the Doxygen documentation #endif #endif // EOF: CSV_line.h