00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _command_h
00018 #define _command_h
00019
00020 #include <spl/types.h>
00021 #include <spl/Debug.h>
00022
00023 #include <spl/data/CommandParameter.h>
00024 #include <spl/Exception.h>
00025 #include <spl/collection/Hashtable.h>
00026 #include <spl/Memory.h>
00027 #include <spl/data/RecordSet.h>
00028 #include <spl/RefCountPtr.h>
00029 #include <spl/String.h>
00030 #include <spl/Variant.h>
00031 #include <spl/collection/Vector.h>
00032
00039 class Command;
00040 typedef RefCountPtr<Command> CommandPtr;
00041
00046 class Command : public IMemoryValidate
00047 {
00048 protected:
00049 String m_cmdtxt;
00050 Hashtable<String, CommandParameterPtr> m_prmIdx;
00051 Vector<CommandParameterPtr> m_prm;
00052
00053 public:
00054 Command();
00055 Command(const Command& cmd);
00056 Command(const String& cmdtxt);
00057 virtual ~Command();
00058
00059 Command& operator =(const Command& cmd);
00060
00061 virtual void Clear();
00062
00063 inline String CommandTextGet() { return m_cmdtxt; };
00064 virtual void CommandTextSet(const String& txt);
00065
00066 virtual CommandParameterPtr CreateParameter(const String& name, int type, int direction, int len);
00067 virtual CommandParameterPtr CreateParameter(const String& name, int type, int direction);
00068 virtual CommandParameterPtr CreateParameter(const String& name, const String& value);
00069 virtual CommandParameterPtr CreateParameter(const String& name, int32 value);
00070 virtual CommandParameterPtr CreateParameter(const String& name, int8 value);
00071 virtual CommandParameterPtr CreateParameter(const String& name, float32 value);
00072 virtual CommandParameterPtr CreateParameter(const String& name, float64 value);
00073
00074 virtual CommandParameterPtr GetParameter(const String& name) const;
00075 inline CommandParameterPtr GetParameter(int idx) const
00076 {
00077 return m_prm.ElementAt(idx);
00078 }
00079
00080 inline int ParameterCount() const
00081 {
00082 return m_prm.Count();
00083 }
00084
00085 virtual void Prepare();
00086 virtual int ExecuteNonQuery();
00087 virtual RecordSetPtr ExecuteQuery();
00088
00089 #if defined(DEBUG)
00090 virtual void CheckMem() const;
00091 virtual void ValidateMem() const;
00092 #endif
00093 };
00094
00097 #endif