136 const std::string& filename,
bool& global,
141 unsigned char tmp = 0;
143 int32_t name_len = 0;
151 is.read (reinterpret_cast<char *> (&name_len), 4);
159 name[name_len] =
'\0';
160 if (! is.read (reinterpret_cast<char *> (name), name_len))
161 goto data_read_error;
165 is.read (reinterpret_cast<char *> (&doc_len), 4);
167 goto data_read_error;
173 tdoc[doc_len] =
'\0';
174 if (! is.read (reinterpret_cast<char *> (tdoc), doc_len))
175 goto data_read_error;
179 if (! is.read (reinterpret_cast<char *> (&tmp), 1))
180 goto data_read_error;
181 global = tmp ? 1 : 0;
184 if (! is.read (reinterpret_cast<char *> (&tmp), 1))
185 goto data_read_error;
212 if (! is.read (reinterpret_cast<char *> (&len), 4))
213 goto data_read_error;
217 if (! is.read (reinterpret_cast<char *> (s), len))
218 goto data_read_error;
239 if (! is.read (reinterpret_cast<char *> (&len), 4))
240 goto data_read_error;
244 if (! is.read (s, len))
245 goto data_read_error;
252 goto data_read_error;
259 error (
"load: trouble reading binary file '%s'", filename.c_str ());
271 const std::string& name,
const std::string& doc,
272 bool mark_as_global,
bool save_as_floats)
274 int32_t name_len = name.length ();
276 os.write (reinterpret_cast<char *> (&name_len), 4);
279 int32_t doc_len = doc.length ();
281 os.write (reinterpret_cast<char *> (&doc_len), 4);
286 tmp = mark_as_global;
287 os.write (reinterpret_cast<char *> (&tmp), 1);
291 os.write (reinterpret_cast<char *> (&tmp), 1);
295 int32_t len = typ.length ();
296 os.write (reinterpret_cast<char *> (&len), 4);
297 const char *btmp = typ.data ();
298 os.write (btmp, len);
304 bool success = val.
save_binary (os, save_as_floats);
306 return (os && success);