本文整理汇总了C++中TSTR::ToCStr方法的典型用法代码示例。如果您正苦于以下问题:C++ TSTR::ToCStr方法的具体用法?C++ TSTR::ToCStr怎么用?C++ TSTR::ToCStr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TSTR
的用法示例。
在下文中一共展示了TSTR::ToCStr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
bool Cal3DCoreHelper::loadCfg(const std::string &strFilename)
{
// open the model configuration file
m_name = strFilename;
#if MAX_PRODUCT_VERSION_MAJOR > 14
TSTR tmpN;
tmpN.FromUTF8(m_name.c_str());
TSTR tmpName = myVRMLName(tmpN);
m_VrmlName = tmpName.ToCStr().data();
#else
m_VrmlName = myVRMLName(m_name.c_str());
#endif
std::ifstream file;
file.open(strFilename.c_str(), std::ios::in | std::ios::binary);
if (!file)
{
std::cerr << "Failed to open model configuration file '" << strFilename << "'." << std::endl;
return false;
}
size_t pathend = strFilename.find_last_of("/\\");
if (pathend != std::string::npos)
{
m_path = strFilename.substr(0, pathend + 1);
}
// initialize the data path
std::string strPath = m_path;
// initialize the animation count
m_animationCount = 0;
// parse all lines from the model configuration file
int line;
for (line = 1;; line++)
{
// read the next model configuration line
std::string strBuffer;
std::getline(file, strBuffer);
// stop if we reached the end of file
if (file.eof())
break;
// check if an error happened while reading from the file
if (!file)
{
std::cerr << "Error while reading from the model configuration file '" << strFilename << "'." << std::endl;
return false;
}
// find the first non-whitespace character
std::string::size_type pos;
pos = strBuffer.find_first_not_of(" \t");
// check for empty lines
if ((pos == std::string::npos) || (strBuffer[pos] == '\n') || (strBuffer[pos] == '\r') || (strBuffer[pos] == 0))
continue;
// check for comment lines
if (strBuffer[pos] == '#')
continue;
// get the key
std::string strKey;
strKey = strBuffer.substr(pos, strBuffer.find_first_of(" =\t\n\r", pos) - pos);
pos += strKey.size();
// get the '=' character
pos = strBuffer.find_first_not_of(" \t", pos);
if ((pos == std::string::npos) || (strBuffer[pos] != '='))
{
std::cerr << strFilename << "(" << line << "): Invalid syntax." << std::endl;
return false;
}
// find the first non-whitespace character after the '=' character
pos = strBuffer.find_first_not_of(" \t", pos + 1);
// get the data
std::string strData;
strData = strBuffer.substr(pos, strBuffer.find_first_of("\n\r", pos) - pos);
// handle the model creation
if (strKey == "scale")
{
// set rendering scale factor
m_renderScale = (float)atof(strData.c_str());
}
else if (strKey == "path")
{
// set the new path for the data files if one hasn't been set already
if (m_path == "")
strPath = strData;
}
else if (strKey == "skeleton")
{
// load core skeleton
std::cout << "Loading skeleton '" << strData << "'..." << std::endl;
if (!m_calCoreModel->loadCoreSkeleton(strPath + strData))
//.........这里部分代码省略.........