1######################################################################## 2## 3## Copyright (C) 2008-2021 The Octave Project Developers 4## 5## See the file COPYRIGHT.md in the top-level directory of this 6## distribution or <https://octave.org/copyright/>. 7## 8## This file is part of Octave. 9## 10## Octave is free software: you can redistribute it and/or modify it 11## under the terms of the GNU General Public License as published by 12## the Free Software Foundation, either version 3 of the License, or 13## (at your option) any later version. 14## 15## Octave is distributed in the hope that it will be useful, but 16## WITHOUT ANY WARRANTY; without even the implied warranty of 17## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18## GNU General Public License for more details. 19## 20## You should have received a copy of the GNU General Public License 21## along with Octave; see the file COPYING. If not, see 22## <https://www.gnu.org/licenses/>. 23## 24######################################################################## 25 26## -*- texinfo -*- 27## @deftypefn {} {@var{b} =} saveobj (@var{a}) 28## Method of a class to manipulate an object prior to saving it to a file. 29## 30## The function @code{saveobj} is called when the object @var{a} is saved 31## using the @code{save} function. An example of the use of @code{saveobj} 32## might be to remove fields of the object that don't make sense to be saved 33## or it might be used to ensure that certain fields of the object are 34## initialized before the object is saved. For example: 35## 36## @example 37## @group 38## function b = saveobj (a) 39## b = a; 40## if (isempty (b.field)) 41## b.field = initfield (b); 42## endif 43## endfunction 44## @end group 45## @end example 46## 47## @seealso{loadobj, class} 48## @end deftypefn 49 50function b = saveobj (a) 51 error ('saveobj: not defined for class "%s"', class (a)); 52endfunction 53