MCPcopy Index your code
hub / github.com/Audio4Linux/JDSP4Linux / read

Method read

3rdparty/qtcsv-qt5/sources/reader.cpp:92–176  ·  view source on GitHub ↗

Function that really reads csv-data and transfer it's data to AbstractProcessor-based processor @input: - ioDevice - IO Device containing the csv-formatted data - processor - refernce to AbstractProcessor-based object - separator - string or character that separate values in a row - textDelimiter - string or character that enclose row elements - codec - pointer to codec object that would be used f

Source from the content-addressed store, hash-verified

90// @output:
91// - bool - result of read operation
92bool ReaderPrivate::read(
93 QIODevice& ioDevice,
94 Reader::AbstractProcessor& processor,
95 const QString& separator,
96 const QString& textDelimiter,
97 QTextCodec* codec)
98{
99 if (false == checkParams(separator)) { return false; }
100
101 // Open IO Device if it was not opened
102 if (false == ioDevice.isOpen() &&
103 false == ioDevice.open(QIODevice::ReadOnly))
104 {
105 qDebug() << __FUNCTION__ << "Error - failed to open IO Device";
106 return false;
107 }
108
109 QTextStream stream(&ioDevice);
110 stream.setCodec(codec);
111
112 // This list will contain elements of the row if its elements
113 // are located on several lines
114 QStringList row;
115
116 ElementInfo elemInfo;
117 bool result = true;
118 while (false == stream.atEnd())
119 {
120 QString line = stream.readLine();
121 processor.preProcessRawLine(line);
122 QStringList elements = ReaderPrivate::splitElements(
123 line, separator, textDelimiter, elemInfo);
124 if (elemInfo.isEnded)
125 {
126 // Current row ends on this line. Check if these elements are
127 // end elements of the long row
128 if (row.isEmpty())
129 {
130 // No, these elements constitute the entire row
131 if (false == processor.processRowElements(elements))
132 {
133 result = false;
134 break;
135 }
136 }
137 else
138 {
139 // Yes, these elements should be added to the row
140 if (false == elements.isEmpty())
141 {
142 row.last().append(elements.takeFirst());
143 row << elements;
144 }
145
146 if (false == processor.processRowElements(row))
147 {
148 result = false;
149 break;

Callers

nothing calls this directly

Calls 5

readLineMethod · 0.80
appendMethod · 0.80
isEmptyMethod · 0.45
processRowElementsMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected