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


C++ string_view::c_str方法代码示例

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


在下文中一共展示了string_view::c_str方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getImpl

bool
ColorConfig::reset (string_view filename)
{
    bool ok = true;
    delete m_impl;

    m_impl = new ColorConfig::Impl;
#ifdef USE_OCIO
    OCIO::SetLoggingLevel (OCIO::LOGGING_LEVEL_NONE);
    try {
        if (filename.empty()) {
            getImpl()->config_ = OCIO::GetCurrentConfig();
        } else {
            getImpl()->config_ = OCIO::Config::CreateFromFile (filename.c_str());
        }
    }
    catch(OCIO::Exception &e) {
        getImpl()->error_ = e.what();
        ok = false;
    }
    catch(...) {
        getImpl()->error_ = "An unknown error occurred in OpenColorIO creating the config";
        ok = false;
    }
#endif

    getImpl()->inventory ();

    // If we populated our own, remove any errors.
    if (getNumColorSpaces() && !getImpl()->error_.empty())
        getImpl()->error_.clear();

    return ok;
}
开发者ID:,项目名称:,代码行数:34,代码来源:

示例2: result

string_view
ColorConfig::parseColorSpaceFromString (string_view str) const
{
#ifdef USE_OCIO
    string_view result (getImpl()->config_->parseColorSpaceFromString (str.c_str()));
    return result;
#else
    return "";
#endif
}
开发者ID:jproccia,项目名称:oiio,代码行数:10,代码来源:color_ocio.cpp

示例3: in

/// Read the entire contents of the named file and place it in str,
/// returning true on success, false on failure.
inline bool
read_text_file (string_view filename, std::string &str)
{
    std::ifstream in (filename.c_str(), std::ios::in | std::ios::binary);
    if (in) {
        std::ostringstream contents;
        contents << in.rdbuf();
        in.close ();
        str = contents.str();
        return true;
    }
    return false;
}
开发者ID:boberfly,项目名称:gafferDependencies,代码行数:15,代码来源:testshade.cpp

示例4:

void
Filesystem::open(OIIO::ofstream& stream, string_view path,
                 std::ios_base::openmode mode)
{
#ifdef _WIN32
    // Windows std::ofstream accepts non-standard wchar_t*
    // On MingW, we use our own OIIO::ofstream
    std::wstring wpath = Strutil::utf8_to_utf16(path);
    stream.open(wpath.c_str(), mode);
#else
    stream.open(path.c_str(), mode);
#endif
}
开发者ID:OpenImageIO,项目名称:oiio,代码行数:13,代码来源:filesystem.cpp

示例5: string_view

string_view
Sysutil::getenv (string_view name)
{
    return string_view (::getenv (name.c_str()));
}
开发者ID:bdeluca,项目名称:oiio,代码行数:5,代码来源:sysutil.cpp

示例6: oso_output

bool
OSLCompilerImpl::compile (string_view filename,
                          const std::vector<std::string> &options,
                          string_view stdoslpath)
{
    if (! OIIO::Filesystem::exists (filename)) {
        error (ustring(), 0, "Input file \"%s\" not found", filename.c_str());
        return false;
    }

    std::vector<std::string> defines;
    std::vector<std::string> includepaths;
#if OIIO_VERSION >= 10604
    m_cwd = OIIO::Filesystem::current_path();
#else
    m_cwd = boost::filesystem::current_path().string();
#endif
    m_main_filename = filename;

    // Determine where the installed shader include directory is, and
    // look for ../shaders/stdosl.h and force it to include.
    if (stdoslpath.empty()) {
        // look in $OSLHOME/shaders
        const char *OSLHOME = getenv ("OSLHOME");
        if (OSLHOME && OSLHOME[0]) {
            std::string path = std::string(OSLHOME) + "/shaders";
            if (OIIO::Filesystem::exists (path)) {
                path = path + "/stdosl.h";
                if (OIIO::Filesystem::exists (path))
                    stdoslpath = ustring(path);
            }
        }
    }
    if (stdoslpath.empty() || ! OIIO::Filesystem::exists(stdoslpath))
        warning (ustring(filename), 0, "Unable to find \"stdosl.h\"");
    else {
        // Add the directory of stdosl.h to the include paths
        includepaths.push_back (OIIO::Filesystem::parent_path (stdoslpath));
    }

    read_compile_options (options, defines, includepaths);

    std::string preprocess_result;
    if (! preprocess_file (filename, stdoslpath,
                           defines, includepaths, preprocess_result)) {
        return false;
    } else if (m_preprocess_only) {
        std::cout << preprocess_result;
    } else {
        bool parseerr = osl_parse_buffer (preprocess_result);
        if (! parseerr) {
            if (shader())
                shader()->typecheck ();
            else
                error (ustring(), 0, "No shader function defined");
        }

        // Print the parse tree if there were no errors
        if (m_debug) {
            symtab().print ();
            if (shader())
                shader()->print (std::cout);
        }

        if (! error_encountered()) {
            shader()->codegen ();
            track_variable_dependencies ();
            track_variable_lifetimes ();
            check_for_illegal_writes ();
//            if (m_optimizelevel >= 1)
//                coalesce_temporaries ();
        }
 
        if (! error_encountered()) {
            if (m_output_filename.size() == 0)
                m_output_filename = default_output_filename ();

            std::ofstream oso_output (m_output_filename.c_str());
            if (! oso_output.good()) {
                error (ustring(), 0, "Could not open \"%s\"",
                       m_output_filename.c_str());
                return false;
            }
            ASSERT (m_osofile == NULL);
            m_osofile = &oso_output;

            write_oso_file (m_output_filename, OIIO::Strutil::join(options," "));
            ASSERT (m_osofile == NULL);
        }

        oslcompiler = NULL;
    }

    return ! error_encountered();
}
开发者ID:HazardousCode,项目名称:OpenShadingLanguage,代码行数:95,代码来源:oslcomp.cpp


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