예제 #1
0
void ConvertAscii::writeTrack(TabTrack *trk, int n)
{
	QString tmp;

	startTrack(trk, n);
	startRow(trk);

	uint bar = 0;

	for (uint x = 0; x < trk->c.size(); x++) {

		// If this bar's not last
		if (bar + 1 < trk->b.size()) {
			if ((uint) trk->b[bar+1].start == x) {
				// Time for next bar
				bar++;
				flushBar(trk);
			}
		}

		addColumn(trk, &(trk->c[x]));
	}

	flushBar(trk);
	flushRow(trk);
}
예제 #2
0
void ConvertAscii::flushBar(TabTrack *trk)
{
	// Close bar with vertical pipe symbol
	for (int i = 0; i < trk->string; i++)
		bar[i] += '|';

	// If we won't overfill page width or if we have no bars yet, add
	// bar[] to row[]
	if (rowBars == 0 || (row[0].length() + bar[0].length() <= pageWidth)) {
		for (int i = 0; i < trk->string; i++) {
			row[i] += bar[i];
			bar[i] = "";
		}
		rowBars++;
	}

	// If we have to flush row, do it
	if (row[0].length() + bar[0].length() >= pageWidth) {
		flushRow(trk);
		startRow(trk);
	}

	// If we still have bar to flush, do it now
	if (bar[0].length() > 0) {
		for (int i = 0; i < trk->string; i++) {
			row[i] += bar[i];
			bar[i] = "";
		}
		rowBars++;
	}
}
예제 #3
0
void UpdateBean::act(AV& av, collection_nvp<E,S> nvp ){

	sqlid_t index=0;
	S& stream=nvp.stream;

	av.diveTable(nvp.name);
		std::string tab=av.getScope().table();
		while(!stream.done()){
			E& el=stream.getNext();
				sqlid_t entry_id=Database::allocId(av.getConnection(), tab);

				startRow(tab,entry_id, curRow()->id,index);
					sql_nvp<E> el_nvp("item",el);
					av & el_nvp;
				commitRow(av.getConnection(), entry_id);
			index++;
		}
	av.pop();
}
예제 #4
0
void UpdateBean::notifyInitWalk(AV& av)
{
	startRow(av.getScope().table(), av.getRootId(), Database::NULL_ID,0);
}
예제 #5
0
void ResultBuilder::build(const bool columnNames)
{
	if (mError==true) return;

	// Set up the columns
	try {
		const int	count = getColumnCount();
		if (count < 1) {
			// I think a count of 0 isn't technically an error, because the result set might just be empty.
			if (count < 0) mError = true;
			return;
		}
		for (int k=0; k<count; ++k) {
			const int	ct = getColumnType(k);
			if (ct == QUERY_NO_TYPE) mError = true;
			else mResult.mCol.push_back(ct);
			if (columnNames) {
				mResult.mColNames.push_back(getColumnName(k));
			}
		}
	} catch (std::exception&) {
		mError = true;
		return;
	}

	// Empty results are considered valid.
	if (!hasNext()) return;

	if (mError == true || mResult.mCol.size() < 1) {
		mError = true;
		return;
	}

	// Read the rows
	while (hasNext()) {
		startRow();
		for (int k=0; k<mResult.mCol.size(); k++) {
			const int		col = mResult.mCol.data()[k];
			if (col == QUERY_NUMERIC) {
				double		v = 0.0f;
				if (!getDouble(k, v)) mError = true;
				addNumeric(v);
			} else if (col == QUERY_STRING) {
				string		v;
				if (!getString(k, v)) mError = true;
				addString(v);
			} else if (col == QUERY_NULL) {
				// I can't determine at any point the actual type of the column,
				// because it looks like sqlite always bases that info on the first
				// row in the result set. So in this case, I've got to just get
				// every type.
				double		v = 0.0f;
				if (!getDouble(k, v)) v = 0.0f;
				addNumeric(v);

				--mColIdx;
				string		str;
				getString(k, str);
				addString(str);
			}
		}
		next();
	}
}