本文整理汇总了C++中ConstantArray::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstantArray::push_back方法的具体用法?C++ ConstantArray::push_back怎么用?C++ ConstantArray::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConstantArray
的用法示例。
在下文中一共展示了ConstantArray::push_back方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetConstant
//----------------------------------------------------------------------------
bool FxCompiler::GetConstant (const TokenArray& tokens,
const std::string& name, Shader::VariableType type,
ConstantArray& constants)
{
std::string::size_type begin, end;
if (tokens[5].size() < 4
|| tokens[5][0] != 'c'
|| tokens[5][1] != '['
|| (end = tokens[5].find("]", 0)) == std::string::npos)
{
ReportError("Expecting 'c[register]' token", &tokens);
return false;
}
// Get the base register for the constant.
begin = 2; // character after '['
std::string number = tokens[5].substr(begin, end - begin);
int baseRegister = atoi(number.c_str());
if (baseRegister == 0 && number != "0")
{
ReportError("Invalid base register", &tokens);
return false;
}
// Get the number of registers used by the constant.
int numRegistersUsed;
if (tokens[5].find(",", 0) == std::string::npos)
{
// The constant uses one register.
numRegistersUsed = 1;
}
else
{
// The constant uses more than one register.
numRegistersUsed = atoi(tokens[6].c_str());
if (numRegistersUsed == 0)
{
ReportError("Invalid number of registers", &tokens);
return false;
}
}
Constant constant;
constant.Name = name;
constant.Type = type;
constant.BaseRegister = baseRegister;
constant.NumRegistersUsed = numRegistersUsed;
constants.push_back(constant);
return true;
}