Book.h


The file Book.h is a re-implementation of the class Book by adding two more methods:
~wenchen/public_html/cgi-bin/351/week5/Book.h

#include  <cstdlib>
  using namespace  std;

class  Book {
  public:
    char*  PrintTitle( ) { return( title ); };
    bool   Unpack( TextBuffer& );
  private:
    char   title[128];
    char   ISBN[12];
    char   authors[128];
    char   price[8];
    int    quantity;
};


bool  Book::Unpack( TextBuffer& buffer ) {
  char  temp[6];

  if ( !buffer.Unpack( title,   "<title>",    "</title>"    ) )
    return( false );
  if ( !buffer.Unpack( ISBN,    "<ISBN>",     "</ISBN>"     ) )
    return( false );
  if ( !buffer.Unpack( authors, "<authors>",  "</authors>"  ) )
    return( false );
  if ( !buffer.Unpack( price,   "<price>",    "</price>"    ) )
    return( false );
  if ( !buffer.Unpack( temp,    "<quantity>", "</quantity>" ) )
    return( false );
  quantity = atoi( temp );
  return( true );
}

int atoi( const char * string ); converts string to integer.