5 #define DEFAULT_ESCAPE_CHARACTER = '"'      6 #define DEFAULT_SEPARATOR = ','              7 #define DEFAULT_QUOTE_CHARACTER = '"'        8 #define NO_QUOTE_CHARACTER = '\u0000';       9 #define NO_ESCAPE_CHARACTER = '\u0000';     10 #define DEFAULT_LINE_END = "\n";            16 public class CSVWriter    35     CSVWriter(Writer writer, 
char separator, 
char quotechar, 
char escapechar, String lineEnd)
    37         this.pw = 
new PrintWriter(writer);
    38         this.separator = separator;
    39         this.quotechar = quotechar;
    40         this.escapechar = escapechar;
    41         this.lineEnd = lineEnd;
    53         if ( nextLine == NULL ) 
return;
    56         for ( 
int i = 0; i < nextLine.length(); ++i )
    58             if ( i != 0 ) sb.append(separator);
    60             QString nextElement = nextLine[i];
    61             if ( nextElement == NULL ) 
continue;
    64             for ( 
int j = 0; j < nextElement.length(); ++j )
    66                 char nextChar = nextElement.mid(j,1);
    68                      (nextChar   == quotechar)
    71                     sb.append(escapechar).append(nextChar);
    74                           ( nextChar == escapechar )
    77                     sb.append(escapechar).append(nextChar);
    88         pw.write(sb.toString());
   122 #endif // CSVWRITER_HPP char escapechar
Definition: csvwriter.hpp:119
#define DEFAULT_SEPARATOR
Definition: csvwriter.hpp:6
QString lineEnd
Definition: csvwriter.hpp:120
CSVWriter(Writer writer, char separator, char quotechar, char escapechar, String lineEnd)
Constructs CSVWriter with supplied separator, quote char, escape char and line ending. 
Definition: csvwriter.hpp:35
#define DEFAULT_QUOTE_CHARACTER
Definition: csvwriter.hpp:7
void close()
Close the underlying stream writer. 
Definition: csvwriter.hpp:108
#define DEFAULT_ESCAPE_CHARACTER
Definition: csvwriter.hpp:5
char quotechar
Definition: csvwriter.hpp:118
CSVWriter(Writer writer)
Definition: csvwriter.hpp:20
#define NO_QUOTE_CHARACTER
Definition: csvwriter.hpp:8
void flush()
Flush underlying stream to writer. 
Definition: csvwriter.hpp:96
PrintWriter pw
Definition: csvwriter.hpp:116
char separator
Definition: csvwriter.hpp:117
void writeNext(QString nextLine)
Writes the next line to the file. 
Definition: csvwriter.hpp:51
#define DEFAULT_LINE_END
Definition: csvwriter.hpp:10
#define NO_ESCAPE_CHARACTER
Definition: csvwriter.hpp:9