public method IO2GTradesTableResponseReader.getRow

Brief

Gets a row from the Trades table.

Declaration
C++
virtual IO2GTradeRow getRow (int index) = 0

Parameters
index

The index of the row. The index must be between 0 and size() - 1.

Details

If the row is not found, the method returns null.

Example

Get rows from the Trades table [hide]

    // Get trades information
    void getTrades(IO2GSession *session, ResponseListener *responseListener)
    {
        O2G2Ptr<IO2GRequestFactory> requestFactory = session->getRequestFactory();
        if (requestFactory)
        {
            O2G2Ptr<IO2GRequest> request = requestFactory->createRefreshTableRequest(Trades);
            if (request)
            {
                responseListener->setRequest(request->getRequestID());
                session->sendRequest(request);
                uni::WaitForSingleObject(responseListener->getResponseEvent(), INFINITE);
            }
        }
    }
 
    void ResponseListener::setRequest(const char * requestId)
    {
        mRequestID = requestId;
    }
 
    HANDLE ResponseListener::getResponseEvent()
    {
        return mResponseEvent;
    }
 
    // Implementation of IO2GResponseListener interface public method onRequestCompleted
    void ResponseListener::onRequestCompleted (const char *requestId, IO2GResponse *response = NULL)
    {
        if (response && response->getType() == GetTrades && mRequestID == requestId)
        {
            O2G2Ptr<IO2GResponseReaderFactory> readerFactory = mSession->getResponseReaderFactory();
            if (readerFactory)
            {
                O2G2Ptr<IO2GTradesTableResponseReader> reader = readerFactory->createTradesTableReader(response);
                for (int i = 0; i < reader->size(); ++i)
                {
                    O2G2Ptr<IO2GTradeRow> trade = reader->getRow(i);
                    std::cout << "TradeID = " << trade->getTradeID() <<
                                 " OfferID = " <<  trade->getOfferID() <<
                                 " Amount= " << trade->getAmount() << std::endl;
                }
            }
            uni::SetEvent(mResponseEvent);
        }
    }
 
    // Implementation of IO2GResponseListener interface public method onRequestFailed
    void ResponseListener::onRequestFailed (const char * requestId, const char * error)
    {
        if (mRequestID == requestId)
        {
            std::cerr << "Request " << mRequestID << " failed: " << error << std::endl;
            uni::SetEvent(mResponseEvent);
        }
    }

Declared in IO2GTradesTableResponseReader

back