MatrixBerryCore
getcallername.m
Go to the documentation of this file.
1 function callerName=getcallername(nStepsUp,mode)
2 import mxberry.core.check.lib.*;
3 if nargin<1
4  nStepsUp=1;
5 elseif isnumeric(nStepsUp)
6  if nStepsUp<0
7  mxberry.core.throwerror('wrongInput',...
8  'nStepsUp cannot be negative');
9  end
10 else
11  error([upper(mfileaname),':wrongInput'],...
12  'nStepsUp is expected to be numeric');
13 end
14 %
15 if fix(nStepsUp)~=nStepsUp
16  mxberry.core.throwerror('wrongInput',...
17  'nStepsUp is expected to be an integer');
18 end
19 %
20 if nargin<2
21  mode='default';
22 else
23  mxberry.core.check.checkgen(mode,...
24  @(x)(isstring(x)&&~isempty(x)));
25 end
26 %
27 [methodName,className]=mxberry.core.getcallernameext(nStepsUp+1);
28 if ~strcmpi(mode,'default')||isempty(className)
29  % delete info on subfunctions
30  curInd=find(methodName=='/'|methodName=='\',1,'first');
31  if ~isempty(curInd)
32  methodName=methodName(1:curInd-1);
33  end
34 end
35 switch lower(mode)
36  case 'default'
37  if isempty(className)
38  callerName=methodName;
39  else
40  callerName=className;
41  end
42  case 'full'
43  if isempty(className)
44  callerName=methodName;
45  else
46  callerName=[className '.' methodName];
47  end
48  otherwise
49  mxberry.core.throwerror('wrongInput',...
50  'Unknown mode: %s',mode);
51 end
function isstring(in inpArray)
function getcallername(in nStepsUp, in mode)
GETCALLERNAME returns a name of caller determined by a number of steps up in the call stacks...