Example #1
0
 pusher_t(const logger_type& log, record_t& record, Args&&... args) :
     log(log),
     record(record)
 {
     //!@todo: Catch exceptions from message inline formatting.
     record.insert(
         keyword::message() =
             aux::format(record.attributes(), std::forward<Args>(args)...)
     );
 }
Example #2
0
void SqliteDB::insertRecord(
			record_t &data,
			const QString &tablename)
{
	QStringList hdr = data.keys();
	QString fields;
	QString values;

	fields.append("(");
	values.append("(");
	QMapIterator<QString, QString> iter(data);
	while(iter.hasNext()){
		iter.next();
		fields.append(iter.key()+",");
		QString temp = QString(iter.value());
		values.append("\'"+temp.replace("'", "''")+"\',");
	}
	fields.remove(fields.size()-1, 1);
	values.remove(values.size()-1, 1);
	fields.append(")");
	values.append(")");

	QString statement = "INSERT INTO ";
	statement.append( tablename );
	statement.append( fields );
	statement.append(" VALUES ");
	statement.append( values );

	exec(statement);
}
Example #3
0
 std::string format(const record_t& record) const {
     std::string buffer;
     stickystream_t stream;
     stream.attach(buffer);
     try {
         string::visitor_t visitor(stream, mapper, record.attributes());
         for (auto it = tokens.begin(); it != tokens.end(); ++it) {
             boost::apply_visitor(visitor, *it);
             stream.flush();
         }
         return buffer;
     } catch (const error_t& err) {
         throw error_t("bad format string '%s': %s", pattern, err.what());
     }
 }
Example #4
0
void SqliteDB::updateRecord(
			record_t &data,
			const QString &cond,
			const QString &tablename)
{
	QStringList hdr = data.keys();
	QString values;
	QMapIterator<QString, QString> iter(data);
	while(iter.hasNext()){
		iter.next();
		QString temp = QString(iter.value());
		values.append(iter.key()+"=\'"+temp.replace("'", "''")+"\',");
	}
	values.remove(values.size()-1, 1);

	QString statement = "UPDATE ";
	statement.append( tablename );
	statement.append(" SET ");
	statement.append( values );
	statement.append(" WHERE ");
	statement.append( cond );

	exec(statement);
}
Example #5
0
 void handle(const record_t& record) {
     this->sink.consume(this->formatter.format(record), record.attributes());
 }