c++ yaml文件读写与字符串处理

#include <iostream>
#include "include/yaml.h"
#include<fstream>
#include <cstring>
#include <string>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

using namespace std;
/*
用新的字符(字符串)替换旧的字符(字符串)
*/
std::string& replace_all_distinct(std::string&  str,const std::string&   old_value,const std::string& new_value)
{
    for(std::string::size_type   pos(0);   pos!=std::string::npos;   pos+=new_value.length())
    {
        if((pos=str.find(old_value,pos))!=std::string::npos)
        {
            str.replace(pos,old_value.length(),new_value);
        }
        else
        {
            break;
        }
    }
    return  str;
}
/*
作用: 以字符(子字符串)delim 分割字符串s
参数:delim  子字符,如'\n'
    s 从文件中读出来的字符串
*/
std::vector<std::string> StringSplit2(const  std::string& s, const std::string& delim)
{
    std::vector<std::string> elems;
    size_t pos = 0;
    //字符串长度
    size_t len = s.length();
    //字符
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值