2024-06-05 19:04:53 -04:00
|
|
|
#ifndef RFL_JSON_SAVE_HPP_
|
|
|
|
#define RFL_JSON_SAVE_HPP_
|
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
2024-06-08 14:10:59 -04:00
|
|
|
#include <yyjson.h>
|
2024-06-05 19:04:53 -04:00
|
|
|
|
|
|
|
#include "../Result.hpp"
|
|
|
|
#include "../io/save_string.hpp"
|
|
|
|
#include "write.hpp"
|
|
|
|
|
|
|
|
namespace rfl {
|
2024-06-08 14:10:59 -04:00
|
|
|
namespace json {
|
2024-06-05 19:04:53 -04:00
|
|
|
|
2024-06-08 14:10:59 -04:00
|
|
|
template <class... Ps>
|
2024-06-08 15:53:06 -04:00
|
|
|
Result<Nothing> save(
|
|
|
|
const std::string& _fname,
|
|
|
|
const auto& _obj,
|
|
|
|
const yyjson_write_flag _flag = 0
|
|
|
|
) {
|
|
|
|
const auto write_func =
|
|
|
|
[_flag](const auto& _obj, auto& _stream) -> auto& {
|
2024-06-08 14:10:59 -04:00
|
|
|
return write<Ps...>(_obj, _stream, _flag);
|
|
|
|
};
|
|
|
|
return rfl::io::save_string(_fname, _obj, write_func);
|
|
|
|
}
|
2024-06-05 19:04:53 -04:00
|
|
|
|
2024-06-08 14:10:59 -04:00
|
|
|
} // namespace json
|
|
|
|
} // namespace rfl
|
2024-06-05 19:04:53 -04:00
|
|
|
|
|
|
|
#endif
|