bool CSVTemplate::validate(const CSVRow& row, int startindex) const { if (!_layout && _count!=row.inRange(startindex, startindex+_count)) { //printf("%s: count mismatch; _c: %lu inr: %lu\n", __PRETTY_FUNCTION__, _count, row.inRange(startindex, startindex+_count)); return false; } if (_layout) { int index=startindex; CSVRecordMap::const_iterator iter; CSVRecordMap::const_iterator end=row.end(); while ((size_t)index<_count) { iter=row.find(index); if (iter!=end) { if (iter->second && !(_layout[index].type&iter->second->getType())) { //printf("debug: %s: [%d] non-matching type\n", __PRETTY_FUNCTION__, index); return false; } else if (!iter->second && !_layout[index].nullable) { // not nullable; is null //printf("debug: %s: [%d] not nullable; null\n", __PRETTY_FUNCTION__, index); return false; } } else if (!_layout[index].nullable) { // not nullable; is unset //printf("debug: %s: [%d] not nullable; unset\n", __PRETTY_FUNCTION__, index); return false; } index++; } } // else count==rangecount and that's all that the template requires for validation return true; }
void AbstractFileSource::display(const CSVRow& row) { if(!row.size()) return; CSVRowCI i=row.begin(); std::cout<<*(i++); for(;i != row.end();++i) std::cout<<','<<*i; };
void ExcludeCommand :: Exclude( CSVRow & r ) const { CSVRow out; if ( mReverse ) { std::reverse( r.begin(), r.end() ); } for ( unsigned int i = 0; i < r.size(); i++ ) { if ( ! ALib::Contains( mFields, i ) ) { out.push_back( r.at( i ) ); } } if ( mReverse ) { std::reverse( out.begin(), out.end() ); } r.swap( out ); }
void CSVFormatter::formatRow(const CSVRow& row, UnicodeString& result, UChar32 sepchar, unsigned int varformat) { result.remove(); UnicodeString formatted; int lastcolumn=0; CSVRecordMap::const_iterator iter; for (iter=row.begin(); iter!=row.end(); ++iter) { for (; lastcolumn<iter->first; ++lastcolumn) { result.append(sepchar); } if (iter->second) { iter->second->getValueFormatted(formatted, varformat); // result.append(iter->second->getTypeName()); // result.append(':'); result.append(formatted); //} else { // result.append("[null]"); } } }