本文整理汇总了C++中Type::GetString方法的典型用法代码示例。如果您正苦于以下问题:C++ Type::GetString方法的具体用法?C++ Type::GetString怎么用?C++ Type::GetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Type
的用法示例。
在下文中一共展示了Type::GetString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Operate
Type* Negative::Operate()
{
std::stringstream ss("");
Type* lValue = GetNextValue();
Type* rValue = GetNextValue();
if (lValue == nullptr || rValue == nullptr)
{
return new Error("Either or both values point to nothing!", Error::OperationError);
}
else if (TypeResolution() == "Error")
{
return new Error(rValue->GetString(), static_cast<Error::ErrorID>(rValue->GetInt()));
}
else if (TypeResolution() == "Int")
{
ss << -lValue->GetInt();
return new Int(ss.str());
}
else if (TypeResolution() == "Float")
{
ss << -lValue->GetFloat();
return new Float(ss.str());
}
return new Error("Type must resolve to either Int or Float", Error::OperationError);
}
示例2: Operate
Type* LogicalAnd::Operate()
{
bool retVal = false;
Type* lValue = GetNextValue();
Type* rValue = GetNextValue();
if (lValue == nullptr || rValue == nullptr)
{
return new Error("Either or both values point to nothing!", Error::OperationError);
}
else if (TypeResolution() == "Error")
{
return new Error(rValue->GetString(), static_cast<Error::ErrorID>(rValue->GetInt()));
}
else if (TypeResolution() == "Int")
{
retVal = lValue->GetInt() && rValue->GetInt();
}
else if (TypeResolution() == "Bool")
{
retVal = lValue->GetInt() && rValue->GetInt();
}
else
return new Error("Expected comparable values: bool or int.", Error::ErrorID::OperationError);
if (retVal == true)
return new Bool("true");
else
return new Bool("false");
}
示例3: Operate
Type* Modulus::Operate()
{
std::stringstream ss("");
Type* lValue = GetNextValue();
Type* rValue = GetNextValue();
if (lValue == nullptr || rValue == nullptr)
{
return new Error("Either or both values point to nothing!", Error::OperationError);
}
else if (TypeResolution() == "Error")
{
return new Error(rValue->GetString(), static_cast<Error::ErrorID>(rValue->GetInt()));
}
else if (TypeResolution() == "Int")
{
//this should never happen!:
if (lValue == nullptr || rValue == nullptr)
return nullptr;
if (rValue->GetInt() == 0);
{
return new Error("Can't divide by zero!", Error::OperationError);
}
ss << lValue->GetInt() % rValue->GetInt();
return new Int(ss.str());
}
return new Error("Type must resolve to an Int", Error::OperationError);
}