| 49 | }; |
| 50 | |
| 51 | void processMessage(bbg::Message &msg, InstrumentListResults &matches, const bool verbose) { |
| 52 | bbg::Element response = msg.asElement(); |
| 53 | if (verbose) response.print(Rcpp::Rcout); |
| 54 | if (std::strcmp(response.name().string(),"InstrumentListResponse")) { |
| 55 | throw std::logic_error("Not a valid InstrumentListResponse."); |
| 56 | } |
| 57 | |
| 58 | bbg::Element data = response.getElement("results"); |
| 59 | int numItems = data.numValues(); |
| 60 | if (verbose) { |
| 61 | Rcpp::Rcout <<"Response contains " << numItems << " items" << std::endl; |
| 62 | Rcpp::Rcout <<"security\t\tdescription" << std::endl; |
| 63 | } |
| 64 | |
| 65 | for (int i = 0; i < numItems; ++i) { |
| 66 | bbg::Element item = data.getValueAsElement(i); |
| 67 | std::string security = item.getElementAsString(SECURITY); |
| 68 | std::string description = item.getElementAsString(DESCRIPTION); |
| 69 | if (verbose) { |
| 70 | Rcpp::Rcout << security << "\t\t" << description << std::endl; |
| 71 | } |
| 72 | matches.security.push_back(security); |
| 73 | matches.description.push_back(description); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | void processResponseEvent(bbg::Event &event, InstrumentListResults &matches, const bool verbose) { |
| 78 | bbg::MessageIterator msgIter(event); |
no outgoing calls
no test coverage detected