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


C++ dynamic_string_array类代码示例

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


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

示例1: get_keys

    void ktx_texture::get_keys(dynamic_string_array &keys) const
    {
        keys.resize(0);
        keys.reserve(m_key_values.size());

        for (uint32_t i = 0; i < m_key_values.size(); i++)
        {
            const uint8_vec &v = m_key_values[i];

            keys.enlarge(1)->set(reinterpret_cast<const char *>(v.get_ptr()));
        }
    }
开发者ID:IanAtLunarG,项目名称:vogl,代码行数:12,代码来源:vogl_ktx_texture.cpp

示例2: load_string_file

    bool command_line_params::load_string_file(const char *pFilename, dynamic_string_array &strings)
    {
        cfile_stream in_stream;
        if (!in_stream.open(pFilename, cDataStreamReadable | cDataStreamSeekable))
        {
            console::error("Unable to open file \"%s\" for reading!\n", pFilename);
            return false;
        }

        dynamic_string ansi_str;

        for (;;)
        {
            if (!in_stream.read_line(ansi_str))
                break;

            ansi_str.trim();
            if (ansi_str.is_empty())
                continue;

            strings.push_back(dynamic_string(ansi_str.get_ptr()));
        }

        return true;
    }
开发者ID:IanAtLunarG,项目名称:vogl,代码行数:25,代码来源:vogl_command_line_params.cpp

示例3: get_printable_backtrace

    bool get_printable_backtrace(dynamic_string_array &strings)
    {
        strings.resize(0);

        console::debug("TODO: %s\n", VOGL_FUNCTION_INFO_CSTR);

        return false;
    }
开发者ID:IanAtLunarG,项目名称:vogl,代码行数:8,代码来源:vogl_backtrace.cpp

示例4: read_text_file_crt

bool file_utils::read_text_file_crt(const char *pPath, dynamic_string_array &lines)
{
    FILE *pFile = fopen(pPath, "r");
    if (!pFile)
        return false;

    while (!feof(pFile))
    {
        char buf[4096];
        buf[0] = '\0';
        fgets(buf, sizeof(buf), pFile);
        lines.push_back(buf);
    }

    fclose(pFile);

    return true;
}
开发者ID:Nicky-D,项目名称:vogl,代码行数:18,代码来源:vogl_file_utils.cpp

示例5: write_text_file

bool file_utils::write_text_file(const char *pPath, const dynamic_string_array &lines, bool unix_line_endings)
{
    cfile_stream stream;
    if (!stream.open(pPath, cDataStreamWritable))
        return false;

    for (uint i = 0; i < lines.size(); i++)
    {
        const dynamic_string &str = lines[i];
        if (str.get_len())
            stream.write(str.get_ptr(), str.get_len());

        if (unix_line_endings)
            stream.write("\n", 1);
        else
            stream.write("\r\n", 2);
    }

    return !stream.get_error();
}
开发者ID:Nicky-D,项目名称:vogl,代码行数:20,代码来源:vogl_file_utils.cpp

示例6: read_text_file

// This helper only works on files with valid file sizes (i.e. it won't work on some files under proc such as /proc/self/status).
bool file_utils::read_text_file(const char *pPath, dynamic_string_array &lines, uint flags)
{
    cfile_stream stream;
    if (!stream.open(pPath, cDataStreamReadable))
    {
        if (flags & cRTFPrintErrorMessages)
            console::error("%s: Failed opening text file \"%s\" for reading\n", VOGL_FUNCTION_INFO_CSTR, pPath);
        else if (flags & cRTFPrintWarningMessages)
            console::warning("%s: Failed opening text file \"%s\" for reading\n", VOGL_FUNCTION_INFO_CSTR, pPath);

        return false;
    }

    int line_count = 0;
    dynamic_string line_str;
    while (stream.get_remaining())
    {
        ++line_count;
        if (!stream.read_line(line_str))
        {
            if (flags & cRTFPrintErrorMessages)
                console::error("%s: Failed reading from text file \"%s\"\n", VOGL_FUNCTION_INFO_CSTR, pPath);
            else if (flags & cRTFPrintWarningMessages)
                console::warning("%s: Failed reading from text file \"%s\"\n", VOGL_FUNCTION_INFO_CSTR, pPath);

            break;
        }

        if (flags & cRTFTrim)
            line_str.trim();

        if (flags & cRTFTrimEnd)
            line_str.trim_end();

        if (flags & cRTFIgnoreEmptyLines)
        {
            if (line_str.is_empty())
                continue;
        }

        if ((flags & cRTFIgnoreCommentedLines) && (line_str.get_len() >= 2))
        {
            bool found_comment = false;

            for (int i = 0; i < static_cast<int>(line_str.get_len()); ++i)
            {
                char c = line_str[i];

                if ((c == ' ') || (c == '\t'))
                    continue;
                else if ((c == '/') && (line_str[i + 1] == '/'))
                    found_comment = true;

                break;
            }

            if (found_comment)
                continue;
        }

        lines.push_back(line_str);
    }

    return true;
}
开发者ID:Nicky-D,项目名称:vogl,代码行数:66,代码来源:vogl_file_utils.cpp

示例7: while

    bool command_line_params::parse(const dynamic_string_array &params, uint32_t total_param_descs, const command_line_param_desc *pParam_desc, const command_line_params::parse_config &config)
    {
        m_params = params;

        command_line_param_desc desc;
        desc.m_num_values = 0;
        desc.m_support_listing_file = false;
        desc.m_pName = "";
        desc.m_pDesc = NULL;

        uint32_t arg_index = 0;
        while (arg_index < params.size())
        {
            const uint32_t cur_arg_index = arg_index;
            const dynamic_string &src_param = params[arg_index++];

            if (src_param.is_empty())
                continue;

            bool is_param = false;
            uint32_t param_prefix_chars = 1;

#if VOGL_CMD_LINE_ALLOW_SLASH_PARAMS
            is_param = (src_param[0] == '/');
#endif
            if ((src_param[0] == '-') && ((config.m_single_minus_params) || (config.m_double_minus_params)))
            {
                is_param = true;

                bool double_minus = (src_param[1] == '-');
                if (double_minus)
                {
                    if (config.m_double_minus_params)
                    {
                        param_prefix_chars = 2;
                    }
                    else
                    {
                        if (config.m_ignore_unrecognized_params)
                            continue;

                        console::error("Unrecognized command line parameter: \"%s\"\n", src_param.get_ptr());
                        return false;
                    }
                }
            }

            if (is_param)
            {
                if (src_param.get_len() < (param_prefix_chars + 1))
                {
                    console::warning("Skipping invalid command line parameter: \"%s\"\n", src_param.get_ptr());
                    continue;
                }

                dynamic_string key_str(src_param);

                key_str.right(param_prefix_chars);

                if (config.m_pParam_ignore_prefix)
                {
                    if (key_str.begins_with(config.m_pParam_ignore_prefix, true))
                        continue;
                }

                if (config.m_pParam_accept_prefix)
                {
                    if (!key_str.begins_with(config.m_pParam_accept_prefix, true))
                        continue;
                }

                int modifier = 0;
                char c = key_str[key_str.get_len() - 1];
                if (c == '+')
                    modifier = 1;
                else if (c == '-')
                    modifier = -1;

                if (modifier)
                    key_str.left(key_str.get_len() - 1);

                if (total_param_descs)
                {
                    uint32_t param_index;
                    for (param_index = 0; param_index < total_param_descs; param_index++)
                        if (key_str == pParam_desc[param_index].m_pName)
                            break;

                    if (param_index == total_param_descs)
                    {
                        if (config.m_ignore_unrecognized_params)
                            continue;

                        console::error("Unrecognized command line parameter: \"%s\"\n", src_param.get_ptr());
                        return false;
                    }

                    desc = pParam_desc[param_index];
                }

//.........这里部分代码省略.........
开发者ID:IanAtLunarG,项目名称:vogl,代码行数:101,代码来源:vogl_command_line_params.cpp

示例8: split_command_line_params

    bool split_command_line_params(const char *p, dynamic_string_array &params)
    {
        bool within_param = false;
        bool within_quote = false;

        uint32_t ofs = 0;
        dynamic_string str;

        while (p[ofs])
        {
            const char c = p[ofs];

            if (within_param)
            {
                if (within_quote)
                {
                    if (c == '"')
                        within_quote = false;

                    str.append_char(c);
                }
                else if ((c == ' ') || (c == '\t'))
                {
                    if (!str.is_empty())
                    {
                        params.push_back(str);
                        str.clear();
                    }
                    within_param = false;
                }
                else
                {
                    if (c == '"')
                        within_quote = true;

                    str.append_char(c);
                }
            }
            else if ((c != ' ') && (c != '\t'))
            {
                within_param = true;

                if (c == '"')
                    within_quote = true;

                str.append_char(c);
            }

            ofs++;
        }

        if (within_quote)
        {
            console::error("Unmatched quote in command line \"%s\"\n", p);
            return false;
        }

        if (!str.is_empty())
            params.push_back(str);
        return true;
    }
开发者ID:IanAtLunarG,项目名称:vogl,代码行数:61,代码来源:vogl_command_line_params.cpp

示例9: CRNLIB_ASSERT

   bool command_line_params::parse(const dynamic_string_array& params, uint n, const param_desc* pParam_desc)
   {
      CRNLIB_ASSERT(n && pParam_desc);

      m_params = params;

      uint arg_index = 0;
      while (arg_index < params.size())
      {
         const uint cur_arg_index = arg_index;
         const dynamic_string& src_param = params[arg_index++];

         if (src_param.is_empty())
            continue;
#if CRNLIB_CMD_LINE_ALLOW_SLASH_PARAMS
         if ((src_param[0] == '/') || (src_param[0] == '-'))
#else
         if (src_param[0] == '-')
#endif
         {
            if (src_param.get_len() < 2)
            {
               console::error("Invalid command line parameter: \"%s\"", src_param.get_ptr());
               return false;
            }

            dynamic_string key_str(src_param);

            key_str.right(1);

            int modifier = 0;
            char c = key_str[key_str.get_len() - 1];
            if (c == '+')
               modifier = 1;
            else if (c == '-')
               modifier = -1;

            if (modifier)
               key_str.left(key_str.get_len() - 1);

            uint param_index;
            for (param_index = 0; param_index < n; param_index++)
               if (key_str == pParam_desc[param_index].m_pName)
                  break;

            if (param_index == n)
            {
               console::error("Unrecognized command line parameter: \"%s\"", src_param.get_ptr());
               return false;
            }

            const param_desc& desc = pParam_desc[param_index];

            const uint cMaxValues = 16;
            dynamic_string val_str[cMaxValues];
            uint num_val_strs = 0;
            if (desc.m_num_values)
            {
               CRNLIB_ASSERT(desc.m_num_values <= cMaxValues);

               if ((arg_index + desc.m_num_values) > params.size())
               {
                  console::error("Expected %u value(s) after command line parameter: \"%s\"", desc.m_num_values, src_param.get_ptr());
                  return false;
               }

               for (uint v = 0; v < desc.m_num_values; v++)
                  val_str[num_val_strs++] = params[arg_index++];
            }

            dynamic_string_array strings;

            if ((desc.m_support_listing_file) && (val_str[0].get_len() >= 2) && (val_str[0][0] == '@'))
            {
               dynamic_string filename(val_str[0]);
               filename.right(1);
               filename.unquote();

               if (!load_string_file(filename.get_ptr(), strings))
               {
                  console::error("Failed loading listing file \"%s\"!", filename.get_ptr());
                  return false;
               }
            }
            else
            {
               for (uint v = 0; v < num_val_strs; v++)
               {
                  val_str[v].unquote();
                  strings.push_back(val_str[v]);
               }
            }

            param_value pv;
            pv.m_values.swap(strings);
            pv.m_index = cur_arg_index;
            pv.m_modifier = (int8)modifier;
            m_param_map.insert(std::make_pair(key_str, pv));
         }
         else
//.........这里部分代码省略.........
开发者ID:PixelTours,项目名称:crunch-osx,代码行数:101,代码来源:crn_command_line_params.cpp


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