Properties file library for C (or C++)

前端 未结 4 1247
难免孤独
难免孤独 2020-12-04 20:28

The title is pretty self-explanatory: does anyone know of a (good) properties file reader library for C or, if not, C++?

Edit: To be specific, I want a library which

4条回答
  •  借酒劲吻你
    2020-12-04 21:05

    Poco also has an Implementation for Reading PropertyFiles http://pocoproject.org/docs/Poco.Util.PropertyFileConfiguration.html

    A Simple example copied from here: http://pocoproject.org/slides/180-Configuration.pdf

    Property file content:

    # a comment
    ! another comment
    key1 = value1
    key2: 123
    key3.longValue = this is a very \
    long value
    path = c:\\test.dat
    

    Code example

    #include 
    using Poco::AutoPtr;
    using Poco::Util::PropertyFileConfiguration;
    AutoPtr pConf;
    pConf = new PropertyFileConfiguration("test.properties");
    std::string key1 = pConf->getString("key1");
    int value = pConf->getInt("key2");
    std::string longVal = pConf->getString("key3.longValue");
    

提交回复
热议问题