当前位置: 首页>>代码示例>>C++>>正文


C++ TSTR::FromUTF8方法代码示例

本文整理汇总了C++中TSTR::FromUTF8方法的典型用法代码示例。如果您正苦于以下问题:C++ TSTR::FromUTF8方法的具体用法?C++ TSTR::FromUTF8怎么用?C++ TSTR::FromUTF8使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TSTR的用法示例。


在下文中一共展示了TSTR::FromUTF8方法的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))
//.........这里部分代码省略.........
开发者ID:nixz,项目名称:covise,代码行数:101,代码来源:cal3dHelper.cpp


注:本文中的TSTR::FromUTF8方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。