www.gusucode.com > datastoreio工具箱 matlab源码程序 > datastoreio/+matlab/+io/+datastore/@KeyValueDatastore/readAllData.m

    function data = readAllData(kvds)
%READALLDATA Read all of the key-value pairs from a KeyValueDatastore.
%   T = READALLDATA(KVDS) reads all of the key-value pairs from KVDS.
%   T is a table with variables 'Key' and 'Value'.
%
%   See also matlab.io.datastore.KeyValueDatastore, hasdata, read, preview, reset

%   Copyright 2016 The MathWorks, Inc.

try
    % reset the datastore to the beginning
    % reset also errors when files are deleted between save-load of the datastore
    % to/from MAT-Files (and between releases).
    reset(kvds);

    % If empty files return an empty table with correct VariableNames for the empty
    % empty table
    if isEmptyFiles(kvds) || ~hasdata(kvds)
        import matlab.io.datastore.KeyValueDatastore;
        data = emptyTable(kvds, KeyValueDatastore.TABLE_OUTPUT_VARIABLE_NAMES);
        return;
    end
    % on exit reset the datastore
    c = onCleanup(@()reset(kvds));
    % read all the data
    data =  readAllSplits(kvds.Splitter);
catch ME
    throw(ME);
end
end