Logo
~Sockets~
~Examples~
~Contact~

db::Steps Class Reference

#include <libfuture.h>

Collaboration diagram for db::Steps:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Steps (Database *)
 Begin class 'Steps'.
 Steps (Database *, const std::string &)
 Steps (Database *, Query *, int=0)
 Steps (Database &, long num)
 Steps (Database &, long player, long area, long zcoord, long ycoord)
 ~Steps ()
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 ()
 Steps (Database *)
 Steps (Database *, const std::string &)
 Steps (Database *, Query *, int=0)
 Steps (Database &, long num)
 Steps (Database &, long player, long area, long zcoord, long ycoord)
 ~Steps ()
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
long player
long area
long zcoord
long ycoord
std::string xcoords

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 330 of file root/src/futuremud/libfuture/libfuture.h.


Constructor & Destructor Documentation

Steps::Steps ( Database *   ) 

Begin class 'Steps'.

Definition at line 1784 of file libfuture.cpp.

01785 {
01786         database = db;
01787         new_object = 1;
01788         clear();
01789 }

Steps::Steps ( Database *  ,
const std::string &   
)

Definition at line 1792 of file libfuture.cpp.

01793 {
01794         database = db;
01795         new_object = 1;
01796         spawn(sql);
01797 }

Steps::Steps ( Database *  ,
Query *  ,
int  = 0 
)

Definition at line 1800 of file libfuture.cpp.

01801 {
01802         database = db;
01803         new_object = 0;
01804         spawn(qd, offset);
01805 }

Steps::Steps ( Database &  ,
long  num 
)

Definition at line 1808 of file libfuture.cpp.

References database, and spawn().

01808                                    :database(&db),new_object(1)
01809 {
01810         Query q(*database);
01811         std::string sql = "select * from steps where ";
01812         {
01813                 char slask[100];
01814                 sprintf(slask,"num='%ld'",i_num);
01815                 sql += slask;
01816         }
01817         spawn(sql);
01818 }

Steps::Steps ( Database &  ,
long  player,
long  area,
long  zcoord,
long  ycoord 
)

Definition at line 1821 of file libfuture.cpp.

References database, and spawn().

01821                                                                               :database(&db),new_object(1)
01822 {
01823         Query q(*database);
01824         std::string sql = "select * from steps where ";
01825         {
01826                 char slask[100];
01827                 sprintf(slask,"player='%ld'",i_player);
01828                 sql += slask;
01829         }
01830         {
01831                 char slask[100];
01832                 sprintf(slask," and area='%ld'",i_area);
01833                 sql += slask;
01834         }
01835         {
01836                 char slask[100];
01837                 sprintf(slask," and zcoord='%ld'",i_zcoord);
01838                 sql += slask;
01839         }
01840         {
01841                 char slask[100];
01842                 sprintf(slask," and ycoord='%ld'",i_ycoord);
01843                 sql += slask;
01844         }
01845         spawn(sql);
01846 }

Steps::~Steps (  ) 

Definition at line 1849 of file libfuture.cpp.

01850 {
01851 }

db::Steps::Steps ( Database *   ) 

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

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

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

db::Steps::Steps ( Database &  ,
long  player,
long  area,
long  zcoord,
long  ycoord 
)

db::Steps::~Steps (  ) 


Member Function Documentation

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

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

References database.

00338 { return *database; }

unsigned long long int Steps::insert (  ) 

Definition at line 1860 of file libfuture.cpp.

01861 {
01862         Query q(*database);
01863         std::string sql;
01864 
01865         sql = "insert into steps(player,area,zcoord,ycoord,xcoords)";
01866         {
01867                 char slask[100];
01868                 sprintf(slask," values(%ld",this -> player);
01869                 sql += slask;
01870         }
01871         {
01872                 char slask[100];
01873                 sprintf(slask,", %ld",this -> area);
01874                 sql += slask;
01875         }
01876         {
01877                 char slask[100];
01878                 sprintf(slask,", %ld",this -> zcoord);
01879                 sql += slask;
01880         }
01881         {
01882                 char slask[100];
01883                 sprintf(slask,", %ld",this -> ycoord);
01884                 sql += slask;
01885         }
01886         sql += ", '" + q.GetDatabase().safestr(this -> xcoords) + "'";
01887         sql += ")";
01888         q.execute(sql);
01889         new_object = 0;
01890         unsigned long long int inserted_id = q.insert_id();
01891         num = inserted_id;
01892         return inserted_id;
01893 }

void Steps::update (  ) 

Definition at line 1896 of file libfuture.cpp.

01897 {
01898         update(this -> num);
01899 }

void Steps::save (  ) 

Definition at line 1936 of file libfuture.cpp.

01937 {
01938         if (new_object)
01939                 insert();
01940         else
01941                 update();
01942 }

void Steps::erase (  ) 

Definition at line 1945 of file libfuture.cpp.

01946 {
01947         if (!new_object)
01948         {
01949                 std::string sql = "delete from steps where";
01950                 Query q(*database);
01951                 {
01952                         char slask[200];
01953                         sprintf(slask," num='%ld'",this -> num);
01954                         sql += slask;
01955                 }
01956                 q.execute(sql);
01957         }
01958 }

std::string Steps::xml (  ) 

Definition at line 1961 of file libfuture.cpp.

01962 {
01963         Query q(*database);
01964         std::string dest;
01965         char slask[200];
01966         dest = "<STEPS>";
01967         sprintf(slask,"<NUM>%ld</NUM>",this -> num);
01968         dest += slask;
01969         sprintf(slask,"<PLAYER>%ld</PLAYER>",this -> player);
01970         dest += slask;
01971         sprintf(slask,"<AREA>%ld</AREA>",this -> area);
01972         dest += slask;
01973         sprintf(slask,"<ZCOORD>%ld</ZCOORD>",this -> zcoord);
01974         dest += slask;
01975         sprintf(slask,"<YCOORD>%ld</YCOORD>",this -> ycoord);
01976         dest += slask;
01977         dest += "<XCOORDS>" + q.GetDatabase().xmlsafestr(this -> xcoords) + "</XCOORDS>";
01978         dest += "</STEPS>";
01979         return dest;
01980 }

std::string Steps::xml ( const std::string &  ,
const std::string &   
)

Definition at line 1983 of file libfuture.cpp.

01984 {
01985         Query q(*database);
01986         std::string dest;
01987         char slask[200];
01988         dest = "<STEPS " + tag + "=\"" + xvalx + "\">";
01989         sprintf(slask,"<NUM>%ld</NUM>",this -> num);
01990         dest += slask;
01991         sprintf(slask,"<PLAYER>%ld</PLAYER>",this -> player);
01992         dest += slask;
01993         sprintf(slask,"<AREA>%ld</AREA>",this -> area);
01994         dest += slask;
01995         sprintf(slask,"<ZCOORD>%ld</ZCOORD>",this -> zcoord);
01996         dest += slask;
01997         sprintf(slask,"<YCOORD>%ld</YCOORD>",this -> ycoord);
01998         dest += slask;
01999         dest += "<XCOORDS>" + q.GetDatabase().xmlsafestr(this -> xcoords) + "</XCOORDS>";
02000         dest += "</STEPS>";
02001         return dest;
02002 }

size_t Steps::num_cols (  ) 

Definition at line 2005 of file libfuture.cpp.

02006 {
02007         return 6;
02008 }

void Steps::clear (  )  [private]

Definition at line 2011 of file libfuture.cpp.

02012 {
02013         this -> num = 0;
02014         this -> player = 0;
02015         this -> area = 0;
02016         this -> zcoord = 0;
02017         this -> ycoord = 0;
02018         this -> xcoords = "";
02019 }

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

Definition at line 2022 of file libfuture.cpp.

Referenced by Steps().

02023 {
02024         Query q(*database);
02025         std::string temp;
02026 
02027         clear();
02028 
02029         if (!strncasecmp(sql.c_str(),"select * ",9))
02030         {
02031                 temp = "select num,player,area,zcoord,ycoord,xcoords " + sql.substr(9);
02032         } else
02033                 temp = sql;
02034         q.get_result(temp);
02035         if (q.fetch_row())
02036         {
02037                 this -> num = q.getval(0);                                                                                                                                                              // 0 - num integer
02038                 this -> player = q.getval(1);                                                                                                                                                           // 1 - player integer
02039                 this -> area = q.getval(2);                                                                                                                                                             // 2 - area integer
02040                 this -> zcoord = q.getval(3);                                                                                                                                                           // 3 - zcoord integer
02041                 this -> ycoord = q.getval(4);                                                                                                                                                           // 4 - ycoord integer
02042                 this -> xcoords = q.getstr(5);                                                                                                                                                          // 5 - xcoords text
02043                 new_object = 0;
02044         } else
02045                 clear();
02046         q.free_result();
02047 }

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

Definition at line 2050 of file libfuture.cpp.

02051 {
02052         clear();
02053 
02054         this -> num = qd -> getval(0 + offset);                                                                                                                                                         // 0 - num integer
02055         this -> player = qd -> getval(1 + offset);                                                                                                                                                              // 1 - player integer
02056         this -> area = qd -> getval(2 + offset);                                                                                                                                                                // 2 - area integer
02057         this -> zcoord = qd -> getval(3 + offset);                                                                                                                                                              // 3 - zcoord integer
02058         this -> ycoord = qd -> getval(4 + offset);                                                                                                                                                              // 4 - ycoord integer
02059         this -> xcoords = qd -> getstr(5 + offset);                                                                                                                                                             // 5 - xcoords text
02060 }

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

Definition at line 1854 of file libfuture.cpp.

01855 {
01856         spawn(sql);
01857 }

void Steps::update ( long  num  )  [private]

Definition at line 1902 of file libfuture.cpp.

01903 {
01904         Query q(*database);
01905         std::string sql;
01906         {
01907                 char slask[200];
01908                 sprintf(slask,"update steps set player=%ld",this -> player);
01909                 sql += slask;
01910         }
01911         {
01912                 char slask[200];
01913                 sprintf(slask,", area=%ld",this -> area);
01914                 sql += slask;
01915         }
01916         {
01917                 char slask[200];
01918                 sprintf(slask,", zcoord=%ld",this -> zcoord);
01919                 sql += slask;
01920         }
01921         {
01922                 char slask[200];
01923                 sprintf(slask,", ycoord=%ld",this -> ycoord);
01924                 sql += slask;
01925         }
01926         sql += ", xcoords='" + q.GetDatabase().safestr(this -> xcoords) + "'";
01927         {
01928                 char slask[200];
01929                 sprintf(slask," where num='%ld'",i_num);
01930                 sql += slask;
01931         }
01932         q.execute(sql);
01933 }

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

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

References database.

00338 { return *database; }

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

void db::Steps::update (  ) 

void db::Steps::save (  ) 

void db::Steps::erase (  ) 

std::string db::Steps::xml (  ) 

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

size_t db::Steps::num_cols (  ) 

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

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

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

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

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


Member Data Documentation

long Steps::num

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

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

std::string Steps::xcoords

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

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

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

Referenced by GetDatabase(), and Steps().

short Steps::new_object [private]

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

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

Definition at line 363 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