📄 shsql.h
字号:
#ifndef __shsql_h
#define __shsql_h
///////////////////////////////////////////////////////////////////////////////
// $Header: /shorthand/src/shsql.h 1 2/14/03 4:20a Arm $
//-----------------------------------------------------------------------------
// Project: ShortHand interpreter
// Author: Andrei Remenchuk <andrei@remenchuk.com>
//-----------------------------------------------------------------------------
// sql.cpp: ShortHand SQL objects and functions
///////////////////////////////////////////////////////////////////////////////
#include "nodes.h"
#include "map.h"
#include "dbdriver.h"
class ShhConnection : public ShhObject
{
protected:
ShhDbDriver* m_driver;
ShhDbHandle m_session;
string m_driverName;
string m_connectionString;
public:
ShhConnection(ShhModule& module, const YYLTYPE& ctor_location);
void constructor(ShhValueList* args);
void connect();
void disconnect();
ShhDbHandle provide_session();
bool hasMethod(const char* name);
ShhValue executeMethod(const char* name, ShhValueList* args);
~ShhConnection();
friend class ShhSQL;
friend class ShhDDL;
friend class ShhRecordSet;
};
class ShhSQL : public ShhObject, public ShhDbExecutor
{
protected:
ShhDbDriver* m_driver;
ShhCursorHandle m_cursor;
ShhResultHandle m_result;
array<string> m_parameters;
/** number of fields in the result set */
int m_field_count;
/** sequential number of the current record (first is one). */
int m_row_num;
/** total number of expected rows in the result set */
int m_total_row_count;
/** a pointer to the Connection object */
ShhConnection* m_connection;
protected:
virtual ShhValue execute(ShhValueList* args);
void paste_value(string& out, ShhValue value, int index);
void substitute(ShhValueList* args, const char* sqlin, string& sqlout);
void throwSQL(const char* format, ...);
ShhDbHandle provide_session();
public:
ShhSQL(ShhModule& module, const char* type, const YYLTYPE& location);
void constructor(ShhValueList* args);
ShhValue executeMethod(const char* name, ShhValueList* args);
bool hasMethod(const char* name);
const char* fpi_StoreParameter(int index, const char* value);
ShhDbHandle fpi_GetConnection();
~ShhSQL();
};
class ShhDDL : public ShhSQL
{
public:
ShhDDL(ShhModule& module, const YYLTYPE& location);
};
/**
* Recordset
*/
class ShhRecordSet : public ShhSQL
{
protected:
/** result set */
ShhRowHandle m_row;
/** number of fields in the result set */
int m_field_count;
/** sequential number of the current record (first is one). */
int m_row_num;
/** total number of expected rows in the result set */
int m_total_row_count;
/** indicates that cursor has advanced since last execution */
bool m_changed_since_execute;
/** indicates that last row has already been fetched */
bool m_no_more_rows;
protected:
ShhValue execute(ShhValueList* args);
ShhValue method_more();
ShhValue method_finished();
ShhValue method_next();
ShhValue method_rownum();
ShhValue method_count();
ShhValue method_value(ShhValueList* args);
public:
ShhRecordSet(ShhModule& module, const YYLTYPE& ctor_location);
ShhValue executeMethod(const char* name, ShhValueList* args);
bool hasMethod(const char* name);
~ShhRecordSet();
};
#endif //__shsql_h
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -