数据转换解决方案

时间:2014-01-09 08:42:18

标签: c++

今天我尝试为我发送的消息设计时间戳,我在函数中使用的代码如下:

void MainWindow::buttonClickHandler()
{
    QString qs;
    qs=ui->lineEdit->text();
    std::string m_text=qs.toStdString();
    //std::string m_text = ui->lineEdit->text();
        // Customized message
    long long startTime = System::currentTimeMillis();    
    try{
            std::auto_ptr<TextMessage> message(m_IfacomMessageBroker->getSession()->createTextMessage(m_text));
            //message->setCMSTimestamp(System::currentTimeMillis());

            //m_IfacomMessageBroker->sendMessage(message);
             m_IfacomMessageBroker->sendMessage("test");
            long long ltest = m_IfacomAmqProducer->getSenderTimestamp(message);
            QDateTime *dt = new QDateTime();
            dt->setMSecsSinceEpoch(ltest);
            QString qtstring1 = dt->toString("dd.MM.yyyy hh:mm:ss.zzz");
        } catch (CMSException& e) {
            e.printStackTrace();

    }

        long long endTime = System::currentTimeMillis();
        double totalTime = (double)(endTime - startTime) / 1000.0;
}
void MainWindow::on_pushButton_3_clicked()
{
   m_IfacomMessageBroker->close();
}

当我尝试构建解决方案时,出现此错误:

Error   12  error C2664: 'IfacomAmqSender::getSenderTimestamp' : cannot convert   parameter 1 from 'std::auto_ptr<_Ty>' to 'const cms::Message *'   C:\Users\Marco\Desktop\Activemq\ReleaseVersions\GUI-CMS-SENDER\mainwindow.cpp   105 1   GUI-CMS-SENDER

但奇怪的是我在另一个.cpp文件中没有问题地使用这个函数!!!

1 个答案:

答案 0 :(得分:2)

m_IfacomAmqProducer->getSenderTimestamp(message.get())