Commit 25760566 by dahlan

addBooks written - untested

parent 8f3813a4
......@@ -7,9 +7,9 @@
#include "Book.h"
Book::Book(string Title = "", string Publisher = "", string ISBN = "",
int Year = 0, float Price = 0.0, int Stock = 0, string Auth1 = "",
string Auth2 = "", string Auth3 = "", string Auth4 = "")
Book::Book(string Title, string Publisher, string ISBN,
int Year, float Price, int Stock, string Auth1,
string Auth2, string Auth3, string Auth4)
{
this->title = Title;
this->publisher = Publisher;
......@@ -197,37 +197,37 @@ bool Book::setYear(int Year)
}
bool Book::operator >= (const bookType & rhs) const
bool Book::operator >= (const Book & rhs) const
{
//TODO: Finish This...
return false;
}
bool Book::operator == (const bookType & rhs) const
bool Book::operator == (const Book & rhs) const
{
//TODO: Finish This...
return false;
}
bool Book::operator <= (const bookType & rhs) const
bool Book::operator <= (const Book & rhs) const
{
//TODO: Finish This...
return false;
}
bool Book::operator < (const bookType & rhs) const
bool Book::operator < (const Book & rhs) const
{
//TODO: Finish This...
return false;
}
bool Book::operator != (const bookType & rhs) const
bool Book::operator != (const Book & rhs) const
{
//TODO: Finish This...
return false;
}
bool Book::operator > (const bookType & rhs) const
bool Book::operator > (const Book & rhs) const
{
//TODO: Finish This...
return false;
......
......@@ -67,12 +67,12 @@ public:
void print(ofstream & outs) const;
bool operator >= (const bookType & rhs) const;
bool operator == (const bookType & rhs) const;
bool operator <= (const bookType & rhs) const;
bool operator < (const bookType & rhs) const;
bool operator != (const bookType & rhs) const;
bool operator > (const bookType & rhs) const;
bool operator >= (const Book & rhs) const;
bool operator == (const Book & rhs) const;
bool operator <= (const Book & rhs) const;
bool operator < (const Book & rhs) const;
bool operator != (const Book & rhs) const;
bool operator > (const Book & rhs) const;
};
#endif /* BOOK_H_ */
......@@ -33,13 +33,13 @@ int main(int const, const char ** const)
xmlrpc_c::methodPtr const updateBookMethodP(new updateBookMethod);
xmlrpc_c::methodPtr const listBooksMethodP(new listBooksMethod);
myRegistry.addMethod("getBook", addBookMethodP);
myRegistry.addMethod("addBook", addBookMethodP);
myRegistry.addMethod("deleteBook", deleteBookMethodP);
myRegistry.addMethod("searchBook", searchBookMethodP);
myRegistry.addMethod("updateBook", updateBookMethodP);
myRegistry.addMethod("listBooks", listBooksMethodP);
xmlrpc_c::serverAbyss myAbyssServer(xmlrpc_c::serverAbyss::constrOpt().registryP(&myRegistry).portNumber(8081).uriPath("/"));
xmlrpc_c::serverAbyss myAbyssServer(xmlrpc_c::serverAbyss::constrOpt().registryP(&myRegistry).portNumber(8081));
myAbyssServer.run();
// xmlrpc_c::serverAbyss.run() never returns
......
......@@ -17,6 +17,9 @@
#ifndef XMLRPC_SERVERMETHODS__
#define XMLRPC_SERVERMETHODS__
#include <string>
#include <vector>
#include <map>
#include "Book.h"
using namespace std;
......@@ -40,6 +43,55 @@ public:
*/
void execute(xmlrpc_c::paramList const& paramList, xmlrpc_c::value * const retvalP)
{
cerr << "addBookMethod Called" << endl;
map<string, xmlrpc_c::value> data = paramList.getStruct(0);
paramList.verifyEnd(1);
string title = xmlrpc_c::value_string(data.at("title"));
xmlrpc_c::value_array author_arrays = xmlrpc_c::value_array(data.at("author"));
vector<xmlrpc_c::value> author = author_arrays.vectorValueValue();
string publisher = xmlrpc_c::value_string(data.at("publisher"));
string isbn = xmlrpc_c::value_string(data.at("isbn"));
int number_of_authors = xmlrpc_c::value_int(data.at("number_of_authors"));
int publication_year = xmlrpc_c::value_int(data.at("publication_year"));
int stock = xmlrpc_c::value_int(data.at("stock"));
float price = xmlrpc_c::value_double(data.at("price"));
cout << title << endl;
//Book book;
switch(number_of_authors)
{
case 1:
{
Book book(title,publisher,isbn,publication_year,price,stock,static_cast<string>(static_cast<xmlrpc_c::value_string>(author[0])));
break;
}
case 2:
{
Book book(title,publisher,isbn,publication_year,price,stock,static_cast<string>(static_cast<xmlrpc_c::value_string>(author[0])),static_cast<string>(static_cast<xmlrpc_c::value_string>(author[1])));
break;
}
case 3:
{
Book book(title,publisher,isbn,publication_year,price,stock,static_cast<string>(static_cast<xmlrpc_c::value_string>(author[0])),static_cast<string>(static_cast<xmlrpc_c::value_string>(author[1])),static_cast<string>(static_cast<xmlrpc_c::value_string>(author[2])));
break;
}
case 4:
{
Book book(title,publisher,isbn,publication_year,price,stock,static_cast<string>(static_cast<xmlrpc_c::value_string>(author[0])),static_cast<string>(static_cast<xmlrpc_c::value_string>(author[1])),static_cast<string>(static_cast<xmlrpc_c::value_string>(author[2])),static_cast<string>(static_cast<xmlrpc_c::value_string>(author[3])));
break;
}
default:
{
Book book(title,publisher,isbn,publication_year,price,stock);
break;
}
}
*retvalP = xmlrpc_c::value_boolean(true);
//TODO: EVERYTHING
}
};
......
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