zoukankan      html  css  js  c++  java
  • paip.c++ bcb string 转换操作大总结.

    paip.c++ bcb string 转换操作大总结.

    1.StringTrimleft  (customzi)
    2.int2str   (customzi)
    3.replace_all  (customzi)
    4.StringTrimleftAndTab  (customzi)
    5.UnicodeString >>string          string line=  this->Edit1->Text.t_str();
    6.stirng  >> String                 (  UnicodeString strA = stirng.c_str();)
    7.StrToInt   (vcl/sysUtil.hpp)


    作者Attilax ,  EMAIL:1466519819@qq.com
    来源:attilax的专栏
    地址:http://blog.csdn.net/attilax


    void StringTrimleftCa(::std::string & str)
    {
    //left
    str.erase(0,str.find_first_not_of("\r\t\n "));
    //str.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
    //right
    //str.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
    }

     string StringTrimleft(string str)
     {
        string str2=str;
        StringTrimleftCa(str2);
        return str2;

     }
     
     #include <strstream>
     string int2str(int&i) {
     string s;
    stringstream ss(s);
    ss <<i;

    return ss.str();
    }


    string&   replace_all(string&   str,const   string&   old_value,const   string&   new_value)
    {
        while(true)   {
            string::size_type   pos(0);
            if(   (pos=str.find(old_value))!=string::npos   )
                str.replace(pos,old_value.length(),new_value);
            else   break;
        }
        return   str;
    }

      string StringTrimleftAndTab(string str)
     {
        string str2=str;
         treex* tx=new treex();
     string line2= tx-> convertLeft2space (str );

     string lineTrimed=StringTrimleft( line2);
        return lineTrimed;

     }
     
     
     
    string treex::convertLeft2space(string line)
    {
      line=replace_all(line,"│","  ");
       line=replace_all(line,"├","  ");
        line=replace_all(line,"─","  ");
        line=replace_all(line,"└","  ");

      return line;
    }


     int treex::indentLevel(string line)
    {
     string line2=  convertLeft2space (line );

     string lineTrimed=StringTrimleft( line2);
     int lineTrimedLenth=lineTrimed.length();
       int n= line2.length()- lineTrimedLenth ;
       int level=n/4;
       return level;
    }

  • 相关阅读:
    django的模板层
    django的视图层
    django的路由层
    web应用与http协议
    索引
    pymysql模块的使用
    多表查询
    单表查询
    数据的增删改
    自定义form组件
  • 原文地址:https://www.cnblogs.com/attilax/p/15199479.html
Copyright © 2011-2022 走看看