00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _OASYS_SQL_SERIALIZE_H_
00018 #define _OASYS_SQL_SERIALIZE_H_
00019
00027 #include "Serialize.h"
00028 #include "../util/StringBuffer.h"
00029
00030 namespace oasys {
00031
00032 class SQLImplementation;
00033
00038 class SQLQuery : public SerializeAction {
00039 public:
00043 SQLQuery(action_t type, const char* table_name, SQLImplementation* impl,
00044 const char* initial_query = 0);
00045
00049 const char* query() { return query_.c_str(); }
00050
00054 StringBuffer* querybuf() { return &query_; }
00055
00056 protected:
00057 const char* table_name_;
00058 SQLImplementation* sql_impl_ ;
00059 StringBuffer query_;
00060 };
00061
00066 class SQLInsert : public SQLQuery {
00067 public:
00071 SQLInsert(const char* table_name, SQLImplementation *impl);
00072
00073 virtual void begin_action();
00074 virtual void end_action();
00075
00080 int action(const SerializableObject* const_object)
00081 {
00082 return(SerializeAction::action((SerializableObject*)const_object));
00083 }
00084
00085
00086 void process(const char* name, u_int32_t* i);
00087 void process(const char* name, u_int16_t* i);
00088 void process(const char* name, u_int8_t* i);
00089 void process(const char* name, int32_t* i);
00090 void process(const char* name, int16_t* i);
00091 void process(const char* name, int8_t* i);
00092 void process(const char* name, bool* b);
00093 void process(const char* name, u_char* bp, size_t len);
00094 void process(const char* name, u_char** bp, size_t* lenp, int flags);
00095 void process(const char* name, std::string* s);
00096 };
00097
00102 class SQLUpdate : public SQLQuery {
00103 public:
00107 SQLUpdate(const char* table_name, SQLImplementation *impl);
00108
00109 virtual void begin_action();
00110 virtual void end_action();
00111
00116 int action(const SerializableObject* const_object)
00117 {
00118 return(SerializeAction::action((SerializableObject*)const_object));
00119 }
00120
00121
00122 void process(const char* name, u_int32_t* i);
00123 void process(const char* name, u_int16_t* i);
00124 void process(const char* name, u_int8_t* i);
00125 void process(const char* name, int32_t* i);
00126 void process(const char* name, int16_t* i);
00127 void process(const char* name, int8_t* i);
00128 void process(const char* name, bool* b);
00129 void process(const char* name, u_char* bp, size_t len);
00130 void process(const char* name, u_char** bp, size_t* lenp, int flags);
00131 void process(const char* name, std::string* s);
00132 };
00133
00138 class SQLTableFormat : public SQLQuery {
00139 public:
00143 SQLTableFormat(const char* table_name, SQLImplementation *impl);
00144
00145 virtual void begin_action();
00146 virtual void end_action();
00147
00152 int action(const SerializableObject* const_object)
00153 {
00154 return(SerializeAction::action((SerializableObject*)const_object));
00155 }
00156
00157
00158 void process(const char* name, SerializableObject* object);
00159 void process(const char* name, u_int32_t* i);
00160 void process(const char* name, u_int16_t* i);
00161 void process(const char* name, u_int8_t* i);
00162 void process(const char* name, bool* b);
00163 void process(const char* name, u_char* bp, size_t len);
00164 void process(const char* name, u_char** bp, size_t* lenp, int flags);
00165 void process(const char* name, std::string* s);
00166
00167 protected:
00168 void append(const char* name, const char* type);
00169 StringBuffer column_prefix_;
00170 };
00171
00176 class SQLExtract : public SerializeAction {
00177 public:
00178 SQLExtract(SQLImplementation *impl);
00179
00180
00181 const char* next_field() ;
00182
00183
00184 void process(const char* name, u_int32_t* i);
00185 void process(const char* name, u_int16_t* i);
00186 void process(const char* name, u_int8_t* i);
00187 void process(const char* name, bool* b);
00188 void process(const char* name, u_char* bp, size_t len);
00189 void process(const char* name, u_char** bp, size_t* lenp, int flags);
00190 void process(const char* name, std::string* s);
00191
00192 protected:
00193 int field_;
00194
00195 private:
00196 SQLImplementation *sql_impl_;
00197 };
00198
00199 }
00200
00201 #endif