%%
%% This is file `pst-dbicons.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% pst-dbicons.dtx  (with options: `package')
%% 
%% IMPORTANT NOTICE:
%% 
%% For the copyright see the source file.
%% 
%% Any modified versions of this file must be renamed
%% with new filenames distinct from pst-dbicons.sty.
%% 
%% For distribution of the original source see the terms
%% for copying and modification in the file pst-dbicons.dtx.
%% 
%% This generated file may be distributed as long as the
%% original source files, as listed above, are part of the
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
\def\filedate{2006/11/26}
\def\docdate{2006/11/26}
\def\fileversion{0.2}
\def\basename{pst-dbicons}
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
\RequirePackage{pstricks}
\RequirePackage{pst-node}
\typeout{Style `\basename', Version \fileversion\space <\filedate>}
\ProvidesPackage{pst-dbicons}[\filedate \space\fileversion]
\def\seticonparams#1#2{\expandafter\def\csname #1@parm\endcsname{[#2]}}
\seticonparams{entity}{fillstyle=none}
\seticonparams{relationship}{fillstyle=none}
\seticonparams{attribute}{fillstyle=none}
\def\dbi@purifylabel#1#2{%
  \begingroup
    \edef\_{\string_}%
    \edef\textunderscore{\string_}%
    \edef\x{\endgroup
      \def\noexpand#1{#2}%
    }%
  \x
}
\def\entity{%
 \@ifnextchar[{\entity@i}{\entity@i[normal]}}
\def\entity@i[#1]#2{%
 \@ifnextchar[{\entity@ii{#1}{#2}}{\entity@ii{#1}{#2}[#2]}}
\def\entity@ii#1#2[#3]{\csname entity@#1\endcsname{#2}{#3}}
\def\entity@normal#1#2{%
  \dbi@purifylabel{\dbi@prfd@nodename}{#1}%
  \rnode{\dbi@prfd@nodename}{\expandafter\psframebox\entity@parm{\strut#2}}}
\def\entity@weak#1#2{%
  {\psset{doubleline=true}%
   \dbi@purifylabel{\dbi@prfd@nodename}{#1}%
   \rnode{\dbi@prfd@nodename}{\expandafter\psframebox\entity@parm{\strut#2}}}}
\def\attribute{%
 \@ifnextchar[{\attribute@i}{\attribute@i[sv]}}
\def\attribute@i[#1]#2{%
 \@ifnextchar[{\attribute@ii{#1}{#2}}{\attribute@ii{#1}{#2}[#2]}}
\def\attribute@ii#1#2[#3]{\csname attribute@#1\endcsname{#2}{#3}}
\def\attribute@mv#1#2{{\psset{doubleline=true}%
  \dbi@purifylabel{\dbi@prfd@nodename}{#1}%
  \expandafter\ovalnode\attribute@parm{\dbi@prfd@nodename}{#2}}}
\def\attribute@sv#1#2{%
  \dbi@purifylabel{\dbi@prfd@nodename}{#1}%
  \expandafter\ovalnode\attribute@parm{\dbi@prfd@nodename}{#2}}
\def\attribute@key#1#2{
  \dbi@purifylabel{\dbi@prfd@nodename}{#1}%
  \expandafter\ovalnode\attribute@parm{\dbi@prfd@nodename}{\underline{#2}}}
\newdimen\@attrdist
\@attrdist2em  % Default value for distance of attribute from entity
\def\attrdist#1{\@attrdist#1} % set default distance
\def\attributeof#1{%
 \@ifnextchar[{\attributeof@i{#1}}{\attributeof@i{#1}[\attrdist]}}
\def\attributeof@i#1[#2]#3{%
 \@ifnextchar[{\attributeof@ii{#1}[#2]{#3}}{\attributeof@ii{#1}[#2]{#3}[sv]}}
\def\attributeof@ii#1[#2]#3[#4]#5{%
 \@ifnextchar[{\attributeof@iii{#1}[#2]{#3}[#4]{#5}}%
              {\attributeof@iii{#1}[#2]{#3}[#4]{#5}[#5]}}
\def\attributeof@iii#1[#2]#3[#4]#5[#6]{%
  \SpecialCoor
  \dbi@purifylabel{\dbi@prfd@nodename}{#1}%
  \uput{#2}[#3]{0}(\dbi@prfd@nodename){\attribute[#4]{#5}[#6]}%
  \NormalCoor
  \ncline{-}{#1}{#5}}
\def\relationship{%
 \@ifnextchar[{\relationship@i}{\relationship@i[normal]}}
\def\relationship@i[#1]#2{%
 \@ifnextchar[{\relationship@ii{#1}{#2}}{\relationship@ii{#1}{#2}[#2]}}
\def\relationship@ii#1#2[#3]{\csname relationship@#1\endcsname{#2}{#3}}
\def\relationship@normal#1#2{%
   \dbi@purifylabel{\dbi@prfd@nodename}{#1}%
   \expandafter\dianode\relationship@parm{\dbi@prfd@nodename}{#2}}
\def\relationship@weak#1#2{%
  {\psset{doubleline=true}%
   \dbi@purifylabel{\dbi@prfd@nodename}{#1}%
   \expandafter\dianode\relationship@parm{\dbi@prfd@nodename}{#2}}}
\let\relationship@ident\relationship@weak
\newtoks\rolepos
\rolepos{0.85}%
\newtoks\cardpos
\cardpos{0.5}%
\newif\ifdbi@recursive
\def\relationshipbetween{%
 \@ifnextchar[{\relationshipbetween@type}{\relationshipbetween@type[normal]}}
\def\relationshipbetween@type[#1]#2{\dbi@recursivefalse%
 \def\relationtype{#1}%
 \@ifnextchar({\relationshipbetween@i@role{#2}}%
              {\relationshipbetween@i@role{#2}(\relax)}}
\def\relationshipbetween@i@role#1(#2){%
 \@ifnextchar[{\relationshipbetween@i@card{#1}{#2}}%
              {\relationshipbetween@i@card{#1}{#2}[\relax]}}
\def\relationshipbetween@i@card#1#2[#3]{%
 \@ifnextchar/{\relationshipbetween@i@linetype{#1}{#2}{#3}}%
              {\relationshipbetween@i@linetype{#1}{#2}{#3}/\relax/}}%
\def\relationshipbetween@i@linetype#1#2#3/#4/#5{%
 \def\dbi@linecmd@i{#4}%
 \def\dbi@tempa{#1}\def\dbi@tempb{#5}%
 \ifx\dbi@tempa\dbi@tempb\dbi@recursivetrue\fi
 \ifx#4\relax
    \ifdbi@recursive
       \def\dbi@linecmd@i{\ncarc[arcangleA=10,arcangleB=45]}%
      \else\def\dbi@linecmd@i{\ncline}\fi\fi
 \@ifnextchar({\relationshipbetween@ii@role{#1}{#2}{#3}{#5}}%
              {\relationshipbetween@ii@role{#1}{#2}{#3}{#5}(\relax)}}%
\def\relationshipbetween@ii@role#1#2#3#4(#5){%
 \@ifnextchar[{\relationshipbetween@ii@card{#1}{#2}{#3}{#4}{#5}}%
              {\relationshipbetween@ii@card{#1}{#2}{#3}{#4}{#5}[\relax]}}
\def\relationshipbetween@ii@card#1#2#3#4#5[#6]{%
 \@ifnextchar/{\relationshipbetween@ii@linetype{#1}{#2}{#3}{#4}{#5}{#6}}%
              {\relationshipbetween@ii@linetype{#1}{#2}{#3}{#4}{#5}{#6}%
               /\relax/}}%
\def\relationshipbetween@ii@linetype#1#2#3#4#5#6/#7/#8{%
 \def\dbi@linecmd@ii{#7}%
 \ifx#7\relax
    \ifdbi@recursive
       \def\dbi@linecmd@ii{\ncarc[arcangleA=-10,arcangleB=-45]}%
      \else\def\dbi@linecmd@ii{\ncline}\fi\fi
 \@ifnextchar[{\relationshipbetween@optname{#1}{#2}{#3}{#4}{#5}{#6}{#8}}%
              {\relationshipbetween@optname{#1}{#2}{#3}{#4}{#5}{#6}{#8}[#8]}}%
\def\relationshipbetween@optname#1#2#3#4#5#6#7[#8]{%
 \@ifnextchar/{\relationshipbetween@linetype{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}}%
              {\relationshipbetween@linetype{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}%
               /\ncline/}}%
\def\relationshipbetween@linetype#1#2#3#4#5#6#7#8/#9/{%
 \def\dbi@linecmd{#9}%
 \@ifnextchar({\relationshipbetween@pos{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}}%
              {\relationshipbetween@pos{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}(0.5)}}%
\def\relationshipbetween@pos#1#2#3#4#5#6#7#8(#9){%
   \ifdbi@recursive
     \relationshipbetween@rec{#1}{#2}{#3}{#5}{#6}{#7}{#8}(#9)\else
     \relationshipbetween@nonrec{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}(#9)\fi}
\def\relationshipbetween@nonrec#1#2#3#4#5#6#7#8(#9){%
 \dbi@purifylabel{\dbi@prfd@nodename@i}{#1}%
 \dbi@purifylabel{\dbi@prfd@nodename@ii}{#4}%
 \dbi@purifylabel{\dbi@prfd@nodename@iii}{#7}%
 {\psset{linestyle=none}%
  \dbi@linecmd{-}{\dbi@prfd@nodename@i}{\dbi@prfd@nodename@ii}}%
 \ncput[npos=#9]{\relationship[\relationtype]{#7}[#8]}%
 \dbi@linecmd@i{-}{\dbi@prfd@nodename@i}{\dbi@prfd@nodename@iii}%
  \ifx#3\relax\else\ncput*[npos=\the\cardpos]{#3}\fi
  \ifx#2\relax\else\ncput*[npos=\the\rolepos]{#2}\fi
 \dbi@linecmd@ii{-}{\dbi@prfd@nodename@ii}{\dbi@prfd@nodename@iii}%
  \ifx#6\relax\else\ncput*[npos=\the\cardpos]{#6}\fi
  \ifx#5\relax\else\ncput*[npos=\the\rolepos]{#5}\fi}
\def\relationshipbetween@rec#1#2#3#4#5#6#7(#8,#9){%
  \dbi@purifylabel{\dbi@prfd@nodename@i}{#1}%
  \dbi@purifylabel{\dbi@prfd@nodename@ii}{#6}%
  \SpecialCoor
  \uput{#8}[#9]{0}(\dbi@prfd@nodename@i)%
         {\relationship[\relationtype]{#6}[#7]}%
  \NormalCoor
  \dbi@linecmd@i{-}{\dbi@prfd@nodename@i}{\dbi@prfd@nodename@ii}%
   \ifx#3\relax\else\ncput*[npos=\the\cardpos]{#3}\fi
   \ifx#2\relax\else\ncput*[npos=\the\rolepos]{#2}\fi
  \dbi@linecmd@ii{-}{\dbi@prfd@nodename@i}{\dbi@prfd@nodename@ii}%
   \ifx#5\relax\else\ncput*[npos=\the\cardpos]{#5}\fi
   \ifx#4\relax\else\ncput*[npos=\the\rolepos]{#4}\fi}
\def\inrelationship{%
 \@ifnextchar[{\inrelationship@type}{\inrelationship@type[normal]}}
\def\inrelationship@type[#1]#2{%
 \def\relationtype{#1}%
 \@ifnextchar({\inrelationship@role{#2}}%
              {\inrelationship@role{#2}(\relax)}}
\def\inrelationship@role#1(#2){%
 \@ifnextchar[{\inrelationship@card{#1}{#2}}%
              {\inrelationship@card{#1}{#2}[\relax]}}
\def\inrelationship@card#1#2[#3]{%
 \@ifnextchar/{\inrelationship@linetype{#1}{#2}{#3}}%
              {\inrelationship@linetype{#1}{#2}{#3}/\ncline/}}%
\def\inrelationship@linetype#1#2#3/#4/#5{%
 \dbi@purifylabel{\dbi@prfd@nodename@i}{#1}%
 \dbi@purifylabel{\dbi@prfd@nodename@ii}{#5}%
 \def\dbi@linecmd{#4}%
 \@ifnextchar[{\inrelationship@newrel{#1}{#2}{#3}{#5}}%
              {\@ifnextchar({%
                \inrelationship@newrel{#1}{#2}{#3}{#5}[#5]}%
               {\dbi@linecmd{-}{\dbi@prfd@nodename@i}{\dbi@prfd@nodename@ii}
                \ifx#3\relax\else\ncput*[npos=\the\cardpos]{#3}\fi
                \ifx#2\relax\else\ncput*[npos=\the\rolepos]{#2}\fi}}}%
\def\inrelationship@newrel#1#2#3#4[#5]{%
 \@ifnextchar({\inrelationship@newrel@pos{#1}{#2}{#3}{#4}{#5}}%
              {\PackageError{\basename}{Position of relationship #4
                undefined.}\@eha}}
\def\inrelationship@newrel@pos#1#2#3#4#5(#6,#7){%
  \SpecialCoor
  \dbi@purifylabel{\dbi@prfd@nodename@i}{#1}%
  \dbi@purifylabel{\dbi@prfd@nodename@ii}{#4}%
  \uput{#6}[#7]{0}(\dbi@prfd@nodename@i){\relationship[\relationtype]{#4}[#5]}%
  \NormalCoor
  \dbi@linecmd{-}{\dbi@prfd@nodename@i}{\dbi@prfd@nodename@ii}
  \ifx#3\relax\else\ncput*[npos=\the\cardpos]{#3}\fi
  \ifx#2\relax\else\ncput*[npos=\the\rolepos]{#2}\fi}
\def\annote#1#2(#3,#4){%
  \dbi@purifylabel{\dbi@prfd@nodename}{#1}%
  \SpecialCoor
  \uput{#3}[#4]{0}(\dbi@prfd@nodename){#2}%
  \NormalCoor}
\def\nodeconnections#1{\hbox to 0cm{\vbox to 0cm {#1}}}
\def\database{\@ifnextchar[{\database@i}{\database@i[c]}}
\def\database@i[#1]#2#3{%
 \@ifnextchar[{\database@ii{#1}{#2}{#3}}%
              {\database@ii{#1}{#2}{#3}[fillstyle=none]}}
\def\database@ii#1#2#3[#4]#5{%
 \@ifnextchar[{\database@iii{#1}{#2}{#3}{#4}{#5}}%
              {\database@iii{#1}{#2}{#3}{#4}{#5}[#5]}}
\def\database@iii#1#2#3#4#5[#6]{%
 \psset{nodesep=0pt}%
 \dbi@purifylabel{\dbi@prfd@nodename}{#6}%
 \rnode{\dbi@prfd@nodename}{%
 \begin{tabular}[#1]{c}%
 \rnode{lu\dbi@prfd@nodename}{}\hspace{#2}\rnode{ru\dbi@prfd@nodename}{}\\[#3]
 \rnode{ll\dbi@prfd@nodename}{}\hspace{#2}\rnode{rl\dbi@prfd@nodename}{}%
 \end{tabular}}%
 \nodeconnections{%
 \ncbar[linestyle=none,#4,
        angleA=180,angleB=180,armB=0]{ru\dbi@prfd@nodename}{ll\dbi@prfd@nodename}
 \ncbar[linestyle=none,#4,
        angleA=0,angleB=0,armA=0]{ru\dbi@prfd@nodename}{ll\dbi@prfd@nodename}
 \nccurve[#4,angleA=90,angleB=90,ncurv=.6]{lu\dbi@prfd@nodename}{ru\dbi@prfd@nodename}%
      \ncput{\rnode{mu\dbi@prfd@nodename}{}}%
 \nccurve[angleA=-90,angleB=-90,ncurv=.6]{lu\dbi@prfd@nodename}{ru\dbi@prfd@nodename}%
      \ncput{\rnode{muf\dbi@prfd@nodename}{}}%
 \nccurve[#4,angleA=-90,angleB=-90,ncurv=.6]{ll\dbi@prfd@nodename}{rl\dbi@prfd@nodename}%
      \ncput{\rnode{ml\dbi@prfd@nodename}{}}%
 \ncline{lu\dbi@prfd@nodename}{ll\dbi@prfd@nodename}%
 \ncline{ru\dbi@prfd@nodename}{rl\dbi@prfd@nodename}%
 \ncline[linestyle=none]{muf\dbi@prfd@nodename}{ml\dbi@prfd@nodename}\ncput[npos=0.4]{#5}}}
\endinput
%%
%% End of file `pst-dbicons.sty'.
