![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
00001 using System; 00002 using System.Collections.Generic; 00003 using System.Linq; 00004 using System.Text; 00005 00006 namespace RoutineAnalyzer 00007 { 00008 class CppWrapperSetRoutineParam : RoutineParamBase 00009 { 00010 #region Static Methods 00011 00017 static string GetCppWrapperType(ParameterTypes type) 00018 { 00019 switch (type) 00020 { 00021 case ParameterTypes.IntByReference: return "int*"; 00022 case ParameterTypes.IntByValue: return "int"; 00023 case ParameterTypes.StringByReference: return "wchar_t*"; 00024 case ParameterTypes.StringByValue: return "wchar_t*"; 00025 00026 default: 00027 throw new Exception("Error: Cpp type not implemented!"); 00028 } 00029 } 00030 00031 #endregion 00032 00033 #region Methods 00034 00035 public CppWrapperSetRoutineParam(string sql, int index) 00036 : base(sql, index) 00037 { 00038 } 00039 00040 public override string GetParameter() 00041 { 00042 if (_type == ParameterTypes.StringByValue) 00043 return String.Format("convertString({0})", ParseHelper.ConvertUnderscoreToCamelCase(Name)); 00044 else if (_type == ParameterTypes.StringByReference) 00045 return GetStdStringName(); 00046 else 00047 return ParseHelper.ConvertUnderscoreToCamelCase(Name); 00048 } 00049 00050 public override string GetDeclaration() 00051 { 00052 string typeName = GetCppWrapperType(_type); 00053 string name = ParseHelper.ConvertUnderscoreToCamelCase(Name); 00054 return string.Format("{0} {1}", typeName, name); 00055 } 00056 00057 public override string GetPreExecuteCode() 00058 { 00059 if (_type == ParameterTypes.StringByReference) 00060 return String.Format("std::string {0};", GetStdStringName()); 00061 else 00062 return ""; 00063 } 00064 00065 public override string GetPostExecuteCode() 00066 { 00067 if (_type == ParameterTypes.StringByReference) 00068 return String.Format("{0} = convertString({1});", ParseHelper.ConvertUnderscoreToCamelCase(Name), GetStdStringName()); 00069 else 00070 return ""; 00071 } 00072 00073 string GetStdStringName() 00074 { 00075 return String.Format("str{0}", ParseHelper.ConvertUnderscoreToCamelCase(Name)); 00076 } 00077 00078 #endregion 00079 } 00080 }
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.