本文整理汇总了C++中database::Results::Bind方法的典型用法代码示例。如果您正苦于以下问题:C++ Results::Bind方法的具体用法?C++ Results::Bind怎么用?C++ Results::Bind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类database::Results
的用法示例。
在下文中一共展示了Results::Bind方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CacheResults
//.........这里部分代码省略.........
kUtility.SetYields(m_piYieldPerEra, "Improvement_YieldPerEra", "ImprovementType", szImprovementType);
kUtility.SetYields(m_piAdjacentCityYieldChange, "Improvement_AdjacentCityYields", "ImprovementType", szImprovementType);
kUtility.SetYields(m_piAdjacentMountainYieldChange, "Improvement_AdjacentMountainYieldChanges", "ImprovementType", szImprovementType);
kUtility.SetYields(m_piCoastalLandYieldChange, "Improvement_CoastalLandYields", "ImprovementType", szImprovementType);
kUtility.SetYields(m_piFreshWaterChange, "Improvement_FreshWaterYields", "ImprovementType", szImprovementType);
kUtility.SetYields(m_piHillsYieldChange, "Improvement_HillsYields", "ImprovementType", szImprovementType);
kUtility.SetYields(m_piRiverSideYieldChange, "Improvement_RiverSideYields", "ImprovementType", szImprovementType);
kUtility.SetYields(m_piPrereqNatureYield, "Improvement_PrereqNatureYields", "ImprovementType", szImprovementType);
kUtility.SetFlavors(m_piFlavorValue, "Improvement_Flavors", "ImprovementType", szImprovementType);
{
//Initialize Improvement Resource Types to number of Resources
const int iNumResources = kUtility.MaxRows("Resources");
m_paImprovementResource = FNEW(CvImprovementResourceInfo[iNumResources], c_eCiv5GameplayDLL, 0);
kUtility.InitializeArray(m_piResourceQuantityRequirements, iNumResources);
std::string strResourceTypesKey = "Improvements - ResourceTypes";
Database::Results* pResourceTypes = kUtility.GetResults(strResourceTypesKey);
if(pResourceTypes == NULL)
{
pResourceTypes = kUtility.PrepareResults(strResourceTypesKey, "select Resources.ID, ResourceType, ResourceMakesValid, ResourceTrade, DiscoveryRand from Improvement_ResourceTypes inner join Resources on ResourceType = Resources.Type where ImprovementType = ?");
}
std::string strYieldResultsKey = "Improvements - YieldResults";
Database::Results* pYieldResults = kUtility.GetResults(strYieldResultsKey);
if(pYieldResults == NULL)
{
pYieldResults = kUtility.PrepareResults(strYieldResultsKey, "select Yields.ID, Yield from Improvement_ResourceType_Yields inner join Yields on YieldType = Yields.Type where ImprovementType = ? and ResourceType = ?");
}
pResourceTypes->Bind(1, szImprovementType, lenImprovementType, false);
while(pResourceTypes->Step())
{
const int idx = pResourceTypes->GetInt("ID");
CvImprovementResourceInfo& pResourceInfo = m_paImprovementResource[idx];
const char* szResourceType = pResourceTypes->GetText("ResourceType");
pResourceInfo.m_bResourceMakesValid = pResourceTypes->GetBool("ResourceMakesValid");
pResourceInfo.m_bResourceTrade = pResourceTypes->GetBool("ResourceTrade");
pResourceInfo.m_iDiscoverRand = pResourceTypes->GetInt("DiscoveryRand");
m_piResourceQuantityRequirements[idx] = pResourceTypes->GetInt("QuantityRequirement");
//Populate Yields for structure
kUtility.InitializeArray(pResourceInfo.m_piYieldChange, "Yields");
pYieldResults->Bind(1, szImprovementType, lenImprovementType, false);
pYieldResults->Bind(2, szResourceType, -1, false);
while(pYieldResults->Step())
{
const int yieldIdx = pYieldResults->GetInt("ID");
const int yield = pYieldResults->GetInt("Yield");
pResourceInfo.m_piYieldChange[yieldIdx] = yield;
}
pYieldResults->Reset();
}
pResourceTypes->Reset();
}
const int iNumYields = kUtility.MaxRows("Yields");
示例2: CacheResults
bool CvCorporationEntry::CacheResults(Database::Results& kResults, CvDatabaseUtility& kUtility)
{
if(!CvBaseInfo::CacheResults(kResults, kUtility))
return false;
m_iMaxFranchises = kResults.GetInt("MaxFranchises");
m_iNumFreeTradeRoutes = kResults.GetInt("NumFreeTradeRoutes");
m_iTradeRouteLandDistanceModifier = kResults.GetInt("TradeRouteLandDistanceModifier");
m_iTradeRouteSeaDistanceModifier = kResults.GetInt("TradeRouteSeaDistanceModifier");
m_iTradeRouteSpeedModifier = kResults.GetInt("TradeRouteSpeedModifier");
m_iTradeRouteVisionBoost = kResults.GetInt("TradeRouteVisionBoost");
m_bTradeRoutesInvulnerable = kResults.GetBool("TradeRoutesInvulnerable");
m_iTradeRouteRecipientBonus = kResults.GetInt("TradeRouteRecipientBonus");
m_iTradeRouteTargetBonus = kResults.GetInt("TradeRouteTargetBonus");
//References
const char* szTextVal = NULL;
szTextVal = kResults.GetText("HeadquartersBuildingClass");
m_eHeadquartersBuildingClass = (BuildingClassTypes) GC.getInfoTypeForString(szTextVal, true);
szTextVal = kResults.GetText("OfficeBuildingClass");
m_eOfficeBuildingClass = (BuildingClassTypes) GC.getInfoTypeForString(szTextVal, true);
szTextVal = kResults.GetText("FranchiseBuildingClass");
m_eFranchiseBuildingClass = (BuildingClassTypes) GC.getInfoTypeForString(szTextVal, true);
szTextVal = kResults.GetText("OfficeBenefitHelper");
m_strOfficeBenefitHelper = szTextVal;
// This is not ideal, but Corporations are loaded last, and I want an easy way to tell if a building class is owned by a Corporation
// Note: Intellisense may lie here! This will compile (declared as friend)
CvBuildingClassInfo* pkBuildingInfo = GC.getBuildingClassInfo(m_eHeadquartersBuildingClass);
if (pkBuildingInfo)
{
pkBuildingInfo->m_eCorporationType = (CorporationTypes) GetID();
pkBuildingInfo->m_bIsHeadquarters = true;
}
pkBuildingInfo = GC.getBuildingClassInfo(m_eOfficeBuildingClass);
if (pkBuildingInfo)
{
pkBuildingInfo->m_eCorporationType = (CorporationTypes) GetID();
pkBuildingInfo->m_bIsOffice = true;
}
pkBuildingInfo = GC.getBuildingClassInfo(m_eFranchiseBuildingClass);
if (pkBuildingInfo)
{
pkBuildingInfo->m_eCorporationType = (CorporationTypes) GetID();
pkBuildingInfo->m_bIsFranchise = true;
}
const char* szCorporationType = GetType();
kUtility.PopulateArrayByExistence(m_piResourceMonopolyAnd, "Resources", "Corporation_ResourceMonopolyAnds", "ResourceType", "CorporationType", szCorporationType);
kUtility.PopulateArrayByExistence(m_piResourceMonopolyOrs, "Resources", "Corporation_ResourceMonopolyOrs", "ResourceType", "CorporationType", szCorporationType);
kUtility.PopulateArrayByValue(m_piNumFreeResource, "Resources", "Corporation_NumFreeResource", "ResourceType", "CorporationType", szCorporationType, "NumResource");
kUtility.PopulateArrayByValue(m_piUnitResourceProductionModifier, "Resources", "Corporation_UnitResourceProductionModifier", "ResourceType", "CorporationType", szCorporationType, "Modifier");
kUtility.SetYields(m_piTradeRouteCityMod, "Corporation_TradeRouteCityYield", "CorporationType", szCorporationType);
kUtility.SetYields(m_piTradeRouteMod, "Corporation_TradeRouteMod", "CorporationType", szCorporationType);
//BuildingClassYieldChanges
{
kUtility.Initialize2DArray(m_ppiBuildingClassYieldChanges, "BuildingClasses", "Yields");
std::string strKey("Corporation_BuildingClassYieldChanges");
Database::Results* pResults = kUtility.GetResults(strKey);
if (pResults == NULL)
{
pResults = kUtility.PrepareResults(strKey, "select BuildingClasses.ID as BuildingClassID, Yields.ID as YieldID, YieldChange from Corporation_BuildingClassYieldChanges inner join BuildingClasses on BuildingClasses.Type = BuildingClassType inner join Yields on Yields.Type = YieldType where CorporationType = ?");
}
pResults->Bind(1, szCorporationType);
while (pResults->Step())
{
const int BuildingClassID = pResults->GetInt(0);
const int iYieldID = pResults->GetInt(1);
const int iYieldChange = pResults->GetInt(2);
m_ppiBuildingClassYieldChanges[BuildingClassID][iYieldID] = iYieldChange;
}
}
//ResourceYieldChanges
{
kUtility.Initialize2DArray(m_ppaiResourceYieldChange, "Resources", "Yields");
std::string strKey("Corporation_ResourceYieldChanges");
Database::Results* pResults = kUtility.GetResults(strKey);
if (pResults == NULL)
{
pResults = kUtility.PrepareResults(strKey, "select Resources.ID as ResourceID, Yields.ID as YieldID, Yield from Corporation_ResourceYieldChanges inner join Resources on Resources.Type = ResourceType inner join Yields on Yields.Type = YieldType where CorporationType = ?");
}
pResults->Bind(1, szCorporationType);
while (pResults->Step())
{
const int ResourceID = pResults->GetInt(0);
const int YieldID = pResults->GetInt(1);
const int yield = pResults->GetInt(2);
//.........这里部分代码省略.........
示例3: CacheResults
//------------------------------------------------------------------------------
bool CvProjectEntry::CacheResults(Database::Results& kResults, CvDatabaseUtility& kUtility)
{
if(!CvBaseInfo::CacheResults(kResults, kUtility))
return false;
m_iMaxGlobalInstances = kResults.GetInt("MaxGlobalInstances");
m_iMaxTeamInstances = kResults.GetInt("MaxTeamInstances");
m_iProductionCost = kResults.GetInt("Cost");
m_iNukeInterception = kResults.GetInt("NukeInterception");
m_iCultureBranchesRequired = kResults.GetInt("CultureBranchesRequired");
m_iTechShare = kResults.GetInt("TechShare");
m_iVictoryDelayPercent = kResults.GetInt("VictoryDelayPercent");
m_bSpaceship = kResults.GetBool("Spaceship");
m_bAllowsNukes = kResults.GetBool("AllowsNukes");
m_strMovieArtDef = kResults.GetText("MovieDefineTag");
const char* szVictoryPrereq = kResults.GetText("VictoryPrereq");
m_iVictoryPrereq = GC.getInfoTypeForString(szVictoryPrereq, true);
const char* szTechPrereq = kResults.GetText("TechPrereq");
m_iTechPrereq = GC.getInfoTypeForString(szTechPrereq, true);
const char* szEveryoneSpecialUnit = kResults.GetText("EveryoneSpecialUnit");
m_iEveryoneSpecialUnit = GC.getInfoTypeForString(szEveryoneSpecialUnit, true);
const char* szCreateSound = kResults.GetText("CreateSound");
SetCreateSound(szCreateSound);
const char* szAnyonePrereqProject = kResults.GetText("AnyonePrereqProject");
m_iAnyoneProjectPrereq = GC.getInfoTypeForString(szAnyonePrereqProject, true);
//Arrays
const char* szProjectType = GetType();
kUtility.PopulateArrayByValue(m_piResourceQuantityRequirements, "Resources", "Project_ResourceQuantityRequirements", "ResourceType", "ProjectType", szProjectType, "Quantity");
//Victory Thresholds
{
const int iNumVictories = kUtility.MaxRows("Victories");
kUtility.InitializeArray(m_piVictoryThreshold, iNumVictories);
kUtility.InitializeArray(m_piVictoryMinThreshold, iNumVictories);
Database::Results kDBResults;
char szQuery[512] = {0};
sprintf_s(szQuery, "select VictoryType, Threshold, MinThreshold from Project_VictoryThresholds where ProjectType = '%s';", szProjectType);
if(DB.Execute(kDBResults, szQuery))
{
while(kDBResults.Step())
{
const char* szVictoryType = kDBResults.GetText("VictoryType");
const int idx = GC.getInfoTypeForString(szVictoryType, true);
const int iThreshold = kDBResults.GetInt("Threshold");
const int iMinThreshold = kDBResults.GetInt("MinThreshold");
m_piVictoryThreshold[idx] = iThreshold;
m_piVictoryMinThreshold[idx] = iMinThreshold;
}
}
}
kUtility.SetFlavors(m_piFlavorValue, "Project_Flavors", "ProjectType", szProjectType);
kUtility.PopulateArrayByValue(m_piProjectsNeeded, "Projects", "Project_Prereqs", "PrereqProjectType", "ProjectType", szProjectType, "AmountNeeded");
// EventEngine - v0.1, Snarko
{
m_asziFlagPrereqs.clear();
std::string strKey("Project_PrereqFlags");
Database::Results* pResults = kUtility.GetResults(strKey);
if(pResults == NULL)
{
pResults = kUtility.PrepareResults(strKey, "select * from Project_PrereqFlags where ProjectType = ?");
}
pResults->Bind(1, szProjectType);
while(pResults->Step())
{
std::string szFlag = pResults->GetText("Flag");
int iMinimumValue = pResults->GetInt("MinimumValue");
m_asziFlagPrereqs.push_back(std::make_pair(szFlag, iMinimumValue));
}
}
// END EventEngine
return true;
}
示例4: PerformDatabasePostProcessing
//------------------------------------------------------------------------------
bool CvDllDatabaseUtility::PerformDatabasePostProcessing()
{
//Insert any database methods that you would like performed after the database
//has been fully loaded. This method will execute every single time the game
//is run.
//Updates performed here are done AFTER the database has been built or read
//from cache.
Database::Connection* db = GC.GetGameDatabase();
//Update Defines table from references in PostDefines table
db->BeginTransaction();
Database::Results kPostDefines;
//Build insertion statement
Database::Results kInsert;
db->Execute(kInsert, "INSERT OR REPLACE INTO Defines(Name, Value) VALUES(?, ?)");
db->SelectAll(kPostDefines, "PostDefines");
while(kPostDefines.Step())
{
const char* szName = kPostDefines.GetText("Name");
const char* szKeyName = kPostDefines.GetText("Key");
const char* szTableName = kPostDefines.GetText("Table");
char szSQL[512];
sprintf_s(szSQL, "select ROWID from %s where Type = '%s' LIMIT 1", szTableName, szKeyName);
Database::Results kLookup;
//Compile the command.
if(db->Execute(kLookup, szSQL))
{
//Run the command.
if(kLookup.Step())
{
//Perform insertion
kInsert.Bind(1, szName);
kInsert.Bind(2, kLookup.GetInt(0));
kInsert.Step();
kInsert.Reset();
}
}
}
// ** Modify ResourceUsage of Resources table **
// Set ResourceUsage to 1 if it's referenced in Unit_ResourceQuantityRequirements
// NOTE: This query could be simplified using the IN operator but when analyzed this
// statement generates faster operations.
const char* szStrategicResource
= "UPDATE Resources SET ResourceUsage = 1 WHERE EXISTS (SELECT * FROM Unit_ResourceQuantityRequirements WHERE ResourceType = Type)";
db->Execute(szStrategicResource);
// Set ResourceUsage to 2 if the Resource has a happiness value greater than 0
const char* szLuxoryResource
= "UPDATE Resources SET ResourceUsage = 2 where Happiness > 0";
db->Execute(szLuxoryResource);
//These are hard-coded GameDefines enum values, let's share them with the database so that they
//get the same amount of love as the DB.
Database::Results kInsertDefine;
if(db->Execute(kInsertDefine, "INSERT OR REPLACE INTO Defines(Name, Value) VALUES(?, ?);"))
{
InsertGameDefine(kInsertDefine, "MAX_CIV_PLAYERS", MAX_CIV_PLAYERS);
InsertGameDefine(kInsertDefine, "MAX_CIV_TEAMS", MAX_CIV_TEAMS);
InsertGameDefine(kInsertDefine, "MAX_MAJOR_CIVS", MAX_MAJOR_CIVS);
InsertGameDefine(kInsertDefine, "MAX_MINOR_CIVS", MAX_MINOR_CIVS);
InsertGameDefine(kInsertDefine, "MAX_PLAYERS", MAX_PLAYERS);
InsertGameDefine(kInsertDefine, "MAX_TEAMS", MAX_TEAMS);
InsertGameDefine(kInsertDefine, "BARBARIAN_PLAYER", BARBARIAN_PLAYER);
InsertGameDefine(kInsertDefine, "BARBARIAN_TEAM", BARBARIAN_TEAM);
InsertGameDefine(kInsertDefine, "NUM_CITY_PLOTS", AVG_CITY_PLOTS);
InsertGameDefine(kInsertDefine, "MIN_CITY_RADIUS", MIN_CITY_RADIUS);
InsertGameDefine(kInsertDefine, "MAX_CITY_RADIUS", MAX_CITY_RADIUS);
InsertGameDefine(kInsertDefine, "CITY_HOME_PLOT", CITY_HOME_PLOT);
InsertGameDefine(kInsertDefine, "MAX_CITY_RADIUS", MAX_CITY_RADIUS);
InsertGameDefine(kInsertDefine, "MAX_CITY_DIAMETER", (2*MAX_CITY_RADIUS+1));
}
db->EndTransaction();
return true;
}