• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ dynamic_string类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: defined

bool file_utils::full_path(dynamic_string &path)
{
#if defined(PLATFORM_WINDOWS)
    char buf[1024];
    char *p = _fullpath(buf, path.get_ptr(), sizeof(buf));
    if (!p)
        return false;
#else
    char buf[PATH_MAX];
    char *p;
    dynamic_string pn, fn;
    split_path(path.get_ptr(), pn, fn);
    if ((fn == ".") || (fn == ".."))
    {
        p = realpath(path.get_ptr(), buf);
        if (!p)
            return false;
        path.set(buf);
    }
    else
    {
        if (pn.is_empty())
            pn = "./";
        p = realpath(pn.get_ptr(), buf);
        if (!p)
            return false;
        combine_path(path, buf, fn.get_ptr());
    }
#endif

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


示例2: write_line

   bool data_stream::write_line(const dynamic_string& str)
   {
      if (!str.is_empty())
         return write(str.get_ptr(), str.get_len()) == str.get_len();

      return true;
   }
开发者ID:1nstant,项目名称:xenia,代码行数:7,代码来源:crn_data_stream.cpp


示例3: combine_path_and_extension

void file_utils::combine_path_and_extension(dynamic_string &dst, const char *pA, const char *pB, const char *pC, const char *pExt)
{
    combine_path(dst, pA, pB, pC);

    if ((!dst.ends_with(".")) && (pExt[0]) && (pExt[0] != '.'))
        dst.append_char('.');

    dst.append(pExt);
}
开发者ID:Nicky-D,项目名称:vogl,代码行数:9,代码来源:vogl_file_utils.cpp


示例4: VOGL_NOTE_UNUSED

bool file_utils::create_directories_from_full_path(const dynamic_string &fullpath)
{
    bool got_unc = false;
    VOGL_NOTE_UNUSED(got_unc);
    dynamic_string cur_path;

    const int l = fullpath.get_len();

    int n = 0;
    while (n < l)
    {
        const char c = fullpath.get_ptr()[n];

        const bool sep = is_path_separator(c);
        const bool back_sep = is_path_separator(cur_path.back());
        const bool is_last_char = (n == (l - 1));

        if (((sep) && (!back_sep)) || (is_last_char))
        {
            if ((is_last_char) && (!sep))
                cur_path.append_char(c);

            bool valid = !cur_path.is_empty();

#if defined(PLATFORM_WINDOWS)
            // reject obvious stuff (drives, beginning of UNC paths):
            // c:\b\cool
            // \\machine\blah
            // \cool\blah
            if ((cur_path.get_len() == 2) && (cur_path[1] == ':'))
                valid = false;
            else if ((cur_path.get_len() >= 2) && (cur_path[0] == '\\') && (cur_path[1] == '\\'))
            {
                if (!got_unc)
                    valid = false;
                got_unc = true;
            }
            else if (cur_path == "\\")
                valid = false;
#endif
            if (cur_path == "/")
                valid = false;

            if (valid)
            {
                create_directory(cur_path.get_ptr());
            }
        }

        cur_path.append_char(c);

        n++;
    }

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


示例5: write_string_to_file

bool file_utils::write_string_to_file(const char *pPath, const dynamic_string &str)
{
    cfile_stream stream;
    if (!stream.open(pPath, cDataStreamWritable))
        return false;

    if (str.get_len())
        stream.write(str.get_ptr(), str.get_len());

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


示例6: get_command_line

   void get_command_line(dynamic_string& cmd_line, int argc, char *argv[])
   {
      argc, argv;
#if CRNLIB_USE_WIN32_API
      cmd_line.set(GetCommandLineA());
#else
      cmd_line.clear();
      for (int i = 0; i < argc; i++)
      {
         dynamic_string tmp(argv[i]);
         if ((tmp.front() != '"') && (tmp.front() != '-') && (tmp.front() != '@'))
            tmp = "\"" + tmp + "\"";
         if (cmd_line.get_len())
            cmd_line += " ";
         cmd_line += tmp;
      }
#endif
   }
开发者ID:svn2github,项目名称:crunch,代码行数:18,代码来源:crn_command_line_params.cpp


示例7: get_command_line_as_single_string

   void get_command_line_as_single_string(dynamic_string& cmd_line, int argc, char *argv[])
   {
      argc, argv;
#if false && CRNLIB_USE_WIN32_API // THIS DOES NOT WORK PROPERLY, ADDING TOO MANY QUOTES, SO WE IGNORE IT.
      cmd_line.set(GetCommandLineA());
#else
      cmd_line.clear();
      for (int i = 0; i < argc; i++)
      {
         dynamic_string tmp(argv[i]);
         if ((tmp.front() != '"') && (tmp.front() != '-') && (tmp.front() != '@')) 
            tmp = "\"" + tmp + "\"";
         if (cmd_line.get_len())
            cmd_line += " ";
         cmd_line += tmp;
      }
#endif
   }
开发者ID:PixelTours,项目名称:crunch-osx,代码行数:18,代码来源:crn_command_line_params.cpp


示例8: ext

bool file_utils::add_default_extension(dynamic_string &path, const char *pExt)
{
    dynamic_string ext(path);
    get_extension(ext);
    if (ext.is_empty())
    {
        path.append(pExt);
        return true;
    }
    return false;
}
开发者ID:Nicky-D,项目名称:vogl,代码行数:11,代码来源:vogl_file_utils.cpp


示例9: remove_extension

bool file_utils::remove_extension(dynamic_string &filename)
{
    int sep = -1;
#if defined(PLATFORM_WINDOWS)
    int rightmost_backslash = filename.find_right('\\');
    int rightmost_forwardslash = filename.find_right('/');
    sep = VOGL_MAX(rightmost_backslash,
                   rightmost_forwardslash);
#endif
    if (sep < 0)
        sep = filename.find_right('/');

    int dot = filename.find_right('.');
    if (dot < sep)
        return false;

    filename.left(dot);

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


示例10: get_value_as_string

   bool command_line_params::get_value_as_string(const char* pKey, uint index, dynamic_string& value, uint value_index) const
   {
      param_map_const_iterator it = get_param(pKey, index);
      if ((it == end()) || (value_index >= it->second.m_values.size()))
      {
         value.empty();
         return false;
      }

      value = it->second.m_values[value_index];
      return true;
   }
开发者ID:PixelTours,项目名称:crunch-osx,代码行数:12,代码来源:crn_command_line_params.cpp


示例11: temp

void file_utils::combine_path(dynamic_string &dst, const char *pA, const char *pB)
{
    dynamic_string temp(pA);
    if ((!temp.is_empty()) && (!is_path_separator(pB[0])))
    {
        char c = temp[temp.get_len() - 1];
        if (!is_path_separator(c))
            temp.append_char(VOGL_PATH_SEPERATOR_CHAR);
    }
    temp += pB;
    dst.swap(temp);
}
开发者ID:Nicky-D,项目名称:vogl,代码行数:12,代码来源:vogl_file_utils.cpp


示例12: get_key_value_as_string

    bool ktx_texture::get_key_value_as_string(const char *pKey, dynamic_string &str) const
    {
        const uint8_vec *p = find_key(pKey);
        if (!p)
        {
            str.clear();
            return false;
        }

        const uint32_t ofs = vogl_strlen(pKey) + 1;
        const uint8_t *pValue = p->get_ptr() + ofs;
        const uint32_t n = p->size() - ofs;

        uint32_t i;
        for (i = 0; i < n; i++)
            if (!pValue[i])
                break;

        str.set_from_buf(pValue, i);
        return true;
    }
开发者ID:IanAtLunarG,项目名称:vogl,代码行数:21,代码来源:vogl_ktx_texture.cpp


示例13: read_line

    bool data_stream::read_line(dynamic_string &str)
    {
        str.empty();

        for (;;)
        {
            const int c = read_byte();

            const bool prev_got_cr = m_got_cr;
            m_got_cr = false;

            if (c < 0)
            {
                if (!str.is_empty())
                    break;

                return false;
            }
            // ignores DOS EOF, assumes it's at the very end of the file
            else if ((26 == c) || (!c))
                continue;
            else if (13 == c)
            {
                m_got_cr = true;
                break;
            }
            else if (10 == c)
            {
                if (prev_got_cr)
                    continue;

                break;
            }

            str.append_char(static_cast<char>(c));
        }

        return true;
    }
开发者ID:Daft-Freak,项目名称:vogl,代码行数:39,代码来源:vogl_data_stream.cpp


示例14: read_line

    bool data_stream::read_line(dynamic_string &str)
    {
        str.empty();

        for (;;)
        {
            // Can't be const--need to deal with Mac OS9 style line endings via substition
            const int c = read_byte();

            if (c < 0)
            {
                if (!str.is_empty())
                    break;

                return false;
            }
            // ignores DOS EOF, assumes it's at the very end of the file
            else if ((26 == c) || (!c))
                continue;
            else if (c_CR == c)
            {
                // This path handles OS9 and Windows style line endings.
                // Check to see if the next character is a LF, if so eat that one too.
                if (c_LF == peek_byte()) {
                    read_byte();
                }
                break;
            }
            else if (c_LF == c)
            {
                // UNIX style line endings.
                break;
            }

            str.append_char(static_cast<char>(c));
        }

        return true;
    }
开发者ID:Cyberbanan,项目名称:vogl,代码行数:39,代码来源:vogl_data_stream.cpp


示例15: get_value_as_string

    bool command_line_params::get_value_as_string(dynamic_string &value, const char *pKey, uint32_t key_index, const char *pDef, uint32_t value_index) const
    {
        param_map_const_iterator it = get_param(pKey, key_index);
        if (it == end())
            return false;
        if (value_index >= it->second.m_values.size())
        {
            vogl::console::debug("%s: Trying to retrieve value %u of command line parameter %s, but this parameter only has %u values\n", VOGL_FUNCTION_INFO_CSTR, value_index, pKey, it->second.m_values.size());
            value.set(pDef);
            return false;
        }

        value = it->second.m_values[value_index];
        return true;
    }
开发者ID:IanAtLunarG,项目名称:vogl,代码行数:15,代码来源:vogl_command_line_params.cpp


示例16: trim_trailing_seperator

void file_utils::trim_trailing_seperator(dynamic_string &path)
{
    if ((path.get_len()) && (is_path_separator(path.back())))
        path.truncate(path.get_len() - 1);
}
开发者ID:Nicky-D,项目名称:vogl,代码行数:5,代码来源:vogl_file_utils.cpp


示例17: combine_path

void file_utils::combine_path(dynamic_string &dst, const char *pA, const char *pB, const char *pC)
{
    combine_path(dst, pA, pB);
    combine_path(dst, dst.get_ptr(), pC);
}
开发者ID:Nicky-D,项目名称:vogl,代码行数:5,代码来源:vogl_file_utils.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ dynamic_string_array类代码示例发布时间:2022-05-31
下一篇:
C++ dynamic_properties类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap