![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
Implements the core functionality of a routine parameter Child classes of this class implement specific code generation and logic. More...
Inheritance diagram for RoutineAnalyzer::RoutineParamBase:Public Member Functions | |
| abstract string | GetDeclaration () |
| virtual string | GetParameter () |
| Returns the parameter marked used while setting up the CALL statement to the database For an IN parameter, this is just a question mark For an OUT parameter, this must be a unique name we query for later. | |
| abstract string | GetPostExecuteCode () |
| abstract string | GetPreExecuteCode () |
| RoutineParamBase (string sql, int index) | |
Protected Attributes | |
| int | _index |
| bool | _isInParam |
| string | _name |
| string | _sql |
| ParameterTypes | _type |
Properties | |
| string | Name [get] |
Private Member Functions | |
| void | Parse (string sql) |
| Analyzes the declaration and populates this object with the logical representation. | |
Static Private Member Functions | |
| static ParameterTypes | ConvertParameterType (string paramType, bool isIn) |
| Given a string describing the parameter type and a flag indicating whether it was in or out, this determines the Parameter type. | |
Definition at line 25 of file RoutineParamBase.cs.
| RoutineAnalyzer::RoutineParamBase::RoutineParamBase | ( | string | sql, |
| int | index | ||
| ) | [inline] |
| static ParameterTypes RoutineAnalyzer::RoutineParamBase::ConvertParameterType | ( | string | paramType, |
| bool | isIn | ||
| ) | [inline, static, private] |
| paramType | |
| isIn |
Definition at line 36 of file RoutineParamBase.cs.
Referenced by Parse().
{
paramType = paramType.ToUpper();
if (isIn)
{
if (paramType.Contains("VARCHAR"))
return ParameterTypes.StringByValue;
else
return ParameterTypes.IntByValue;
}
else
{
if (paramType.Contains("VARCHAR"))
return ParameterTypes.StringByReference;
else
return ParameterTypes.IntByReference;
}
}
| abstract string RoutineAnalyzer::RoutineParamBase::GetDeclaration | ( | ) | [pure virtual] |
Implemented in RoutineAnalyzer::CppGetRoutineParam, RoutineAnalyzer::CppSetRoutineParam, RoutineAnalyzer::CppWrapperSetRoutineParam, and RoutineAnalyzer::UScriptSetRoutineParam.
Referenced by RoutineAnalyzer::UScriptSetRoutine::GetDeclaration(), RoutineAnalyzer::UScriptGetRoutine::GetDeclaration(), RoutineAnalyzer::CppWrapperSetRoutine::GetDeclaration(), RoutineAnalyzer::CppWrapperGetRoutine::GetDeclaration(), RoutineAnalyzer::CppSetRoutine::GetDeclaration(), and RoutineAnalyzer::CppGetRoutine::GetDeclaration().
| virtual string RoutineAnalyzer::RoutineParamBase::GetParameter | ( | ) | [inline, virtual] |
| paramIndex |
Reimplemented in RoutineAnalyzer::CppWrapperSetRoutineParam.
Definition at line 128 of file RoutineParamBase.cs.
References _index, and _isInParam.
Referenced by RoutineAnalyzer::CppWrapperSetRoutine::GetCode(), and RoutineAnalyzer::CppSetRoutineParam::GetPostExecuteCode().
{
//if it is just an input param, then we use a quotation mark as the param maker
if (_isInParam)
return "?";
//if it is an output parameter, then we create a variable name based on the index
return string.Format("@param{0}", _index);
}
| abstract string RoutineAnalyzer::RoutineParamBase::GetPostExecuteCode | ( | ) | [pure virtual] |
| abstract string RoutineAnalyzer::RoutineParamBase::GetPreExecuteCode | ( | ) | [pure virtual] |
| void RoutineAnalyzer::RoutineParamBase::Parse | ( | string | sql | ) | [inline, private] |
| declaration |
Definition at line 87 of file RoutineParamBase.cs.
References _isInParam, _name, _sql, _type, and ConvertParameterType().
Referenced by RoutineParamBase().
{
//save the original SQL
_sql = sql;
//break up the parameters by their spaces
//NOTE: This is a very brittle way of parsing and depends on consistent SQL coding style in the database
string[] parts = sql.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
string direction;
string name;
string type;
//We assuming the delcaration takes the form: DIRECTION NAME TYPE
//if they didn't use an explicit IN declaration, then it is assumed to be one
if (parts.Length == 2)
{
direction = "IN";
name = parts[0];
type = parts[1];
}
else
{
direction = parts[0].ToUpper();
name = parts[1];
type = parts[2];
}
//if the direction is IN, then it's an in paramter (otherwise it is an OUT)
_isInParam = direction.ToUpper() == "IN";
_type = ConvertParameterType(type, _isInParam);
_name = name;
}
int RoutineAnalyzer::RoutineParamBase::_index [protected] |
Definition at line 61 of file RoutineParamBase.cs.
Referenced by GetParameter(), RoutineAnalyzer::CppGetRoutineParam::GetPostExecuteCode(), RoutineAnalyzer::CppSetRoutineParam::GetPreExecuteCode(), and RoutineParamBase().
bool RoutineAnalyzer::RoutineParamBase::_isInParam [protected] |
Definition at line 62 of file RoutineParamBase.cs.
Referenced by GetParameter(), RoutineAnalyzer::CppSetRoutineParam::GetPostExecuteCode(), RoutineAnalyzer::CppSetRoutineParam::GetPreExecuteCode(), and Parse().
string RoutineAnalyzer::RoutineParamBase::_name [protected] |
Definition at line 59 of file RoutineParamBase.cs.
Referenced by Parse().
string RoutineAnalyzer::RoutineParamBase::_sql [protected] |
Definition at line 60 of file RoutineParamBase.cs.
Referenced by Parse().
Definition at line 63 of file RoutineParamBase.cs.
Referenced by RoutineAnalyzer::UScriptSetRoutineParam::GetDeclaration(), RoutineAnalyzer::CppWrapperSetRoutineParam::GetDeclaration(), RoutineAnalyzer::CppSetRoutineParam::GetDeclaration(), RoutineAnalyzer::CppGetRoutineParam::GetDeclaration(), RoutineAnalyzer::CppWrapperSetRoutineParam::GetParameter(), RoutineAnalyzer::CppWrapperSetRoutineParam::GetPostExecuteCode(), RoutineAnalyzer::CppSetRoutineParam::GetPostExecuteCode(), RoutineAnalyzer::CppGetRoutineParam::GetPostExecuteCode(), RoutineAnalyzer::CppWrapperSetRoutineParam::GetPreExecuteCode(), RoutineAnalyzer::CppSetRoutineParam::GetPreExecuteCode(), and Parse().
string RoutineAnalyzer::RoutineParamBase::Name [get] |
Definition at line 66 of file RoutineParamBase.cs.
Referenced by RoutineAnalyzer::CppGetRoutineParam::GetCppName(), RoutineAnalyzer::UScriptSetRoutineParam::GetDeclaration(), RoutineAnalyzer::CppWrapperSetRoutineParam::GetDeclaration(), RoutineAnalyzer::CppSetRoutineParam::GetDeclaration(), RoutineAnalyzer::CppWrapperSetRoutineParam::GetParameter(), RoutineAnalyzer::CppWrapperSetRoutineParam::GetPostExecuteCode(), RoutineAnalyzer::CppSetRoutineParam::GetPostExecuteCode(), RoutineAnalyzer::CppSetRoutineParam::GetPreExecuteCode(), RoutineAnalyzer::CppGetRoutineParam::GetPreExecuteCode(), and RoutineAnalyzer::CppWrapperSetRoutineParam::GetStdStringName().
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.