Giter VIP home page Giter VIP logo

readwriteini's Introduction

rw_ini_base

使用C++标准库解析ini格式文件,只提供解析后的表和写入函数,查询、修改等功能可自行添加函数

类型说明

节点基类

    /**
     * 节点基类
     */
    class node_base {
    public:
        // 行上注释
        std::vector<std::string> line_up_explain{};
        // 行尾注释
        std::string line_tail_explain{};
    };

section类

    /**
     * section节点类
     */
    class section : public node_base {
    public:
        // section名字
        std::string name{};
        // 所属键值表
        std::vector<key_value> table{};

        section() = default;

        explicit section(std::string name) : name(std::move(name)) {}

        bool operator==(const section &s) const {
            return name == s.name;
        }
    };

键值对类

    /**
     * key_value 键值对类
     */
    class key_value : public node_base {
    public:
        //
        std::string key{};
        //
        std::string value{};

        bool operator==(const key_value &k_v) const {
            return key == k_v.key;
        }
    };

封装问题

示例

class rw_ini_test : public rw_ini::rw_ini_base {
public:
    explicit rw_ini_test(const std::string &ini_path) : rw_ini::rw_ini_base(ini_path) {}
    // 从rw_ini::rw_ini_base类继承到了解析结果集std::vector<section> s_list
    // 以及写入函数rw_ini::rw_ini_base::write()
    // 可以封装自己喜欢的api
};

说明

  1. 可通过 std::vector<section> s_list 直接查找 section 对象并或其所属键值对列表,可直接进行修改值操作,修改完成后可执行写入函数写入文件。
  2. 可调用成员函数void rw_ini::rw_ini_base::write()对源文件进行更新

readwriteini's People

Contributors

windsnowli avatar

Stargazers

AShen avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar 西瓜 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.