MayaFlux 0.5.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 61 of file JSONSerializer.hpp.

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

References value.

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

+ Here is the caller graph for this function: