mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-06-20 17:17:13 +02:00
Discard instances of constant StackStrF parameters. This should always be non-const if possible.
This commit is contained in:
@ -101,7 +101,7 @@ Object GetMemoryHighwaterMark(bool reset)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
CSStr EscapeString(const StackStrF & str)
|
||||
CSStr EscapeString(StackStrF & str)
|
||||
{
|
||||
// Is there even a string to escape?
|
||||
if (str.mLen <= 0)
|
||||
@ -115,7 +115,7 @@ CSStr EscapeString(const StackStrF & str)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
CCStr EscapeStringEx(SQChar spec, const StackStrF & str)
|
||||
CCStr EscapeStringEx(SQChar spec, StackStrF & str)
|
||||
{
|
||||
// Utility that allows changing the format specifier temporarily
|
||||
static SQChar fs[] = _SC("%q");
|
||||
|
@ -126,12 +126,12 @@ Object GetMemoryHighwaterMark(bool reset);
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Retrieve the escaped version of the specified string.
|
||||
*/
|
||||
CSStr EscapeString(const StackStrF & str);
|
||||
CSStr EscapeString(StackStrF & str);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Retrieve the escaped version of the specified string using the supplied format specifier.
|
||||
*/
|
||||
CCStr EscapeStringEx(SQChar spec, const StackStrF & str);
|
||||
CCStr EscapeStringEx(SQChar spec, StackStrF & str);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Convert the values from the specified array to a list of column names string.
|
||||
|
@ -97,7 +97,7 @@ const ConnRef & Connection::GetCreated() const
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Connection::Open(const StackStrF & name)
|
||||
void Connection::Open(StackStrF & name)
|
||||
{
|
||||
// Should we create a connection handle?
|
||||
if (!m_Handle)
|
||||
@ -114,7 +114,7 @@ void Connection::Open(const StackStrF & name)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Connection::Open(const StackStrF & name, Int32 flags)
|
||||
void Connection::Open(StackStrF & name, Int32 flags)
|
||||
{
|
||||
// Should we create a connection handle?
|
||||
if (!m_Handle)
|
||||
@ -131,7 +131,7 @@ void Connection::Open(const StackStrF & name, Int32 flags)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Connection::Open(const StackStrF & name, Int32 flags, const StackStrF & vfs)
|
||||
void Connection::Open(StackStrF & name, Int32 flags, StackStrF & vfs)
|
||||
{
|
||||
// Should we create a connection handle?
|
||||
if (!m_Handle)
|
||||
@ -148,7 +148,7 @@ void Connection::Open(const StackStrF & name, Int32 flags, const StackStrF & vfs
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Int32 Connection::Exec(const StackStrF & str)
|
||||
Int32 Connection::Exec(StackStrF & str)
|
||||
{
|
||||
SQMOD_VALIDATE_CREATED(*this);
|
||||
// Attempt to execute the specified query
|
||||
@ -163,7 +163,7 @@ Int32 Connection::Exec(const StackStrF & str)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Object Connection::Query(const StackStrF & str) const
|
||||
Object Connection::Query(StackStrF & str) const
|
||||
{
|
||||
SQMOD_VALIDATE_CREATED(*this);
|
||||
// Return the requested information
|
||||
@ -171,7 +171,7 @@ Object Connection::Query(const StackStrF & str) const
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Connection::Queue(const StackStrF & str)
|
||||
void Connection::Queue(StackStrF & str)
|
||||
{
|
||||
SQMOD_VALIDATE(*this);
|
||||
// Is there a query to commit?
|
||||
@ -198,10 +198,11 @@ bool Connection::IsReadOnly() const
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool Connection::TableExists(const StackStrF & name) const
|
||||
bool Connection::TableExists(StackStrF & name) const
|
||||
{
|
||||
StackStrF query("SELECT count(*) FROM [sqlite_master] WHERE [type]='table' AND [name]=?");
|
||||
// Prepare a statement to inspect the master table
|
||||
Statement stmt(SQMOD_GET_CREATED(*this), "SELECT count(*) FROM [sqlite_master] WHERE [type]='table' AND [name]=?");
|
||||
Statement stmt(SQMOD_GET_CREATED(*this), query);
|
||||
// Could the statement be created?
|
||||
if (stmt.IsValid())
|
||||
{
|
||||
@ -346,9 +347,9 @@ void Register_Connection(Table & sqlns)
|
||||
Class< Connection >(sqlns.GetVM(), Typename::Str)
|
||||
// Constructors
|
||||
.Ctor()
|
||||
.Ctor< const StackStrF & >()
|
||||
.Ctor< const StackStrF &, Int32 >()
|
||||
.Ctor< const StackStrF &, Int32, const StackStrF & >()
|
||||
.Ctor< StackStrF & >()
|
||||
.Ctor< StackStrF &, Int32 >()
|
||||
.Ctor< StackStrF &, Int32, StackStrF & >()
|
||||
// Meta-methods
|
||||
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
|
||||
.Func(_SC("_tostring"), &Connection::ToString)
|
||||
@ -387,9 +388,9 @@ void Register_Connection(Table & sqlns)
|
||||
.Func(_SC("ClearQueue"), &Connection::ClearQueue)
|
||||
.Func(_SC("PopQueue"), &Connection::PopQueue)
|
||||
// Member Overloads
|
||||
.Overload< void (Connection::*)(const StackStrF &) >(_SC("Open"), &Connection::Open)
|
||||
.Overload< void (Connection::*)(const StackStrF &, Int32) >(_SC("Open"), &Connection::Open)
|
||||
.Overload< void (Connection::*)(const StackStrF &, Int32, const StackStrF &) >(_SC("Open"), &Connection::Open)
|
||||
.Overload< void (Connection::*)(StackStrF &) >(_SC("Open"), &Connection::Open)
|
||||
.Overload< void (Connection::*)(StackStrF &, Int32) >(_SC("Open"), &Connection::Open)
|
||||
.Overload< void (Connection::*)(StackStrF &, Int32, StackStrF &) >(_SC("Open"), &Connection::Open)
|
||||
.Overload< Int32 (Connection::*)(Int32) >(_SC("GetInfo"), &Connection::GetInfo)
|
||||
.Overload< Int32 (Connection::*)(Int32, bool) >(_SC("GetInfo"), &Connection::GetInfo)
|
||||
.Overload< Int32 (Connection::*)(Int32, bool, bool) >(_SC("GetInfo"), &Connection::GetInfo)
|
||||
|
@ -79,7 +79,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Explicit constructor.
|
||||
*/
|
||||
Connection(const StackStrF & name)
|
||||
Connection(StackStrF & name)
|
||||
: m_Handle(new ConnHnd())
|
||||
{
|
||||
SQMOD_GET_VALID(*this)->Create(name.mPtr, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, nullptr);
|
||||
@ -88,7 +88,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Explicit constructor.
|
||||
*/
|
||||
Connection(const StackStrF & name, Int32 flags)
|
||||
Connection(StackStrF & name, Int32 flags)
|
||||
: m_Handle(new ConnHnd())
|
||||
{
|
||||
SQMOD_GET_VALID(*this)->Create(name.mPtr, flags, nullptr);
|
||||
@ -97,7 +97,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Explicit constructor.
|
||||
*/
|
||||
Connection(const StackStrF & name, Int32 flags, const StackStrF & vfs)
|
||||
Connection(StackStrF & name, Int32 flags, StackStrF & vfs)
|
||||
: m_Handle(new ConnHnd())
|
||||
{
|
||||
SQMOD_GET_VALID(*this)->Create(name.mPtr, flags, vfs.mPtr);
|
||||
@ -279,32 +279,32 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Attempt to open the specified database.
|
||||
*/
|
||||
void Open(const StackStrF & name);
|
||||
void Open(StackStrF & name);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Attempt to open the specified database.
|
||||
*/
|
||||
void Open(const StackStrF & name, Int32 flags);
|
||||
void Open(StackStrF & name, Int32 flags);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Attempt to open the specified database.
|
||||
*/
|
||||
void Open(const StackStrF & name, Int32 flags, const StackStrF & vfs);
|
||||
void Open(StackStrF & name, Int32 flags, StackStrF & vfs);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Attempt to execute the specified query.
|
||||
*/
|
||||
Int32 Exec(const StackStrF & str);
|
||||
Int32 Exec(StackStrF & str);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Attempt to queue the specified query.
|
||||
*/
|
||||
void Queue(const StackStrF & str);
|
||||
void Queue(StackStrF & str);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Attempt to create a statement from the specified query.
|
||||
*/
|
||||
Object Query(const StackStrF & str) const;
|
||||
Object Query(StackStrF & str) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* See if the database connection was opened in read-only mode.
|
||||
@ -314,7 +314,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Shortcut to test if a table exists.
|
||||
*/
|
||||
bool TableExists(const StackStrF & name) const;
|
||||
bool TableExists(StackStrF & name) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* See if the database connection is or is not in auto-commit mode.
|
||||
|
@ -459,7 +459,7 @@ void Parameter::SetFloat64(SQFloat value)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Parameter::SetString(const StackStrF & value)
|
||||
void Parameter::SetString(StackStrF & value)
|
||||
{
|
||||
SQMOD_VALIDATE_CREATED(*this);
|
||||
// Attempt to bind the specified value
|
||||
|
@ -341,7 +341,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Attempt to bind a string value at the referenced parameter index.
|
||||
*/
|
||||
void SetString(const StackStrF & value);
|
||||
void SetString(StackStrF & value);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Attempt to bind a string value at the referenced parameter index.
|
||||
|
@ -160,7 +160,7 @@ void Statement::ValidateRow() const
|
||||
#endif // _DEBUG
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Statement::Statement(const Connection & connection, const StackStrF & query)
|
||||
Statement::Statement(const Connection & connection, StackStrF & query)
|
||||
: m_Handle(new StmtHnd(connection.GetHandle()))
|
||||
{
|
||||
SQMOD_GET_VALID(*this)->Create(query.mPtr, query.mLen);
|
||||
@ -425,7 +425,7 @@ void Register_Statement(Table & sqlns)
|
||||
// Constructors
|
||||
.Ctor()
|
||||
.Ctor< const Statement & >()
|
||||
.Ctor< const Connection &, const StackStrF & >()
|
||||
.Ctor< const Connection &, StackStrF & >()
|
||||
// Meta-methods
|
||||
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
|
||||
.Func(_SC("_tostring"), &Statement::ToString)
|
||||
|
@ -98,7 +98,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Construct a statement under the specified connection using the specified string.
|
||||
*/
|
||||
Statement(const ConnRef & connection, const StackStrF & query)
|
||||
Statement(const ConnRef & connection, StackStrF & query)
|
||||
: m_Handle(new StmtHnd(connection))
|
||||
{
|
||||
SQMOD_GET_VALID(*this)->Create(query.mPtr, query.mLen);
|
||||
@ -107,7 +107,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Construct a statement under the specified connection using the specified string.
|
||||
*/
|
||||
Statement(const Connection & connection, const StackStrF & query);
|
||||
Statement(const Connection & connection, StackStrF & query);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Direct handle constructor.
|
||||
@ -314,7 +314,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the parameter index associated with the specified name.
|
||||
*/
|
||||
Int32 GetParameterIndex(const StackStrF & name) const
|
||||
Int32 GetParameterIndex(StackStrF & name) const
|
||||
{
|
||||
return sqlite3_bind_parameter_index(SQMOD_GET_VALID(*this)->mPtr, name.mPtr);
|
||||
}
|
||||
@ -367,7 +367,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the column index associated with the specified name.
|
||||
*/
|
||||
Int32 GetColumnIndex(const StackStrF & name) const
|
||||
Int32 GetColumnIndex(StackStrF & name) const
|
||||
{
|
||||
return SQMOD_GET_VALID(*this)->GetColumnIndex(name.mPtr, name.mLen);
|
||||
}
|
||||
@ -594,7 +594,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Attempt to bind a string value at the specified parameter index.
|
||||
*/
|
||||
Statement & SetString(const Object & param, const StackStrF & value)
|
||||
Statement & SetString(const Object & param, StackStrF & value)
|
||||
{
|
||||
Parameter(SQMOD_GET_CREATED(*this), param).SetString(value);
|
||||
// Allow chaining of operations
|
||||
|
Reference in New Issue
Block a user