Skip to content

coost v3.0.0 released

Compare
Choose a tag to compare
@idealvin idealvin released this 02 Sep 04:36
· 257 commits to master since this release

New features & improvement

  • Improve cmake scripts and support Conan. Improve export of symbols in shared library. Thanks to SpaceIm.

  • A better JSON library. Support precision control for float point numbers in Json.

    // {"a":23,"b":false,"s":"xx","v":[1,2,3],"o":{"xx":0}}
    Json x = {
        { "a", 23 },
        { "b", false },
        { "s", "xx" },
        { "v", {1,2,3} },
        { "o", {
            {"xx", 0}
        }},
    };
    
    // equal to x
    Json y = Json()
        .add_member("a", 23)
        .add_member("b", false)
        .add_member("s", "xx")
        .add_member("v", Json().push_back(1).push_back(2).push_back(3))
        .add_member("o", Json().add_member("xx", 0));
    
    x.get("a").as_int();       // 23
    x.get("s").as_string();    // "xx"
    x.get("v", 0).as_int();    // 1
    x.get("v", 2).as_int();    // 3
    x.get("o", "xx").as_int(); // 0
  • Add TLOG to print logs which are grouped by topics.

    TLOG("rpc") << "hello " << 23;
    TLOG("xxx") << "hello " << 23;
  • Improve exception handling in co/log on Windows. Thanks to 909254.

  • Remove path from __FILE__ in co/log.

  • Support alias for flag. Add api flag::alias().

    DEF_bool(debug, false, "");         // no alias
    DEF_bool(debug, false, "", d);      // d is an alias of debug
    DEF_bool(debug, false, "", d, dbg); // 2 aliases
  • Ignore non-existing flags in config file.

  • Add --version for co/flag.

  • --help shows only user-defined flags in co/flag by default, and limit flag level to [0-9].

  • Add api flag::set_value() for setting value of a flag.

  • Add log::set_write_cb() to set a callback for writting logs.

  • Add macros __arch64, __arch32, __fname__ and __fnlen__ in co/def.h.

  • Add a fast memory allocator. Provide co::stl_allocator for STL.

  • Provide containers based on co::stl_allocator. See co/stl.h for details.

  • Improve atomic operations, support memory order. Add atomic_cas as an alias of atomic_compare_swap and add atomic_bool_cas.

  • Add nanoid(), md5digest(), sha256() in co/hash.h.

  • Support HTTP protocol for JSON-based RPC framework.

  • Support graceful exit for tcp::Server, http::Server, rpc::Server.

  • Add fs::dir for readding directory.

  • Support + mode for both read and write for fs::file.

  • Support precision control for float point numbers.

    fastream s;
    s << 3.14159; // "3.14159"
    
    s.clear();
    s.maxdp(3) << 3.14159; // "3.141"
    
    s.clear();
    s << co::maxdp(2) << 3.14159; // "3.14"
    
    LOG << co::maxdp(2) << 1.234e-7; // "1.23e-7"
  • Improve hook on macos with fishhook. Thanks to shuai132.

Changed

  • Remove flag a from co/unitest, run all tests by default.

  • Remove log::init(), log::close(), log::set_single_write_cb().

  • Remove co::init(), co::exit().

  • Rename co::all_schedulers() to co::schedulers().

  • Rename co::Table to co::table.

  • Remove atomic_get, use atomic_load instead.

  • Remove atomic_set, use atomic_store instead.

  • Remove atomic_reset, use atomic_store(&x, 0) instead.

  • Remove err::get(), err::set(), use co::error() instead.

Bugs fixed