Google
Web alhem.net
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

db::Tag Class Reference

#include <libfd.h>

List of all members.

Public Member Functions

 Tag (Database *)
 Tag (Database *, const std::string &)
 Tag (Database *, Query *, int=0)
 Tag (Database &, long num)
 ~Tag ()
my_ulonglong 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

Private Member Functions

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


Constructor & Destructor Documentation

db::Tag::Tag Database *  db  ) 
 

Begin class 'Tag'

Definition at line 788 of file libfd.cpp.

References clear(), database, and new_object.

00789 { 00790 database = db; 00791 new_object = 1; 00792 clear(); 00793 }

db::Tag::Tag Database *  ,
const std::string & 
 

Definition at line 796 of file libfd.cpp.

References database, new_object, and spawn().

00797 { 00798 database = db; 00799 new_object = 1; 00800 spawn(sql); 00801 }

db::Tag::Tag Database *  ,
Query *  ,
int  = 0
 

Definition at line 804 of file libfd.cpp.

References database, new_object, and spawn().

00805 { 00806 database = db; 00807 new_object = 0; 00808 spawn(qd, offset); 00809 }

db::Tag::Tag Database &  ,
long  num
 

Definition at line 812 of file libfd.cpp.

References database, and spawn().

00812 :database(&db),new_object(1) 00813 { 00814 Query q(*database); 00815 std::string sql = "select * from tag where "; 00816 { 00817 char slask[100]; 00818 sprintf(slask,"num='%ld'",i_num); 00819 sql += slask; 00820 } 00821 spawn(sql); 00822 }

db::Tag::~Tag  ) 
 

Definition at line 825 of file libfd.cpp.

00826 { 00827 }


Member Function Documentation

void db::Tag::clear  )  [private]
 

Definition at line 941 of file libfd.cpp.

References num.

Referenced by spawn(), and Tag().

00942 { 00943 num = 0; 00944 // 1 - name varchar(255) 00945 }

void db::Tag::erase  ) 
 

Definition at line 891 of file libfd.cpp.

References database, new_object, and num.

00892 { 00893 if (!new_object) 00894 { 00895 std::string sql = "delete from tag where"; 00896 Query q(*database); 00897 { 00898 char slask[200]; 00899 sprintf(slask," num='%ld'",this -> num); 00900 sql += slask; 00901 } 00902 q.execute(sql); 00903 } 00904 }

my_ulonglong db::Tag::insert  ) 
 

Definition at line 836 of file libfd.cpp.

References database, name, new_object, and num.

Referenced by save().

00837 { 00838 Query q(*database); 00839 std::string sql; 00840 00841 sql = "insert into tag(num,name)"; 00842 { 00843 char slask[100]; 00844 sprintf(slask," values(%ld",this -> num); 00845 sql += slask; 00846 } 00847 sql += ", '" + q.safestr(this -> name) + "'"; 00848 sql += ")"; 00849 q.execute(sql); 00850 new_object = 0; 00851 my_ulonglong inserted_id = q.insert_id(); 00852 num = inserted_id; 00853 return inserted_id; 00854 }

size_t db::Tag::num_cols  ) 
 

Definition at line 935 of file libfd.cpp.

00936 { 00937 return 2; 00938 }

void db::Tag::save  ) 
 

Definition at line 882 of file libfd.cpp.

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

Referenced by form_input(), and MyMinionSocket::OnVerifiedLine().

00883 { 00884 if (new_object) 00885 insert(); 00886 else 00887 update(); 00888 }

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

Definition at line 830 of file libfd.cpp.

References spawn().

00831 { 00832 spawn(sql); 00833 }

void db::Tag::spawn Query *  ,
int  = 0
[private]
 

Definition at line 972 of file libfd.cpp.

References clear(), name, and num.

00973 { 00974 clear(); 00975 00976 num = qd -> getval(0 + offset); // 0 - num int(11) 00977 name = qd -> getstr(1 + offset); // 1 - name varchar(255) 00978 }

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

Definition at line 948 of file libfd.cpp.

References clear(), database, name, new_object, and num.

Referenced by select(), and Tag().

00949 { 00950 Query q(*database); 00951 std::string temp; 00952 00953 clear(); 00954 00955 if (!strncasecmp(sql.c_str(),"select * ",9)) 00956 { 00957 temp = "select num,name " + sql.substr(9); 00958 } else 00959 temp = sql; 00960 q.get_result(temp); 00961 if (q.fetch_row()) 00962 { 00963 num = q.getval(0); // 0 - num int(11) 00964 name = q.getstr(1); // 1 - name varchar(255) 00965 new_object = 0; 00966 } else 00967 clear(); 00968 q.free_result(); 00969 }

void db::Tag::update long  num  )  [private]
 

Definition at line 863 of file libfd.cpp.

References database, name, and num.

00864 { 00865 Query q(*database); 00866 std::string sql; 00867 { 00868 char slask[200]; 00869 sprintf(slask,"update tag set num=%ld",this -> num); 00870 sql += slask; 00871 } 00872 sql += ", name='" + q.safestr(this -> name) + "'"; 00873 { 00874 char slask[200]; 00875 sprintf(slask," where num='%ld'",i_num); 00876 sql += slask; 00877 } 00878 q.execute(sql); 00879 }

void db::Tag::update  ) 
 

Definition at line 857 of file libfd.cpp.

References num.

Referenced by save().

00858 { 00859 update(this -> num); 00860 }

std::string db::Tag::xml const std::string &  ,
const std::string & 
 

Definition at line 921 of file libfd.cpp.

References database, name, and num.

00922 { 00923 Query q(*database); 00924 std::string dest; 00925 char slask[200]; 00926 dest = "<TAG " + tag + "=\"" + xvalx + "\">"; 00927 sprintf(slask,"<NUM>%ld</NUM>",this -> num); 00928 dest += slask; 00929 dest += "<NAME>" + q.xmlsafestr(this -> name) + "</NAME>"; 00930 dest += "</TAG>"; 00931 return dest; 00932 }

std::string db::Tag::xml  ) 
 

Definition at line 907 of file libfd.cpp.

References database, name, and num.

00908 { 00909 Query q(*database); 00910 std::string dest; 00911 char slask[200]; 00912 dest = "<TAG>"; 00913 sprintf(slask,"<NUM>%ld</NUM>",this -> num); 00914 dest += slask; 00915 dest += "<NAME>" + q.xmlsafestr(this -> name) + "</NAME>"; 00916 dest += "</TAG>"; 00917 return dest; 00918 }


Member Data Documentation

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

Definition at line 201 of file libfd.h.

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

std::string db::Tag::name
 

Definition at line 192 of file libfd.h.

Referenced by form_input(), insert(), MyMinionSocket::OnVerifiedLine(), post_form(), search(), spawn(), update(), and xml().

short db::Tag::new_object [private]
 

Definition at line 202 of file libfd.h.

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

long db::Tag::num
 

Definition at line 191 of file libfd.h.

Referenced by clear(), erase(), form_input(), insert(), MyMinionSocket::OnVerifiedLine(), post_form(), search(), spawn(), update(), and xml().


The documentation for this class was generated from the following files:
Generated on Thu Feb 10 22:42:41 2005 for Distributed URL Classification Tool by doxygen 1.3.7