%%
%% This is file `metakeys.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% metakeys.dtx  (with options: `package')
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{metakeys}[2016/04/06 v0.9 Framework for Metadata Keys]
\newif\ifmetakeys@showmeta\metakeys@showmetafalse
\DeclareOption{showmeta}{\metakeys@showmetatrue}
\DeclareOption*{}
\ProcessOptions
\RequirePackage{keyval}[1997/11/10]
\RequirePackage{etoolbox}
\newcommand\addmetakey{\@ifstar\addmetakey@star\addmetakey@nostar}%
\newcommand\addmetakey@star[3][]{%
  \@ifnextchar[{%
    \addmetakey@star@aux[#1]{#2}{#3}%
  }{%
    \addmetakey@star@aux[#1]{#2}{#3}[]%
  }%
}%
\def\addmetakey@star@aux[#1]#2#3[#4]{%
  \metakeys@ext@clear@keys{#2}{#3}{#1}%
  \metakeys@initialize@showkeys{#2}%
  \define@key{#2}{#3}[#4]{%
    \csxdef{#2@#3}{##1}%
  }%
}%
\newcommand\addmetakey@nostar[3][]{%
  \metakeys@ext@showkeys{#2}{#3}%
  \addmetakey@star[#1]{#2}{#3}%
}%
\newcommand\metasetkeys[2]{%
  \@nameuse{clear@#1@keys}%
  \setkeys{#1}{#2}%
  \ifmetakeys@showmeta%
    \edef\@@keys{\@nameuse{#1@showkeys}}%
    \metakeys@show@keys{#1}{%
      \@for\@I:=\@@keys\do{%
        \metakeys@show@keyval{#1}{\@I}%
      }%
    }%
  \fi%
}%
\newrobustcmd\metakeys@ext@clear@keys[3]{%
  \@metakeys@ext@clear@keys{#1}{#1@#2}{#3}%
}%
\newrobustcmd\@metakeys@ext@clear@keys[3]{%
  \@ifundefined{clear@#1@keys}{%
\csgdef{clear@#1@keys}{\csgdef{#2}{#3}}%
  }%
  {\expandafter\gappto\csname clear@#1@keys\endcsname{\csgdef{#2}{#3}}}%
}%
\newrobustcmd\addmetalistkey{%
  \@ifstar\addmetalistkey@star\addmetalistkey@nostar%
}%
\newrobustcmd\addmetalistkey@star[3][]{%
  \metakeys@ext@clear@keys{#2}{#3}{#1}%
  \metakeys@initialize@showkeys{#2}%
  \csgdef{#2@#3s}{}%
  \define@key{#2}{#3}[#1]{%
    \ifcsempty{#2@#3s}{%
      \csgdef{#2@#3s}{##1}%
    }{%
      \csxdef{#2@#3s}{\csuse{#2@#3s},##1}%
    }%
  }%
}%
\newrobustcmd\addmetalistkey@nostar[3][]{%
  \metakeys@ext@showkeys{#2}{#3}%
  \addmetalistkey@star[#1]{#2}{#3}%
}%
\newrobustcmd\metakeys@initialize@showkeys[1]{%
  \@ifundefined{#1@showkeys}{%
    \csdef{#1@showkeys}{}%
  }{}%
}%
\newrobustcmd\metakeys@ext@showkeys[2]{%
  \@ifundefined{#1@showkeys}{%
    \csdef{#1@showkeys}{#2}%
  }{%
    \csedef{#1@showkeys}{\csuse{#1@showkeys},#2}%
  }%
}%
\newrobustcmd\@metakeys@show@key[2]{\metakeys@show@key{#2}{#1}}%
\newrobustcmd\metakeys@show@key[2]{%
  \edef\@test{#2}%
  \ifx\@test\@empty\else #1:#2\quad\fi%
}%
\newrobustcmd\metakeys@show@keys[2]{\marginpar{{\scriptsize #2}}}%
\newrobustcmd\metakeys@show@keyval[2]{%
  \expandafter\@metakeys@show@key\csname #1@#2\endcsname{#2}%
}%
\newrobustcmd\showmetakeys{\metakeys@showmetatrue}%
\newrobustcmd\hidemetakeys{\metakeys@showmetafalse}%
\newrobustcmd\addmetakeynew[3][]{%
  \metakeys@ext@clear@keys{#2}{#3}{#1}%
  \define@key{#2}{#3}{%
    \csgdef{#2@#3}{##1}%
  }%
}%
\newrobustcmd\metakeys@unspecified{an metakeys-defined key left unspecified}%
\newrobustcmd\metakeysifus[4]{%
  \message{testing #1@#2=\csname#1@#2\endcsname}%
  \expandafter\ifx\csname #1@#2\endcsname\metakeys@unspecified{#3}\else{#4}\fi%
}%
\endinput
%%
%% End of file `metakeys.sty'.
