Logo
~Sockets~
~Examples~
~Contact~

db::Account Class Reference

#include <libfuture.h>

Collaboration diagram for db::Account:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Account (Database *)
 Begin class 'Account'.
 Account (Database *, const std::string &)
 Account (Database *, Query *, int=0)
 Account (Database &, long num)
 Account (Database &, const std::string &name)
 ~Account ()
Database & GetDatabase ()
unsigned long long int insert ()
void update ()
void save ()
void erase ()
std::string xml ()
std::string xml (const std::string &, const std::string &)
size_t num_cols ()
 Account (Database *)
 Account (Database *, const std::string &)
 Account (Database *, Query *, int=0)
 Account (Database &, long num)
 Account (Database &, const std::string &name)
 ~Account ()
Database & GetDatabase ()
unsigned long long int insert ()
void update ()
void save ()
void erase ()
std::string xml ()
std::string xml (const std::string &, const std::string &)
size_t num_cols ()

Public Attributes

long num
std::string name
std::string passwd
std::string display_name
char wizard
std::string email
long area
long chunk
long chunkx
long chunky
long facing
long wizview
long race

Private Member Functions

void clear ()
void spawn (const std::string &)
void spawn (Query *, int=0)
void select (const std::string &)
void update (long num)
void clear ()
void spawn (const std::string &)
void spawn (Query *, int=0)
void select (const std::string &)
void update (long num)

Private Attributes

Database * database
short new_object
Database * database

Detailed Description

Definition at line 51 of file root/src/futuremud/libfuture/libfuture.h.


Constructor & Destructor Documentation

db::Account::Account ( Database *   ) 

Begin class 'Account'.

Definition at line 34 of file libfuture.cpp.

References clear(), database, and new_object.

00035 {
00036         database = db;
00037         new_object = 1;
00038         clear();
00039 }

db::Account::Account ( Database *  ,
const std::string &   
)

Definition at line 42 of file libfuture.cpp.

References database, new_object, and spawn().

00043 {
00044         database = db;
00045         new_object = 1;
00046         spawn(sql);
00047 }

db::Account::Account ( Database *  ,
Query *  ,
int  = 0 
)

Definition at line 50 of file libfuture.cpp.

References database, new_object, and spawn().

00051 {
00052         database = db;
00053         new_object = 0;
00054         spawn(qd, offset);
00055 }

db::Account::Account ( Database &  ,
long  num 
)

Definition at line 58 of file libfuture.cpp.

References database, and spawn().

00058                                        :database(&db),new_object(1)
00059 {
00060         Query q(*database);
00061         std::string sql = "select * from account where ";
00062         {
00063                 char slask[100];
00064                 sprintf(slask,"num='%ld'",i_num);
00065                 sql += slask;
00066         }
00067         spawn(sql);
00068 }

db::Account::Account ( Database &  ,
const std::string &  name 
)

Definition at line 71 of file libfuture.cpp.

References database, and spawn().

00071                                                      :database(&db),new_object(1)
00072 {
00073         Query q(*database);
00074         std::string sql = "select * from account where ";
00075         sql += "name='" + q.GetDatabase().safestr(i_name) + "'";
00076         spawn(sql);
00077 }

db::Account::~Account (  ) 

Definition at line 80 of file libfuture.cpp.

00081 {
00082 }

db::Account::Account ( Database *   ) 

db::Account::Account ( Database *  ,
const std::string &   
)

db::Account::Account ( Database *  ,
Query *  ,
int  = 0 
)

db::Account::Account ( Database &  ,
long  num 
)

db::Account::Account ( Database &  ,
const std::string &  name 
)

db::Account::~Account (  ) 


Member Function Documentation

Database& db::Account::GetDatabase (  )  [inline]

Definition at line 59 of file root/src/futuremud/libfuture/libfuture.h.

References database.

00059 { return *database; }

unsigned long long int db::Account::insert (  ) 

Definition at line 91 of file libfuture.cpp.

References area, chunk, chunkx, chunky, database, display_name, email, facing, name, new_object, num, passwd, race, wizard, and wizview.

Referenced by save().

00092 {
00093         Query q(*database);
00094         std::string sql;
00095 
00096         sql = "insert into account(name,passwd,display_name,wizard,email,area,chunk,chunkx,chunky,facing,wizview,race)";
00097         sql += " values('" + q.GetDatabase().safestr(this -> name) + "'";
00098         sql += ", '" + q.GetDatabase().safestr(this -> passwd) + "'";
00099         sql += ", '" + q.GetDatabase().safestr(this -> display_name) + "'";
00100         {
00101                 char slask[100];
00102                 sprintf(slask,", %d",this -> wizard);
00103                 sql += slask;
00104         }
00105         sql += ", '" + q.GetDatabase().safestr(this -> email) + "'";
00106         {
00107                 char slask[100];
00108                 sprintf(slask,", %ld",this -> area);
00109                 sql += slask;
00110         }
00111         {
00112                 char slask[100];
00113                 sprintf(slask,", %ld",this -> chunk);
00114                 sql += slask;
00115         }
00116         {
00117                 char slask[100];
00118                 sprintf(slask,", %ld",this -> chunkx);
00119                 sql += slask;
00120         }
00121         {
00122                 char slask[100];
00123                 sprintf(slask,", %ld",this -> chunky);
00124                 sql += slask;
00125         }
00126         {
00127                 char slask[100];
00128                 sprintf(slask,", %ld",this -> facing);
00129                 sql += slask;
00130         }
00131         {
00132                 char slask[100];
00133                 sprintf(slask,", %ld",this -> wizview);
00134                 sql += slask;
00135         }
00136         {
00137                 char slask[100];
00138                 sprintf(slask,", %ld",this -> race);
00139                 sql += slask;
00140         }
00141         sql += ")";
00142         q.execute(sql);
00143         new_object = 0;
00144         unsigned long long int inserted_id = q.insert_id();
00145         num = inserted_id;
00146         return inserted_id;
00147 }

void db::Account::update (  ) 

Definition at line 150 of file libfuture.cpp.

References num.

Referenced by save().

00151 {
00152         update(this -> num);
00153 }

void db::Account::save (  ) 

Definition at line 213 of file libfuture.cpp.

References insert(), new_object, and update().

00214 {
00215         if (new_object)
00216                 insert();
00217         else
00218                 update();
00219 }

void db::Account::erase (  ) 

Definition at line 222 of file libfuture.cpp.

References database, new_object, and num.

00223 {
00224         if (!new_object)
00225         {
00226                 std::string sql = "delete from account where";
00227                 Query q(*database);
00228                 {
00229                         char slask[200];
00230                         sprintf(slask," num='%ld'",this -> num);
00231                         sql += slask;
00232                 }
00233                 q.execute(sql);
00234         }
00235 }

std::string db::Account::xml (  ) 

Definition at line 238 of file libfuture.cpp.

References area, chunk, chunkx, chunky, database, display_name, email, facing, name, num, passwd, race, wizard, and wizview.

00239 {
00240         Query q(*database);
00241         std::string dest;
00242         char slask[200];
00243         dest = "<ACCOUNT>";
00244         sprintf(slask,"<NUM>%ld</NUM>",this -> num);
00245         dest += slask;
00246         dest += "<NAME>" + q.GetDatabase().xmlsafestr(this -> name) + "</NAME>";
00247         dest += "<PASSWD>" + q.GetDatabase().xmlsafestr(this -> passwd) + "</PASSWD>";
00248         dest += "<DISPLAY_NAME>" + q.GetDatabase().xmlsafestr(this -> display_name) + "</DISPLAY_NAME>";
00249         sprintf(slask,"<WIZARD>%d</WIZARD>",this -> wizard);
00250         dest += slask;
00251         dest += "<EMAIL>" + q.GetDatabase().xmlsafestr(this -> email) + "</EMAIL>";
00252         sprintf(slask,"<AREA>%ld</AREA>",this -> area);
00253         dest += slask;
00254         sprintf(slask,"<CHUNK>%ld</CHUNK>",this -> chunk);
00255         dest += slask;
00256         sprintf(slask,"<CHUNKX>%ld</CHUNKX>",this -> chunkx);
00257         dest += slask;
00258         sprintf(slask,"<CHUNKY>%ld</CHUNKY>",this -> chunky);
00259         dest += slask;
00260         sprintf(slask,"<FACING>%ld</FACING>",this -> facing);
00261         dest += slask;
00262         sprintf(slask,"<WIZVIEW>%ld</WIZVIEW>",this -> wizview);
00263         dest += slask;
00264         sprintf(slask,"<RACE>%ld</RACE>",this -> race);
00265         dest += slask;
00266         dest += "</ACCOUNT>";
00267         return dest;
00268 }

std::string db::Account::xml ( const std::string &  ,
const std::string &   
)

Definition at line 271 of file libfuture.cpp.

References area, chunk, chunkx, chunky, database, display_name, email, facing, name, num, passwd, race, wizard, and wizview.

00272 {
00273         Query q(*database);
00274         std::string dest;
00275         char slask[200];
00276         dest = "<ACCOUNT " + tag + "=\"" + xvalx + "\">";
00277         sprintf(slask,"<NUM>%ld</NUM>",this -> num);
00278         dest += slask;
00279         dest += "<NAME>" + q.GetDatabase().xmlsafestr(this -> name) + "</NAME>";
00280         dest += "<PASSWD>" + q.GetDatabase().xmlsafestr(this -> passwd) + "</PASSWD>";
00281         dest += "<DISPLAY_NAME>" + q.GetDatabase().xmlsafestr(this -> display_name) + "</DISPLAY_NAME>";
00282         sprintf(slask,"<WIZARD>%d</WIZARD>",this -> wizard);
00283         dest += slask;
00284         dest += "<EMAIL>" + q.GetDatabase().xmlsafestr(this -> email) + "</EMAIL>";
00285         sprintf(slask,"<AREA>%ld</AREA>",this -> area);
00286         dest += slask;
00287         sprintf(slask,"<CHUNK>%ld</CHUNK>",this -> chunk);
00288         dest += slask;
00289         sprintf(slask,"<CHUNKX>%ld</CHUNKX>",this -> chunkx);
00290         dest += slask;
00291         sprintf(slask,"<CHUNKY>%ld</CHUNKY>",this -> chunky);
00292         dest += slask;
00293         sprintf(slask,"<FACING>%ld</FACING>",this -> facing);
00294         dest += slask;
00295         sprintf(slask,"<WIZVIEW>%ld</WIZVIEW>",this -> wizview);
00296         dest += slask;
00297         sprintf(slask,"<RACE>%ld</RACE>",this -> race);
00298         dest += slask;
00299         dest += "</ACCOUNT>";
00300         return dest;
00301 }

size_t db::Account::num_cols (  ) 

Definition at line 304 of file libfuture.cpp.

00305 {
00306         return 13;
00307 }

void db::Account::clear (  )  [private]

Definition at line 310 of file libfuture.cpp.

References area, chunk, chunkx, chunky, display_name, email, facing, name, num, passwd, race, wizard, and wizview.

Referenced by Account(), and spawn().

00311 {
00312         this -> num = 0;
00313         this -> name = "";
00314         this -> passwd = "";
00315         this -> display_name = "";
00316         this -> wizard = 0;
00317         this -> email = "";
00318         this -> area = 0;
00319         this -> chunk = 0;
00320         this -> chunkx = 0;
00321         this -> chunky = 0;
00322         this -> facing = 0;
00323         this -> wizview = 0;
00324         this -> race = 0;
00325 }

void db::Account::spawn ( const std::string &   )  [private]

Definition at line 328 of file libfuture.cpp.

References area, chunk, chunkx, chunky, clear(), database, display_name, email, facing, name, new_object, num, passwd, race, wizard, and wizview.

Referenced by Account(), and select().

00329 {
00330         Query q(*database);
00331         std::string temp;
00332 
00333         clear();
00334 
00335         if (!strncasecmp(sql.c_str(),"select * ",9))
00336         {
00337                 temp = "select num,name,passwd,display_name,wizard,email,area,chunk,chunkx,chunky,facing,wizview,race " + sql.substr(9);
00338         } else
00339                 temp = sql;
00340         q.get_result(temp);
00341         if (q.fetch_row())
00342         {
00343                 this -> num = q.getval(0);                                                                                                                                                              // 0 - num integer
00344                 this -> name = q.getstr(1);                                                                                                                                                             // 1 - name varchar(255)
00345                 this -> passwd = q.getstr(2);                                                                                                                                                           // 2 - passwd varchar(255)
00346                 this -> display_name = q.getstr(3);                                                                                                                                                             // 3 - display_name varchar(255)
00347                 this -> wizard = q.getval(4);                                                                                                                                                           // 4 - wizard tinyint(1)
00348                 this -> email = q.getstr(5);                                                                                                                                                            // 5 - email varchar(255)
00349                 this -> area = q.getval(6);                                                                                                                                                             // 6 - area integer
00350                 this -> chunk = q.getval(7);                                                                                                                                                            // 7 - chunk integer
00351                 this -> chunkx = q.getval(8);                                                                                                                                                           // 8 - chunkx integer
00352                 this -> chunky = q.getval(9);                                                                                                                                                           // 9 - chunky integer
00353                 this -> facing = q.getval(10);                                                                                                                                                          // 10 - facing integer
00354                 this -> wizview = q.getval(11);                                                                                                                                                         // 11 - wizview integer
00355                 this -> race = q.getval(12);                                                                                                                                                            // 12 - race integer
00356                 new_object = 0;
00357         } else
00358                 clear();
00359         q.free_result();
00360 }

void db::Account::spawn ( Query *  ,
int  = 0 
) [private]

Definition at line 363 of file libfuture.cpp.

References area, chunk, chunkx, chunky, clear(), display_name, email, facing, name, num, passwd, race, wizard, and wizview.

00364 {
00365         clear();
00366 
00367         this -> num = qd -> getval(0 + offset);                                                                                                                                                         // 0 - num integer
00368         this -> name = qd -> getstr(1 + offset);                                                                                                                                                                // 1 - name varchar(255)
00369         this -> passwd = qd -> getstr(2 + offset);                                                                                                                                                              // 2 - passwd varchar(255)
00370         this -> display_name = qd -> getstr(3 + offset);                                                                                                                                                                // 3 - display_name varchar(255)
00371         this -> wizard = qd -> getval(4 + offset);                                                                                                                                                              // 4 - wizard tinyint(1)
00372         this -> email = qd -> getstr(5 + offset);                                                                                                                                                               // 5 - email varchar(255)
00373         this -> area = qd -> getval(6 + offset);                                                                                                                                                                // 6 - area integer
00374         this -> chunk = qd -> getval(7 + offset);                                                                                                                                                               // 7 - chunk integer
00375         this -> chunkx = qd -> getval(8 + offset);                                                                                                                                                              // 8 - chunkx integer
00376         this -> chunky = qd -> getval(9 + offset);                                                                                                                                                              // 9 - chunky integer
00377         this -> facing = qd -> getval(10 + offset);                                                                                                                                                             // 10 - facing integer
00378         this -> wizview = qd -> getval(11 + offset);                                                                                                                                                            // 11 - wizview integer
00379         this -> race = qd -> getval(12 + offset);                                                                                                                                                               // 12 - race integer
00380 }

void db::Account::select ( const std::string &   )  [private]

Definition at line 85 of file libfuture.cpp.

References spawn().

00086 {
00087         spawn(sql);
00088 }

void db::Account::update ( long  num  )  [private]

Definition at line 156 of file libfuture.cpp.

References area, chunk, chunkx, chunky, database, display_name, email, facing, name, passwd, race, wizard, and wizview.

00157 {
00158         Query q(*database);
00159         std::string sql;
00160         sql += "update account set name='" + q.GetDatabase().safestr(this -> name) + "'";
00161         sql += ", passwd='" + q.GetDatabase().safestr(this -> passwd) + "'";
00162         sql += ", display_name='" + q.GetDatabase().safestr(this -> display_name) + "'";
00163         {
00164                 char slask[200];
00165                 sprintf(slask,", wizard=%d",this -> wizard);
00166                 sql += slask;
00167         }
00168         sql += ", email='" + q.GetDatabase().safestr(this -> email) + "'";
00169         {
00170                 char slask[200];
00171                 sprintf(slask,", area=%ld",this -> area);
00172                 sql += slask;
00173         }
00174         {
00175                 char slask[200];
00176                 sprintf(slask,", chunk=%ld",this -> chunk);
00177                 sql += slask;
00178         }
00179         {
00180                 char slask[200];
00181                 sprintf(slask,", chunkx=%ld",this -> chunkx);
00182                 sql += slask;
00183         }
00184         {
00185                 char slask[200];
00186                 sprintf(slask,", chunky=%ld",this -> chunky);
00187                 sql += slask;
00188         }
00189         {
00190                 char slask[200];
00191                 sprintf(slask,", facing=%ld",this -> facing);
00192                 sql += slask;
00193         }
00194         {
00195                 char slask[200];
00196                 sprintf(slask,", wizview=%ld",this -> wizview);
00197                 sql += slask;
00198         }
00199         {
00200                 char slask[200];
00201                 sprintf(slask,", race=%ld",this -> race);
00202                 sql += slask;
00203         }
00204         {
00205                 char slask[200];
00206                 sprintf(slask," where num='%ld'",i_num);
00207                 sql += slask;
00208         }
00209         q.execute(sql);
00210 }

Database& db::Account::GetDatabase (  )  [inline]

Definition at line 59 of file usr/devel/include/libfuture.h.

References database.

00059 { return *database; }

unsigned long long int db::Account::insert (  ) 

void db::Account::update (  ) 

void db::Account::save (  ) 

void db::Account::erase (  ) 

std::string db::Account::xml (  ) 

std::string db::Account::xml ( const std::string &  ,
const std::string &   
)

size_t db::Account::num_cols (  ) 

void db::Account::clear (  )  [private]

void db::Account::spawn ( const std::string &   )  [private]

void db::Account::spawn ( Query *  ,
int  = 0 
) [private]

void db::Account::select ( const std::string &   )  [private]

void db::Account::update ( long  num  )  [private]


Member Data Documentation

Definition at line 70 of file root/src/futuremud/libfuture/libfuture.h.

Referenced by clear(), erase(), insert(), spawn(), update(), and xml().

std::string db::Account::name

Definition at line 71 of file root/src/futuremud/libfuture/libfuture.h.

Referenced by clear(), insert(), spawn(), update(), and xml().

std::string db::Account::passwd

Definition at line 72 of file root/src/futuremud/libfuture/libfuture.h.

Referenced by clear(), insert(), spawn(), update(), and xml().

Definition at line 73 of file root/src/futuremud/libfuture/libfuture.h.

Referenced by clear(), insert(), spawn(), update(), and xml().

Definition at line 74 of file root/src/futuremud/libfuture/libfuture.h.

Referenced by clear(), insert(), spawn(), update(), and xml().

std::string db::Account::email

Definition at line 75 of file root/src/futuremud/libfuture/libfuture.h.

Referenced by clear(), insert(), spawn(), update(), and xml().

Definition at line 76 of file root/src/futuremud/libfuture/libfuture.h.

Referenced by clear(), insert(), spawn(), update(), and xml().

Definition at line 77 of file root/src/futuremud/libfuture/libfuture.h.

Referenced by clear(), insert(), spawn(), update(), and xml().

Definition at line 78 of file root/src/futuremud/libfuture/libfuture.h.

Referenced by clear(), insert(), spawn(), update(), and xml().

Definition at line 79 of file root/src/futuremud/libfuture/libfuture.h.

Referenced by clear(), insert(), spawn(), update(), and xml().

Definition at line 80 of file root/src/futuremud/libfuture/libfuture.h.

Referenced by clear(), insert(), spawn(), update(), and xml().

Definition at line 81 of file root/src/futuremud/libfuture/libfuture.h.

Referenced by clear(), insert(), spawn(), update(), and xml().

Definition at line 82 of file root/src/futuremud/libfuture/libfuture.h.

Referenced by clear(), insert(), spawn(), update(), and xml().

Database* db::Account::database [private]

short db::Account::new_object [private]

Definition at line 92 of file root/src/futuremud/libfuture/libfuture.h.

Referenced by Account(), erase(), insert(), save(), and spawn().

Database* db::Account::database [private]

Definition at line 91 of file usr/devel/include/libfuture.h.


The documentation for this class was generated from the following files:
Page, code, and content Copyright (C) 2006 by Anders Hedström
Generated on Mon Aug 29 20:21:47 2005 for C++ Sockets by  doxygen 1.4.4