Commit 026819d4 by Andrew Dahl

listBooks function written and tested

parent 64b85b09
......@@ -23,7 +23,6 @@ string getISBN()
cout << "Enter the ISBN:";
getline(cin,isbn);
//cin.getline(isbn,255,'\n');
cout << "\n\n";
return isbn;
......@@ -150,19 +149,14 @@ int main(int argc, char **)
}
else if(choice == 4)
{
// xmlrpc_c::value result;
// simpClient.call(serverUrl, listBooks, "n", &result);
/*
cout << "getBooks() Returned \n";
books = db.getBooks();
for(int i = 0; i < books.size(); i++)
{
cout << books[i] << "\n";
}
books.clear();
*/
cout << "Not Implemented Yet... Come back tomorrow\n\n";
xmlrpc_c::rpcPtr listRPC(listBooks, params);
listRPC->call(&myClient, &myCarriageParm);
assert(listRPC->isFinished());
vector<Book> bookList = bookHandle.valueToVector(listRPC->getResult());
for(int i = 0; i < bookList.size(); i++)
cout << "Book " << i+1 << ": \n" << bookList[i] << "\n\n";
}
else if(choice == 5)
{
......
......@@ -26,9 +26,7 @@ Book BookHandler::paramListToBook(xmlrpc_c::paramList const& paramList)
size = 4;
for(size--; size >= 0; size--)
{
authors[size] = xmlrpc_c::value_string(author_values[size]);
}
return Book(xmlrpc_c::value_string(data.at(XML_TITLE)), // Title
xmlrpc_c::value_string(data.at(XML_PUBLISHER)), // Publisher
......@@ -52,9 +50,7 @@ Book BookHandler::valueToBook(xmlrpc_c::value value)
size = 4;
for(size--; size >= 0; size--)
{
authors[size] = xmlrpc_c::value_string(author_values[size]);
}
return Book(xmlrpc_c::value_string(data.at(XML_TITLE)), // Title
......@@ -79,9 +75,7 @@ map<string, xmlrpc_c::value> BookHandler::bookToMap(Book myBook)
vector<xmlrpc_c::value> authors;
for(int i = 0; i < myBook.getNumberOfAuthors(); i++)
{
authors.push_back(xmlrpc_c::value_string(myBook.getAuthor(i)));
}
pair<string, xmlrpc_c::value> authorPair(XML_AUTHORS, xmlrpc_c::value_array(authors));
......@@ -104,3 +98,14 @@ vector<xmlrpc_c::value> BookHandler::bookListToVector(vector<Book> bookList)
return xmlList;
}
vector<Book> BookHandler::valueToVector(xmlrpc_c::value value)
{
vector<Book> bookList;
vector<xmlrpc_c::value> valueList = xmlrpc_c::value_array(value).vectorValueValue();
for(int i = 0; i < valueList.size(); i++)
bookList.push_back(this->valueToBook(valueList[i]));
return bookList;
}
......@@ -28,6 +28,8 @@ public:
map<string, xmlrpc_c::value> bookToMap(Book myBook);
vector<xmlrpc_c::value> bookListToVector(vector<Book> bookList);
vector<Book> valueToVector (xmlrpc_c::value value);
};
#endif /* BOOKHANDLER_H_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment