![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
Creates C++ code that implements a procedure call to a MySQL SPROC http://dev.mysql.com/doc/refman/5.1/en/connector-net-tutorials-stored-routines-statements.html. More...
Inheritance diagram for RoutineAnalyzer::CppGetRoutine:Public Member Functions | |
| CppGetRoutine (string sql) | |
| override string | GetCode () |
| Should implement creation of the defintion. | |
| override string | GetDeclaration () |
| Gets the declaration associated with this C++ function. | |
Protected Member Functions | |
| override RoutineParamBase | CreateRoutineParam (string sql, int index) |
| Implements generating of objects for parameters, these will be children of RoutineParamBase. | |
void SraData::DbProcedures::getCharActiveSkills(int pInCharId, int* activeSkillId, int* rating, int* queryId) { DbStream* stream; if(*queryId == DbStream::InitStreamId) stream = DbStream::StartStream(formatString("CALL get_char_active_skills(%d)",pInCharId)); else stream = DbStream::RetrieveStream(queryId); if(stream == NULL) return; activeSkillId = stream->getInt(1); rating = stream->getInt(2); if(!DbStream::CheckHasMoreRows(stream, queryId)) queryId = DbStream::InitStreamId; }
Definition at line 29 of file CppGetRoutine.cs.
| RoutineAnalyzer::CppGetRoutine::CppGetRoutine | ( | string | sql | ) | [inline] |
Definition at line 31 of file CppGetRoutine.cs.
: base(sql)
{
}
| override RoutineParamBase RoutineAnalyzer::CppGetRoutine::CreateRoutineParam | ( | string | sql, |
| int | index | ||
| ) | [inline, protected, virtual] |
| sql | |
| index |
Implements RoutineAnalyzer::RoutineBase.
Reimplemented in RoutineAnalyzer::UScriptGetRoutine.
Definition at line 90 of file CppGetRoutine.cs.
{
return new CppGetRoutineParam(sql, index);
}
| override string RoutineAnalyzer::CppGetRoutine::GetCode | ( | ) | [inline, virtual] |
Implements RoutineAnalyzer::RoutineBase.
Reimplemented in RoutineAnalyzer::UScriptGetRoutine.
Definition at line 58 of file CppGetRoutine.cs.
References RoutineAnalyzer::RoutineBase::_name, RoutineAnalyzer::RoutineBase::_params, and GetDeclaration().
{
//start off with the declaration, then put in
StringBuilder builder = new StringBuilder();
builder.AppendLine(GetDeclaration().Replace("static __declspec(dllexport) ", ""));
builder.AppendLine("{");
//choose to start a new stream or continue an existing one
builder.AppendLine("DbStream* stream;");
builder.AppendLine("if(*queryId == DbStream::InitStreamId)");
builder.Append(" stream = DbStream::StartStream(formatString(\"CALL ");
builder.Append(_name);
builder.Append("(%d)\",");
builder.Append(_params.First().GetPreExecuteCode());
builder.AppendLine("));");
builder.AppendLine("else");
builder.AppendLine(" stream = DbStream::RetrieveStream(queryId);");
builder.AppendLine("if(stream == NULL)");
builder.AppendLine(" return;");
for (int i = 1; i < _params.Count; ++i)
builder.AppendLine(_params[i].GetPostExecuteCode());
builder.AppendLine("if(!DbStream::CheckHasMoreRows(stream, queryId))");
builder.AppendLine(" *queryId = DbStream::InitStreamId;");
//close up the statement and return it
builder.Append("}");
return builder.ToString();
}
| override string RoutineAnalyzer::CppGetRoutine::GetDeclaration | ( | ) | [inline, virtual] |
Implements RoutineAnalyzer::RoutineBase.
Reimplemented in RoutineAnalyzer::UScriptGetRoutine.
Definition at line 40 of file CppGetRoutine.cs.
References RoutineAnalyzer::RoutineBase::_name, RoutineAnalyzer::RoutineBase::_params, RoutineAnalyzer::ParseHelper::ConvertUnderscoreToCamelCase(), and RoutineAnalyzer::RoutineParamBase::GetDeclaration().
Referenced by GetCode().
{
StringBuilder builder = new StringBuilder();
builder.Append("static __declspec(dllexport) void ");
builder.Append(ParseHelper.ConvertUnderscoreToCamelCase(_name));
builder.Append("(");
foreach (RoutineParamBase param in _params)
{
builder.Append(param.GetDeclaration());
builder.Append(", ");
}
builder.Append("int* queryId");
builder.Append(")");
return builder.ToString();
}
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.