本文整理汇总了C++中StringStream::ToString方法的典型用法代码示例。如果您正苦于以下问题:C++ StringStream::ToString方法的具体用法?C++ StringStream::ToString怎么用?C++ StringStream::ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringStream
的用法示例。
在下文中一共展示了StringStream::ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DumpStack
String LuaState::DumpStack() const
{
StringStream stream;
unsigned int stackTop = GetStackTop();
stream << stackTop << " entries\n";
for (unsigned int i = 1; i <= stackTop; ++i)
{
stream << i << ": ";
switch (GetType(i))
{
case LuaType_Boolean:
stream << "Boolean(" << ToBoolean(i) << ')';
break;
case LuaType_Function:
stream << "Function(" << ToPointer(i) << ')';
break;
case LuaType_LightUserdata:
case LuaType_Userdata:
stream << "Userdata(" << ToUserdata(i) << ')';
break;
case LuaType_Nil:
stream << "Nil";
break;
case LuaType_None:
stream << "None";
break;
case LuaType_Number:
stream << "Number(" << ToNumber(i) << ')';
break;
case LuaType_String:
stream << "String(" << ToString(i) << ')';
break;
case LuaType_Table:
stream << "Table(" << ToPointer(i) << ')';
break;
case LuaType_Thread:
stream << "Thread(" << ToPointer(i) << ')';
break;
default:
stream << "Unknown(" << ToPointer(i) << ')';
break;
}
stream << '\n';
}
return stream.ToString();
}
示例2: domain_error
UInt32 TriangleIterator::operator[](unsigned int i) const
{
#if NAZARA_UTILITY_SAFE
if (i >= 3)
{
StringStream ss;
ss << "Index out of range: (" << i << " >= 3)";
NazaraError(ss);
throw std::domain_error(ss.ToString());
}
#endif
return m_triangleIndices[i];
}
示例3: ResizeBuffer
void ParticleGroup::ResizeBuffer()
{
// Just to have a better description of our problem in case of error
try
{
m_buffer.resize(m_maxParticleCount*m_particleSize);
}
catch (const std::exception& e)
{
StringStream stream;
stream << "Failed to allocate particle buffer (" << e.what() << ") for " << m_maxParticleCount << " particles of size " << m_particleSize;
NazaraError(stream.ToString());
}
}
示例4: Show
String Continuation::Show() const
{
StringStream str;
int around = 4;
auto current = *index;
auto min = std::max(0, current - around);
auto max = std::min(code->Size() - 1, current + around);
str << "IP=" << current << "\n";
for (int n = min; n < max; ++n)
{
if (n == current - 1)
str << ">>> ";
str << code->At(n) << "\n";
}
return str.ToString();
}
示例5: Get
UberShaderInstance* UberShaderPreprocessor::Get(const ParameterList& parameters) const
{
// Première étape, transformer les paramètres en un flag
UInt32 flags = 0;
for (auto it = m_flags.begin(); it != m_flags.end(); ++it)
{
if (parameters.HasParameter(it->first))
{
bool value;
if (parameters.GetBooleanParameter(it->first, &value) && value)
flags |= it->second;
}
}
// Le shader fait-il partie du cache ?
auto shaderIt = m_cache.find(flags);
// Si non, il nous faut le construire
if (shaderIt == m_cache.end())
{
try
{
// Une exception sera lancée à la moindre erreur et celle-ci ne sera pas enregistrée dans le log (car traitée dans le bloc catch)
ErrorFlags errFlags(ErrorFlag_Silent | ErrorFlag_ThrowException, true);
ShaderRef shader = Shader::New();
shader->Create();
for (unsigned int i = 0; i <= ShaderStageType_Max; ++i)
{
const CachedShader& shaderStage = m_shaders[i];
// Le shader stage est-il activé dans cette version du shader ?
if (shaderStage.present && (flags & shaderStage.requiredFlags) == shaderStage.requiredFlags)
{
UInt32 stageFlags = 0;
for (auto it = shaderStage.flags.begin(); it != shaderStage.flags.end(); ++it)
{
if (parameters.HasParameter(it->first))
{
bool value;
if (parameters.GetBooleanParameter(it->first, &value) && value)
stageFlags |= it->second;
}
}
auto stageIt = shaderStage.cache.find(stageFlags);
if (stageIt == shaderStage.cache.end())
{
ShaderStage stage;
stage.Create(static_cast<ShaderStageType>(i));
unsigned int glslVersion = OpenGL::GetGLSLVersion();
StringStream code;
code << "#version " << glslVersion << "\n\n";
code << "#define GLSL_VERSION " << glslVersion << "\n\n";
code << "#define EARLY_FRAGMENT_TESTS " << ((glslVersion >= 420 || OpenGL::IsSupported(OpenGLExtension_Shader_ImageLoadStore)) ? '1' : '0') << "\n\n";
for (auto it = shaderStage.flags.begin(); it != shaderStage.flags.end(); ++it)
code << "#define " << it->first << ' ' << ((stageFlags & it->second) ? '1' : '0') << '\n';
code << "\n#line 1\n"; // Pour que les éventuelles erreurs du shader se réfèrent à la bonne ligne
code << shaderStage.source;
stage.SetSource(code);
try
{
stage.Compile();
}
catch (const std::exception&)
{
ErrorFlags errFlags2(ErrorFlag_ThrowExceptionDisabled);
NazaraError("Shader code failed to compile (" + stage.GetLog() + ")\n" + code.ToString());
throw;
}
stageIt = shaderStage.cache.emplace(flags, std::move(stage)).first;
}
shader->AttachStage(static_cast<ShaderStageType>(i), stageIt->second);
}
}
shader->Link();
// On construit l'instant
shaderIt = m_cache.emplace(flags, shader.Get()).first;
}
catch (const std::exception&)
{
ErrorFlags errFlags(ErrorFlag_ThrowExceptionDisabled);
NazaraError("Failed to build UberShader instance: " + Error::GetLastError());
throw;
}
//.........这里部分代码省略.........