Beispiel #1
0
String indentString(String str, int indentamount) {
	String s("");
	if (str) {
		if (indentamount > 0) {
			s = repeatString(" ", 5);
			unsigned int i = 0;
			unsigned int n = 0;
			int _indx = 0;
			while (i < str.length()) {
				_indx = str.indexOf("\r\n", i);		// find the next CRLF
				if (_indx >= 0) {
					n = static_cast<unsigned int>(_indx);
					s += str.substring(i, n + 2);	// extract the portion up and including the CRLF
					s += repeatString(" ", 5);		// add indent (after the CRLF)
					i = n + 2;		// move the index to the character just after the CRLF and keep looking
				}
				else {
					return str; // Should not be <0. Something might be wrong. Return the original string.
				}
			}
		}
		else {
			s = str;
		}
	}
	/* As a basic check to see if something might have gone wrong, make sure
	 * the resultant string not less then the input string. Indenting should
	 * make the resultant string larger. An error must have occurred if it's
	 * smaller. Return the original string in case of potential errors.
	 */
	if (s.length() < str.length()) return str;
	return s;
}
Beispiel #2
0
Query Query::valueInListCondition (const QString &column, const QList<QVariant> &values)
{
	Query query (notr ("%1 IN (%2)"));

	query.arg (column);
	query.arg (repeatString (notr ("?"), values.size (), notr (",")));

	foreach (const QVariant &value, values)
		query.bind (value);

	return query;
}