26#if defined (HAVE_CONFIG_H)
62load_inline_fcn (std::istream& is,
bool swap, octave::mach_info::float_format,
66 if (! is.read (
reinterpret_cast<char *
> (&nargs), 4))
77 for (
int i = 0; i < nargs; i++)
79 if (! is.read (
reinterpret_cast<char *
> (&tmp), 4))
86 args(i+1) = std::string (ctmp);
92 if (! is.read (
reinterpret_cast<char *
> (&tmp), 4))
105 if (! is.read (
reinterpret_cast<char *
> (&tmp), 4))
111 is.read (ctmp2, tmp);
115 args(0) = std::string (ctmp2);
117 octave::interpreter& interp = octave::__get_interpreter__ ();
121 if (tmp_inl.
length () > 0)
198 octave::mach_info::float_format fmt,
199 const std::string& filename,
bool& global,
204 unsigned char tmp = 0;
206 int32_t name_len = 0;
214 is.read (
reinterpret_cast<char *
> (&name_len), 4);
222 name[name_len] =
'\0';
223 if (! is.read (
reinterpret_cast<char *
> (name), name_len))
224 error (
"load: trouble reading binary file '%s'", filename.c_str ());
228 is.read (
reinterpret_cast<char *
> (&doc_len), 4);
230 error (
"load: trouble reading binary file '%s'", filename.c_str ());
236 tdoc[doc_len] =
'\0';
237 if (! is.read (
reinterpret_cast<char *
> (tdoc), doc_len))
238 error (
"load: trouble reading binary file '%s'", filename.c_str ());
242 if (! is.read (
reinterpret_cast<char *
> (&tmp), 1))
243 error (
"load: trouble reading binary file '%s'", filename.c_str ());
244 global = (tmp ? 1 : 0);
247 if (! is.read (
reinterpret_cast<char *
> (&tmp), 1))
248 error (
"load: trouble reading binary file '%s'", filename.c_str ());
250 octave::type_info&
type_info = octave::__get_type_info__ ();
277 if (! is.read (
reinterpret_cast<char *
> (&
len), 4))
278 error (
"load: trouble reading binary file '%s'", filename.c_str ());
282 if (! is.read (
reinterpret_cast<char *
> (s),
len))
283 error (
"load: trouble reading binary file '%s'", filename.c_str ());
304 if (! is.read (
reinterpret_cast<char *
> (&
len), 4))
305 error (
"load: trouble reading binary file '%s'", filename.c_str ());
309 if (! is.read (s,
len))
310 error (
"load: trouble reading binary file '%s'", filename.c_str ());
314 if (typ ==
"inline function")
317 if (! load_inline_fcn (is, swap, fmt, tc))
318 error (
"load: trouble reading binary file '%s'", filename.c_str ());
326 error (
"load: trouble reading binary file '%s'", filename.c_str ());
331 error (
"load: trouble reading binary file '%s'", filename.c_str ());
342 const std::string& name,
const std::string& doc,
343 bool mark_global,
bool save_as_floats)
349 "Saving classdef objects is not supported. "
350 "Attempting to save '%s' as struct.",
357 constexpr octave_idx_type max_dim_val = std::numeric_limits<int32_t>::max () - 1;
360 if (dv.
ndims () > max_dim_val)
363 "save: skipping %s: number of dimensions too large for binary format",
370 if (dv(i_dim) > max_dim_val)
373 "save: skipping %s: dimensions too large for binary format",
379 int32_t name_len = name.length ();
381 os.write (
reinterpret_cast<char *
> (&name_len), 4);
384 int32_t doc_len = doc.length ();
386 os.write (
reinterpret_cast<char *
> (&doc_len), 4);
392 os.write (
reinterpret_cast<char *
> (&tmp), 1);
396 os.write (
reinterpret_cast<char *
> (&tmp), 1);
400 int32_t
len = typ.length ();
401 os.write (
reinterpret_cast<char *
> (&
len), 4);
402 const char *btmp = typ.data ();
403 os.write (btmp,
len);
409 bool success = val.
save_binary (os, save_as_floats);
411 return (os && success);
void swap_bytes< 4 >(void *ptr)
Vector representing the dimensions (size) of an Array.
octave_idx_type ndims() const
Number of dimensions.
octave_map map_value() const
octave_idx_type length() const
bool is_classdef_object() const
octave_classdef * classdef_object_value(bool silent=false) const
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
bool save_binary(std::ostream &os, bool save_as_floats)
std::string type_name() const
octave_value lookup_type(const std::string &nm)
void warning_with_id(const char *id, const char *fmt,...)
void error(const char *fmt,...)
std::string read_binary_data(std::istream &is, bool swap, octave::mach_info::float_format fmt, const std::string &filename, bool &global, octave_value &tc, std::string &doc)
bool save_binary_data(std::ostream &os, const octave_value &tc_in, const std::string &name, const std::string &doc, bool mark_global, bool save_as_floats)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)