MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ write()

template<typename T >
bool MayaFlux::IO::JSONSerializer::write ( const std::string &  path,
const T value,
int  indent = 2 
)
inline

Encode value and write to path (created or truncated).

Returns
True on success. On failure call last_error().

Definition at line 64 of file JSONSerializer.hpp.

65 {
66 m_last_error.clear();
67 std::ofstream file(path, std::ios::out | std::ios::trunc);
68 if (!file.is_open()) {
69 m_last_error = "Failed to open for writing: " + path;
70 return false;
71 }
72 file << encode(value, indent);
73 if (!file.good()) {
74 m_last_error = "Write failed: " + path;
75 return false;
76 }
77 return true;
78 }
std::string encode(const T &value, int indent=2)
Serialize value to a JSON string.

Referenced by MayaFlux::Nexus::StateEncoder::encode().

+ Here is the caller graph for this function: