项目作者: Makiah

项目描述 :
☃️ Quick method of concisely loading and saving the properties of arbitrarily complex class structures in a text file, provided loading occurs in a known order.
高级语言: C++
项目地址: git://github.com/Makiah/freeze.git
创建时间: 2019-06-03T03:12:14Z
项目社区:https://github.com/Makiah/freeze

开源协议:

下载


freeze

☃️ Quick method of concisely loading and saving the properties of arbitrarily complex class structures in a text file, provided loading occurs in a known order.

Usage

Basic

  1. // data
  2. int someNum = 2;
  3. std::string someString = "string";
  4. bool someBool = false;
  5. std::vector<std::vector<ClassA>> twod = {{ClassA(1), ClassA(2)}, {ClassA(3)}};
  6. freeze::IceBlock i;
  7. i.freeze(someNum);
  8. i.freeze(someString);
  9. i.freeze(someBool);
  10. i.freeze(twod);
  11. i.save("resources/ice.txt");
  12. // ... process exits, new run (order dependent loading)
  13. freeze::IceBlock i = freeze::IceBlock::fromFile("resources/ice.txt");
  14. int someNum = i.melt<int>();
  15. std::string someString = i.melt<std::string>();
  16. bool someBool = i.melt<bool>();
  17. std::vector<std::vector<ClassA>> twod = i.melt<std::vector<std::vector<ClassA>>>();
  18. // proceed with data from last run

Advanced

See example.cpp.

Building

Copy freeze.h and freeze.cpp somewhere into your project and #include "freeze.h" wherever.