00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef _OASYS_SQL_SERIALIZE_H_
00039 #define _OASYS_SQL_SERIALIZE_H_
00040
00048 #include "Serialize.h"
00049 #include "../util/StringBuffer.h"
00050
00051 namespace oasys {
00052
00053 class SQLImplementation;
00054
00059 class SQLQuery : public SerializeAction {
00060 public:
00064 SQLQuery(action_t type, const char* table_name, SQLImplementation* impl,
00065 const char* initial_query = 0);
00066
00070 const char* query() { return query_.c_str(); }
00071
00075 StringBuffer* querybuf() { return &query_; }
00076
00077 protected:
00078 const char* table_name_;
00079 SQLImplementation* sql_impl_ ;
00080 StringBuffer query_;
00081 };
00082
00087 class SQLInsert : public SQLQuery {
00088 public:
00092 SQLInsert(const char* table_name, SQLImplementation *impl);
00093
00094 virtual void begin_action();
00095 virtual void end_action();
00096
00101 int action(const SerializableObject* const_object)
00102 {
00103 return(SerializeAction::action((SerializableObject*)const_object));
00104 }
00105
00106
00107 void process(const char* name, u_int32_t* i);
00108 void process(const char* name, u_int16_t* i);
00109 void process(const char* name, u_int8_t* i);
00110 void process(const char* name, int32_t* i);
00111 void process(const char* name, int16_t* i);
00112 void process(const char* name, int8_t* i);
00113 void process(const char* name, bool* b);
00114 void process(const char* name, u_char* bp, size_t len);
00115 void process(const char* name, u_char** bp, size_t* lenp, int flags);
00116 void process(const char* name, std::string* s);
00117 };
00118
00123 class SQLUpdate : public SQLQuery {
00124 public:
00128 SQLUpdate(const char* table_name, SQLImplementation *impl);
00129
00130 virtual void begin_action();
00131 virtual void end_action();
00132
00137 int action(const SerializableObject* const_object)
00138 {
00139 return(SerializeAction::action((SerializableObject*)const_object));
00140 }
00141
00142
00143 void process(const char* name, u_int32_t* i);
00144 void process(const char* name, u_int16_t* i);
00145 void process(const char* name, u_int8_t* i);
00146 void process(const char* name, int32_t* i);
00147 void process(const char* name, int16_t* i);
00148 void process(const char* name, int8_t* i);
00149 void process(const char* name, bool* b);
00150 void process(const char* name, u_char* bp, size_t len);
00151 void process(const char* name, u_char** bp, size_t* lenp, int flags);
00152 void process(const char* name, std::string* s);
00153 };
00154
00159 class SQLTableFormat : public SQLQuery {
00160 public:
00164 SQLTableFormat(const char* table_name, SQLImplementation *impl);
00165
00166 virtual void begin_action();
00167 virtual void end_action();
00168
00173 int action(const SerializableObject* const_object)
00174 {
00175 return(SerializeAction::action((SerializableObject*)const_object));
00176 }
00177
00178
00179 void process(const char* name, SerializableObject* object);
00180 void process(const char* name, u_int32_t* i);
00181 void process(const char* name, u_int16_t* i);
00182 void process(const char* name, u_int8_t* i);
00183 void process(const char* name, bool* b);
00184 void process(const char* name, u_char* bp, size_t len);
00185 void process(const char* name, u_char** bp, size_t* lenp, int flags);
00186 void process(const char* name, std::string* s);
00187
00188 protected:
00189 void append(const char* name, const char* type);
00190 StringBuffer column_prefix_;
00191 };
00192
00197 class SQLExtract : public SerializeAction {
00198 public:
00199 SQLExtract(SQLImplementation *impl);
00200
00201
00202 const char* next_field() ;
00203
00204
00205 void process(const char* name, u_int32_t* i);
00206 void process(const char* name, u_int16_t* i);
00207 void process(const char* name, u_int8_t* i);
00208 void process(const char* name, bool* b);
00209 void process(const char* name, u_char* bp, size_t len);
00210 void process(const char* name, u_char** bp, size_t* lenp, int flags);
00211 void process(const char* name, std::string* s);
00212
00213 protected:
00214 int field_;
00215
00216 private:
00217 SQLImplementation *sql_impl_;
00218 };
00219
00220 }
00221
00222 #endif