%% LaTeX package crossreftools - version 0.1 (2017/10/08 -- 22:58:50)
%% Source file for crossreftools.sty
%%
%%
%% -------------------------------------------------------------------------------------------
%% Copyright (c) 2017 by Dr. Christian Hupfer <typography dot with dot latex at gmail dot com>
%% -------------------------------------------------------------------------------------------
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
%%
%% This work has the LPPL maintenance status `author-maintained`
%%
%%

\def\crossreftoolspackageversion{0.1}
\NeedsTeXFormat{LaTeX2e}[1995/12/01]

\ProvidesPackage{crossreftools}[2017/10/08 - v\crossreftoolspackageversion]


% Some helper macros
\newcommand{\crt@firstoffive}[5]{#1}
\newcommand{\crt@refundefined}{[UNDEFINED]}

\long\def\crt@gobblethree#1#2#3{}
\long\def\crt@gobbletwo#1#2{}
\long\def\crt@gobbleone#1{}

% Splitters 

\def\crt@@cref@@splitter@@first[#1][#2][#3]#4\@nil{%
  #1%
}

\def\crt@@cref@@splitter@@second[#1][#2][#3]#4\@nil{%
  #2%
}

\def\crt@@cref@@splitter@@third[#1][#2][#3]#4\@nil{%
  #3%
}

\def\crt@@cref@@splitter@@fourth[#1][#2][#3]#4\@nil{%
  #4%
}


\def\crt@cref@splitter@firstarg#1#2{%
  \expandafter\crt@@cref@@splitter@@first#1\@nil
}

\def\crt@cref@splitter@secondarg#1#2{%
  \expandafter\crt@@cref@@splitter@@second#1\@nil%
}


\def\crt@cref@splitter@thirdarg#1#2{%
  \expandafter\crt@@cref@@splitter@@third#1\@nil%
}


\def\crt@cref@splitter@fourtharg#1#2{%
  \expandafter\crt@@cref@@splitter@@fourth#1\@nil%
}

\def\crt@cref@splitter@firstargument{%
  \@firstoftwo%
}


\def\crt@cref@splitter@pageref{%
  \@secondoftwo%
}


\newcommand{\crtcrefname}[1]{%
  \expandafter\csname cref@#1@name\endcsname%
}

\newcommand{\crtcrefpluralname}[1]{%
  \csname cref@#1@name@plural\endcsname%
}

\newcommand{\crtCrefpluralname}[1]{%
  \csname Cref@#1@name@plural\endcsname%
}

\newcommand{\crtCrefname}[1]{%
  \csname Cref@#1@name\endcsname%
}

\newcommand{\crtcrefnamebylabel}[1]{%
  \expandafter\csname cref@\@@crtextr@ct@cref{counter}{#1}@name\endcsname%
}

\newcommand{\crtCrefnamebylabel}[1]{%
  \expandafter\csname Cref@\@@crtextr@ct@cref{counter}{#1}@name\endcsname%
}

\def\@@crt@@cref@@suffix{cref}

\let\crt@cref@splitter@counter\crt@cref@splitter@firstarg
\let\crt@cref@splitter@number\crt@cref@splitter@secondarg
\let\crt@cref@splitter@result\crt@cref@splitter@thirdarg
\let\crt@cref@splitter@reference\crt@cref@splitter@fourtharg
\let\crt@cref@splitter@page\crt@cref@splitter@pageref


\newcommand{\@@crtextr@ct@cref}[2]{%
  \expandafter\ifx\csname r@#2@\@@crt@@cref@@suffix\endcsname\relax
  \crt@refundefined%
  \else
  \expandafter\expandafter\expandafter\expandafter\expandafter\csname crt@cref@splitter@#1\expandafter\endcsname\csname r@#2@cref\endcsname%
  \fi
}

\newcommand{\crtextractcref}[2]{%
  \@@crtextr@ct@cref{#1}{#2}%
}

\newcommand{\crtcrefcounter}[1]{%
  \@@crtextr@ct@cref{counter}{#1}%
}  

\newcommand{\crtcrefnumber}[1]{%
  \@@crtextr@ct@cref{number}{#1}%
}  

\newcommand{\crtcrefresult}[1]{%
  \@@crtextr@ct@cref{result}{#1}%
}  

\newcommand{\crtcrefreference}[1]{%
  \@@crtextr@ct@cref{reference}{#1}%
}  


\newcommand{\crtcrefpage}[1]{%
  \@@crtextr@ct@cref{page}{#1}%
}  


\endinput

