public method IO2GOrdersTableResponseReader.getRow

Brief

Gets a row from the Orders table.

Declaration
C++
virtual IO2GOrderRow 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 Orders table [hide]

    // Get orders information
    void getOrders(IO2GSession *session, ResponseListener *responseListener, std::string account)
    {
        O2G2Ptr<IO2GRequestFactory> requestFactory = session->getRequestFactory();
        if (requestFactory)
        {
            O2G2Ptr<IO2GRequest> request = requestFactory->createRefreshTableRequestByAccount(Orders, account.c_str());
            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() == GetOrders && mRequestID == requestId)
        {
            O2G2Ptr<IO2GResponseReaderFactory> readerFactory = mSession->getResponseReaderFactory();
            if (readerFactory)
            {
                O2G2Ptr<IO2GOrdersTableResponseReader> reader = readerFactory->createOrdersTableReader(response);
                for (int i = 0; i < reader->size(); ++i)
                {
                    O2G2Ptr<IO2GOrderRow> order = reader->getRow(i);
                    std::cout << "OrderID: " << order->getOrderID() <<
                                " Amount = " << order->getAmount() <<
                                " BuySell = " << order->getBuySell() << 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 IO2GOrdersTableResponseReader

back