-: 0:Source:CSV_line.h -: 0:Graph:test_CSV.gcno -: 0:Data:test_CSV.gcda -: 0:Runs:1 -: 0:Programs:1 -: 1:// CSV_line.h (C) 2008 adolfo@di-mare.com -: 2: -: 3:#ifdef English_dox -: 4: /// Doxygen English documentation. -: 5: #define English_dox "Doxygen English documentation" -: 6: /// \def English_dox ///< Marks English documentation blocks. -: 7:#endif -: 8: -: 9:#ifdef English_dox -: 10:/** \file CSV_line.h -: 11: \brief C++ wrapper class for \c CSV.h. -: 12: -: 13: \author Adolfo Di Mare -: 14: \date 2008 -: 15:*/ -: 16:#endif -: 17: -: 18:#ifdef English_dox -: 19:/// \def CSV_line_h ///< Avoids multiple inclusion. -: 20:#endif -: 21: -: 22:#ifndef CSV_line_h -: 23:#define CSV_line_h -: 24: -: 25:#include "CSV.h" -: 26: -: 27:// CSV: Comma Separated Values [IETF RFC-4180]. -: 28:// namespace csv { -: 29: -: 30:#ifdef English_dox -: 31:/// Uses \c getNextCSV() to scan and store complete CSV lines. -: 32:/// - Oftentimes it helps a lot to \c chop() out trailing CR+LF's. -: 33:/// - This class is derived from std::vector and has -: 34:/// all vector operations and interfaces. -: 35:#endif -: 36:class CSV_line : public std::vector { -: 37:public: -: 38: CSV_line(); -: 39: CSV_line( const std::string & str ); -: 40: CSV_line( const char *pz_str , size_t n=0 ); -: 41: CSV_line( const CSV_line & ); -: 42: void setData( const std::string & str ); -: 43: void setData( const char *pz_str , size_t n=0 ); -: 44: friend class test_CSV; -: 45:}; -: 46: -: 47:#ifdef English_dox -: 48:/// \class test_CSV; -: 49:/// \brief Tests cases for \c CSV_line. -: 50:#endif -: 51: -: 52:#ifdef English_dox -: 53:/// Constructor. -: 54:#endif function _ZN8CSV_lineC1Ev called 6 returned 100% blocks executed 70% 12: 55:inline CSV_line::CSV_line() { } -: 56: -: 57:#ifdef English_dox -: 58:/// Copy constructor. -: 59:#endif -: 60:inline CSV_line::CSV_line( const CSV_line & ) { } -: 61: -: 62:#ifdef English_dox -: 63:/// Constructor from string \c str. -: 64:#endif -: 65:inline CSV_line::CSV_line( const std::string & str ) { -: 66: setData( str ); -: 67:} -: 68: -: 69:#ifdef English_dox -: 70:/// Constructor from \c pz_str. -: 71:#endif function _ZN8CSV_lineC1EPKcj called 13 returned 100% blocks executed 60% 26: 72:inline CSV_line::CSV_line( const char *pz_str , size_t n ) { 13: 73: setData( pz_str , n ); -: 74:} -: 75: -: 76:#ifdef English_dox -: 77:/** \fn int CSV_line::setData( const std::string & str ); -: 78: \brief Scans line \c str to extract all its CSV fields. -: 79: - Stops scanning when a CSV field ends with \c "\n" (Line Feed). -: 80: - Processes up to \c str.length() characters in \c str [ including \c char(0) ]. -: 81: - Misplaced \c "\n" (Line Feed) characters are interpreted as comma -: 82: \c ',' separators. -: 83: - Removes the trailing \c "\n" (Line Feed) from the last CSV field. -: 84: - Removes the trailing end of line marker \c "\r\n" from the last CSV field. -: 85: -: 86: \dontinclude test_CSV.cpp -: 87: \skipline test::setData() -: 88: \until }} -: 89: \see test_CSV::test_setData() -: 90:*/ -: 91:#endif -: 92: -: 93:#ifdef English_dox -: 94:/** \fn int CSV_line::setData( const char *pz_str , size_t n ); -: 95: \brief Scans line \c pz_str to extract all its CSV fields. -: 96: - When n <= 0 computes the length with \c strlen(). -: 97: - Processes all the \c n chars in \c pz_str [ including \c char(0) ]. -: 98: - Stops scanning when a CSV field ends with \c "\n" (Line Feed). -: 99: - Misplaced \c "\n" (Line Feed) characters are interpreted as comma -: 100: \c ',' separators. -: 101: - Removes the trailing \c "\n" (Line Feed) from the last CSV field. -: 102: - Removes the trailing end of line marker \c "\r\n" from the last CSV field. -: 103: -: 104: \dontinclude test_CSV.cpp -: 105: \skipline test::setData() -: 106: \until }} -: 107: \see test_CSV::test_setData() -: 108:*/ -: 109:#endif -: 110: -: 111:// }; // namespace csv -: 112: -: 113:#ifdef English_dox -: 114:/// Defined by the C++ standard library -: 115:namespace std { } // trick to include it into the Doxygen documentation -: 116:#endif -: 117: -: 118:#endif -: 119: -: 120:// EOF: CSV_line.h