% MKSBase is the base class from which all
% MKS MATLAB classes are derived

% Version 2.0 - updated 2024-02-28
classdef MKSBase

    % Methods, begin
    methods(Static)

        % Retrieve structure's double field
        function dbl = getJsonDbl(jsonStruct, field)

            % Catch errors
            try
                s = jsonStruct.(field);
                dbl = str2double(s);
            catch
                dbl = double.empty;
            end

        end

        % Retrieve structure's string field
        function str = getJsonStr(jsonStruct, field)

            % Catch errors
            try
                str = jsonStruct.(field);
            catch
                str = "";
            end

        end

        % Retrieve structure's double array field
        function dArr = getJsonDArray(jsonStruct, field)

            % Catch errors
            try
                arr = jsonStruct.(field);
                if ~isempty(arr)
                    dArr = str2double(arr);
                    dArr = transpose(dArr);
                else
                    dArr = [];
                end
            catch
                dArr = [];
            end

        end
        
        % isNumericDataType - check data type
        function bValue = isNumericDataType(dataType)

            % Check for numeric data types
            switch dataType
            
                % CXTmpPrsDblUnRefDatum
                case "CXTmpPrsDblUnRefDatum"
                    bValue = true;

                % CTmpPrsDblUnRefDatum
                case "CTmpPrsDblUnRefDatum"
                    bValue = true;

                % CXPrsDblUnRefDatum
                case "CXPrsDblUnRefDatum"
                    bValue = true;

                % CXTmpDblUnRefDatum
                case "CXTmpDblUnRefDatum"
                    bValue = true;

                % CTmpDblUnRefDatum
                case "CTmpDblUnRefDatum"
                    bValue = true;

                % CDblUnRefDatum
                case "CDblUnRefDatum"
                    bValue = true;

                % CDblRefDatum
                case "CDblRefDatum"
                    bValue = true;

                % Not numeric
                otherwise
                    bValue = false;
            end
        end

    % Methods, end
    end
end