本文整理汇总了C++中Book类的典型用法代码示例。如果您正苦于以下问题:C++ Book类的具体用法?C++ Book怎么用?C++ Book使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Book类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: executeAsTransaction
bool BooksDB::saveBookStateStack(const Book &book, const std::deque<ReadingState> &stack) {
if (!isInitialized() || book.bookId() == 0) {
return false;
}
mySaveBookStateStack->setState(book.bookId(), stack);
return executeAsTransaction(*mySaveBookStateStack);
}
示例2: main
int main()
{
Book* book = xlCreateBook();
if(book)
{
Font* font = book->addFont();
font->setName(L"Impact");
font->setSize(36);
Format* format = book->addFormat();
format->setAlignH(ALIGNH_CENTER);
format->setBorder(BORDERSTYLE_MEDIUMDASHDOTDOT);
format->setBorderColor(COLOR_RED);
format->setFont(font);
Sheet* sheet = book->addSheet(L"Custom");
if(sheet)
{
sheet->writeStr(2, 1, L"Format", format);
sheet->setCol(1, 1, 25);
}
if(book->save(L"format.xls"))
{
::ShellExecute(NULL, L"open", L"format.xls", NULL, NULL, SW_SHOW);
}
}
return 0;
}
示例3: getPatron
/*******************************************************
**requestBook Description:
** if the specified Book is not in the Library, return
** "book not found"
** if the specified Patron is not in the Library, return
** "patron not found"
** if the specified Book is already requested by another
** Patron, return "book on hold by other patron"
** update the Book's requestedBy; if the Book is on the
** shelf, update its location to on hold; return
** "request successful"
*******************************************************/
string Library::requestBook(std::string pID, std::string bID)
{
//find if Book exists//
if (getBook(bID) == NULL)
return "Book not found.";
//find if Patron exists//
if (getPatron(pID) == NULL)
return "Patron not found.";
//set Book's requestedBy and/or location//
//based on current location//
if (getBook(bID)->getLocation() == ON_HOLD_SHELF)
return "Book on hold by another Patron.";
else
{
//initiate local pointers if Book is not already on hold//
Patron* pPtr = getPatron(pID);
Book* bPtr = getBook(bID);
//set Book's requestedBy and location//
bPtr->setRequestedBy(pPtr);
if (bPtr->getLocation() == ON_SHELF)
{
bPtr->setLocation(ON_HOLD_SHELF);
}
//request was successful//
return "Request successful.";
}
}
示例4:
bool operator ==(const Book& other) {
if(this->getTitle()==other.getTitle()&&this->getBookLength()
==other.getBookLength()) {
return true;
} else
return false;
}
示例5: Generate
std::string InventoryReport::Generate() {
ClassificationService classificationService;
vector<Record> records;
vector<Holding>* holdings = Catalog::Holdings();
for (vector<Holding>::iterator it = holdings->begin();
it != holdings->end();
it++)
{
Holding holding = *it;
Book book = classificationService.RetrieveDetails(holding.Classification());
if (book.Type() == Book::TYPE_BOOK)
{
Record record(book, holding.CurrentBranch().Name(), mIsbnApi);
records.push_back(record);
}
}
sort(records.begin(), records.end());
stringstream buffer;
AppendHeader(buffer);
AppendColumnHeaders(buffer);
for (vector<Record>::iterator it = records.begin(); it != records.end();it++)
Append(buffer, *it);
AppendFooter(buffer);
return buffer.str();
}
示例6: findBook
// Finds successor to a book
// Finds the book, gets the book with max value for the right sub-tree
Book* Library::successor(double price, Book *book) {
Book* tmp = findBook(price, book);
if ( tmp ) {
return max(tmp->getRight(tmp));
}
return 0;
}
示例7: deleteFromBookList
bool BooksDB::deleteFromBookList(const Book &book) {
if (book.bookId() == 0) {
return false;
}
((DBIntValue&)*myDeleteBookList->parameter("@book_id").value()) = book.bookId();
return myDeleteBookList->execute();
}
示例8: scope
void BookWrap::Each(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
HandleScope scope(isolate);
Book* book = ObjectWrap::Unwrap<BookWrap>(args.This())->m_book;
if (args.Length() == 1) {
if (args[0]->IsFunction()) {
Local<Function> fun = Local<Function>::Cast(args[0]);
for(uint32_t i = 0; i < book->size(); ++i) {
Local<Object> pw = PersonWrap::New(isolate, book, i);
Local<Value> argv[1] = { pw };
fun->Call(Null(isolate), 1, argv);
}
args.GetReturnValue().SetUndefined();
return;
}
else {
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "Function expected")));
args.GetReturnValue().SetUndefined();
return;
}
}
else {
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "One argument expected")));
args.GetReturnValue().SetUndefined();
return;
}
}
示例9: ExportAnyData
int ExportAnyData(CString filename, vector<string> &orders)
{
Book* book = xlCreateBook();
if(!book)
return 0;
for(vector<string>::iterator it = orders.begin(); it != orders.end(); it++)
{
CString Filename = it->c_str();
Filename += ".xml";
TiXmlElement *Root = getXMLRoot(Filename);
Sheet* sheet = book->addSheet(it->c_str());
if(!sheet)
return 0;
addOneSheet(sheet, Root);
delete Root->GetDocument();
}
if(book->save(_T(filename.GetBuffer(0)) ))
{
return 1;
}
else
{
return 0;
}
book->release();
}
示例10: detectLanguage
void FormatPlugin::detectLanguage(Book &book, ZLInputStream &stream) {
std::string language = book.language();
if (!language.empty()) {
return;
}
PluginCollection &collection = PluginCollection::Instance();
if (language.empty()) {
language = collection.DefaultLanguageOption.value();
}
if (collection.LanguageAutoDetectOption.value() && stream.open()) {
static const int BUFSIZE = 65536;
char *buffer = new char[BUFSIZE];
const size_t size = stream.read(buffer, BUFSIZE);
stream.close();
shared_ptr<ZLLanguageDetector::LanguageInfo> info =
ZLLanguageDetector().findInfo(buffer, size);
delete[] buffer;
if (!info.isNull()) {
if (!info->Language.empty()) {
language = info->Language;
}
}
}
book.setLanguage(language);
}
示例11: GetBook
//Puts a book on the hold shelf, unless it is already requested.
//If checked out, note that it should go to the hold shelf
void Library::requestBook(std::string patronID, std::string bookID)
{
Book* book = GetBook(bookID);
Patron* patron = GetPatron(patronID);
if(book == NULL || patron == NULL)
{
if(book == NULL)
{
std::cout << std::endl << "No such book in holdings." << std::endl;
}
if(patron == NULL)
{
std::cout << std::endl << "No such patron in records." << std::endl;
}
return;
}
if(book->getRequestedBy() == NULL)
{
book->setRequestedBy(patron);
if(book->getLocation() == ON_SHELF)
{
book->setLocation(ON_HOLD);
}
}
else
{
std::cout << "This book is already requested!";
}
}
示例12: detectLanguage
bool FormatPlugin::detectLanguage(Book &book, ZLInputStream &stream, const std::string &encoding, bool force) {
std::string language = book.language();
if (!force && !language.empty()) {
return true;
}
bool detected = false;
PluginCollection &collection = PluginCollection::Instance();
if (collection.isLanguageAutoDetectEnabled() && stream.open()) {
static const int BUFSIZE = 65536;
char *buffer = new char[BUFSIZE];
const std::size_t size = stream.read(buffer, BUFSIZE);
stream.close();
shared_ptr<ZLLanguageDetector::LanguageInfo> info =
ZLLanguageDetector().findInfoForEncoding(encoding, buffer, size, -20000);
delete[] buffer;
if (!info.isNull()) {
detected = true;
if (!info->Language.empty()) {
language = info->Language;
}
}
}
book.setLanguage(language);
return detected;
}
示例13: insertIntoBookList
bool BooksDB::insertIntoBookList(const Book &book) {
if (book.bookId() == 0) {
return false;
}
((DBIntValue&)*myInsertBookList->parameter("@book_id").value()) = book.bookId();
return myInsertBookList->execute();
}
示例14: detectEncodingAndLanguage
void FormatPlugin::detectEncodingAndLanguage(Book &book, ZLInputStream &stream) {
std::string language = book.language();
std::string encoding = book.encoding();
if (!encoding.empty() && !language.empty()) {
return;
}
PluginCollection &collection = PluginCollection::Instance();
if (language.empty()) {
language = collection.DefaultLanguageOption.value();
}
if (encoding.empty()) {
encoding = collection.DefaultEncodingOption.value();
}
if (collection.LanguageAutoDetectOption.value() && stream.open()) {
static const int BUFSIZE = 65536;
char *buffer = new char[BUFSIZE];
const size_t size = stream.read(buffer, BUFSIZE);
stream.close();
shared_ptr<ZLLanguageDetector::LanguageInfo> info =
ZLLanguageDetector().findInfo(buffer, size);
delete[] buffer;
if (!info.isNull()) {
if (!info->Language.empty()) {
language = info->Language;
}
encoding = info->Encoding;
if ((encoding == "US-ASCII") || (encoding == "ISO-8859-1")) {
encoding = "windows-1252";
}
}
}
book.setEncoding(encoding);
book.setLanguage(language);
}
示例15: main
int main()
{
Book book;
book.print();
return 0;
}