Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Books::cBook Class Reference

Item class for books. More...

#include <books.h>

List of all members.

Public Types

typedef std::vector< std::vector<
std::string > > 
tpages

Public Methods

void OpenBookReadOnly (NXWSOCKET s, P_ITEM book)
void OpenBookReadWrite (NXWSOCKET s, P_ITEM book)
 Sends to the client data for opening book in read/write mode.

void SendPageReadOnly (NXWSOCKET s, P_ITEM book, UI16 p)
 send to the specified client the page for reading only

void ChangeAuthor (char *auth)
 Change the book author.

void ChangeTitle (char *titl)
 Change the book title.

void ChangePages (char *packet, UI16 p, UI16 l, UI16 s)
 parse the 0x66 package replied by client for page changes

UI32 GetIndex () const
 < gets the book index

LOGICAL IsReadOnly () const
 < return true if books is readonly

void GetPages (tpages &pags) const
 < return the pages of the book

std::string GetAuthor () const
 < return the author of the book

std::string GetTitle () const
 < return the title of the book

UI32 GetNumPages () const
 < return the number of pages of the book

Constructors and operators
Author:
Akron


 cBook ()
 default constructor

 cBook (const cBook &oldbook)
 Copy constructor for cBook class.

 cBook (P_ITEM book)
 item constructor

 cBook (std::istream &s)
 constructor that read the book from stream (see cBooks::ReadFrom)

cBook & operator= (const cBook &oldbook)
 assignment operator=

Book Dump/Load functions
Author:
Akron These functions are used to write and read books from a file or, in general from a stream.
This mean that we can truly use files for store books, but also other streams, like string streams.


void DumpTo (std::ostream &s)
 write the book to a stream

bool ReadFrom (std::istream &s)
 read the book from a stream


Private Attributes

LOGICAL readonly
 if the book is loaded from script it must be true

std::string author
 author of the book

std::string title
 title of the book

tpages pages
 pages of the book

UI32 index
 index of the book


Static Private Attributes

UI32 books_index = 0
 1-based books counter


Detailed Description

Item class for books.

Author:
Akron (complete rewrite)
Todo:
create xss-based books

There are two types of books, read only books, defined by scripters, in this case they are loaded from xss scripts and read/write books, wrote in game, that are saved to a save file on disk.

Two books can have the same contents if it's defined by xss script, but not if they are read/write books.
For this reason, we need to duplicate the book's data if we are duping a book item, else we could have two books "linked" together, changing one, will change the other too.

a read/write book is defined on the file like that (without tabs identation obviously :P):

	SECTION RWBOOK index
	{
		AUTHOR author
		TITLE title
		PAGE
		{
			LINE blablabla
			LINE bblalblal
		}
		PAGE
		{
			LINE blablabla
		}
		PAGE
		{
			LINE blablabla
		}
	}
	


Member Typedef Documentation

typedef std::vector< std::vector<std::string> > Books::cBook::tpages
 


Constructor & Destructor Documentation

Books::cBook::cBook  
 

default constructor

Books::cBook::cBook const cBook &    oldbook
 

Copy constructor for cBook class.

Parameters:
oldbook  old book to copy the data from

Books::cBook::cBook P_ITEM    book
 

item constructor

Parameters:
book  pointer to the book item to bound the book to

Books::cBook::cBook std::istream &    s
 

constructor that read the book from stream (see cBooks::ReadFrom)

Parameters:
s  reference to the istream to read the book from


Member Function Documentation

void Books::cBook::ChangeAuthor char *    auth
 

Change the book author.

Author:
Akron
Parameters:
auth  new author of the book

void Books::cBook::ChangePages char *    packet,
UI16    p,
UI16    l,
UI16    size
 

parse the 0x66 package replied by client for page changes

Author:
Akron
Parameters:
packet  pointer to packet got from socket
p  index of page to change
l  lines to process
size  size of the packet buffer

void Books::cBook::ChangeTitle char *    titl
 

Change the book title.

Author:
Akron
Parameters:
titl  new title of the book

void Books::cBook::DumpTo std::ostream &    s
 

write the book to a stream

Author:
Akron
Parameters:
s  reference to the ostream where to dump the book

std::string Books::cBook::GetAuthor   const [inline]
 

< return the author of the book

UI32 Books::cBook::GetIndex   const [inline]
 

< gets the book index

UI32 Books::cBook::GetNumPages   const [inline]
 

< return the number of pages of the book

void Books::cBook::GetPages tpages   pags const [inline]
 

< return the pages of the book

std::string Books::cBook::GetTitle   const [inline]
 

< return the title of the book

LOGICAL Books::cBook::IsReadOnly   const [inline]
 

< return true if books is readonly

void Books::cBook::OpenBookReadOnly NXWSOCKET    s,
P_ITEM    book
 

void Books::cBook::OpenBookReadWrite NXWSOCKET    s,
P_ITEM    book
 

Sends to the client data for opening book in read/write mode.

Author:
Akron
Parameters:
s  socket to send the book to
book  pointer to book item
Note:
it sends a lot of data to client....

cBook & Books::cBook::operator= const cBook &    oldbook
 

assignment operator=

bool Books::cBook::ReadFrom std::istream &    s
 

read the book from a stream

Todo:
complete reading
Parameters:
s  reference to the istream to read the book from

void Books::cBook::SendPageReadOnly NXWSOCKET    s,
P_ITEM    book,
UI16    p
 

send to the specified client the page for reading only

Author:
Akron
Parameters:
s  socket to send the book page
book  pointer to book item
p  index of page to send


Member Data Documentation

std::string Books::cBook::author [private]
 

author of the book

UI32 Books::cBook::books_index = 0 [static, private]
 

1-based books counter

UI32 Books::cBook::index [private]
 

index of the book

Note:
When creating new books, it should be greater than cBook::books counter.
Needed for get informations about the book, also used for book indexing.

tpages Books::cBook::pages [private]
 

pages of the book

LOGICAL Books::cBook::readonly [private]
 

if the book is loaded from script it must be true

std::string Books::cBook::title [private]
 

title of the book


The documentation for this class was generated from the following files: SourceForge.net Logo