%%
%% This is file `coolstr.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% coolstr.dtx  (with options: `package')
%% 
%% This is a generated file
%% 
%% This file may be distributed and/or modified under the
%% conditions of the Limited General Product License
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{coolstr}
 [2009/09/09 v2.2 COntent Oriented LaTeX Strings]
\RequirePackage{ifthen}
\RequirePackage{amsmath}
\RequirePackage{amssymb}
%% \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         \~}
\newcounter{COOL@strlen}%
\newcommand{\COOL@strEnd}{\%\%\%}
\newcommand{\COOL@intEnd}{\%@\%@\%@}
\let\COOL@strStop=\relax
\newcommand{\setstrEnd}[1]{\renewcommand{\COOL@strEnd}{#1}}
\newcounter{COOL@strpointer}
\def\COOL@strgobble[#1]#2#3{%
\ifthenelse{\equal{#3}{\COOL@strEnd}}%
        {%
        \ifthenelse{\value{COOL@strpointer}=#1}%
                {%
                #2%
                }%
        % Else
                {%
                }%
        }%
        {%
        \ifthenelse{\value{COOL@strpointer}=#1}%
                {%
                #2%
                }%
        % Else
                {%
                }%
        \stepcounter{COOL@strpointer}%
        \COOL@strgobble[#1]#3%
        }%
}
\newcommand{\strchar}[2]{%
\setcounter{COOL@strpointer}{1}%
\COOL@strgobble[#2]#1\COOL@strEnd%
}
\newcommand{\strlen}[1]{%
\ifthenelse{\equal{#1}{}}%
        {%
        0%
        }%
        {%
        \strchar{#1}{0}%
        \arabic{COOL@strpointer}%
        }%
}
\newcommand{\strlenstore}[2]{%
\ifthenelse{\equal{#1}{}}%
        {%
        \setcounter{#2}{0}%
        }%
        {%
        \strchar{#1}{0}%
        \setcounter{#2}{\value{COOL@strpointer}}%
        }%
}
\newcounter{COOL@str@index}
\newcounter{COOL@str@start}
\newcounter{COOL@str@end}
\newcommand{\substr}[3]{%
\strlenstore{#1}{COOL@strlen}%
\ifthenelse{#2 < 0 \AND \NOT #2 < -\value{COOL@strlen}}%
        {%
        \setcounter{COOL@str@index}{\value{COOL@strlen}}%
        \addtocounter{COOL@str@index}{#2}%
        \addtocounter{COOL@str@index}{1}%
        }%
{\ifthenelse{#2 > 0 \AND \NOT #2 > \value{COOL@strlen}}%
        {%
        \setcounter{COOL@str@index}{#2}%
        }%
        {%
        \setcounter{COOL@str@index}{0}%
        }}%
\ifthenelse{\equal{#3}{beg}}%
        {%
        \setcounter{COOL@str@start}{1}%
        \setcounter{COOL@str@end}{\value{COOL@str@index}}%
        }%
{\ifthenelse{\equal{#3}{end}}%
        {%
        \setcounter{COOL@str@start}{\value{COOL@str@index}}%
        \setcounter{COOL@str@end}{\value{COOL@strlen}}%
        }%
{\ifthenelse{#3 < 0}%
        {%
        \setcounter{COOL@str@start}{\value{COOL@str@index}}%
        \addtocounter{COOL@str@start}{#3}%
        \addtocounter{COOL@str@start}{1}%
        \ifthenelse{\NOT \value{COOL@str@start} > 0}{\setcounter{COOL@str@start}{1}}{}%
        \setcounter{COOL@str@end}{\value{COOL@str@index}}%
        }%
{\ifthenelse{#3 > 0}%
        {%
        \setcounter{COOL@str@start}{\value{COOL@str@index}}%
        \setcounter{COOL@str@end}{\value{COOL@str@index}}%
        \addtocounter{COOL@str@end}{#3}%
        \addtocounter{COOL@str@end}{-1}%
        \ifthenelse{\value{COOL@str@end} > \value{COOL@strlen}}{\setcounter{COOL@str@end}{\value{COOL@strlen}}}{}%
        }%
        {%
        \setcounter{COOL@str@index}{0}%
        }}}}%
\ifthenelse{ \value{COOL@str@index} = 0 }%
        {%
        }%
        {%
        \setcounter{COOL@strpointer}{1}%
        \COOL@substrgobbler#1\COOL@strStop\COOL@strEnd%
        }%
}
\def\COOL@substrgobbler#1#2\COOL@strEnd{%
\ifthenelse{\equal{#2}{\COOL@strStop}}%
        {%
        \ifthenelse{ \value{COOL@strpointer} < \value{COOL@str@start} \OR \value{COOL@strpointer} > \value{COOL@str@end} }%
                {}%
        % Else
                {%
                #1%
                }%
        }%
        {%
        \ifthenelse{ \value{COOL@strpointer} < \value{COOL@str@start} \OR \value{COOL@strpointer} > \value{COOL@str@end} }%
                {}%
        % Else
                {%
                #1%
                }%
        \stepcounter{COOL@strpointer}%
        \COOL@substrgobbler#2\COOL@strEnd%
        }%
}
\newboolean{COOL@charmatch}
\def\COOL@strcomparegobble[#1]<#2>#3#4{%
\ifthenelse{\equal{#4}{\COOL@strEnd}}%
        {%
        \ifthenelse{\value{COOL@strpointer}=#1 \AND \equal{#2}{#3} }%
                {%
                \setboolean{COOL@charmatch}{true}%
                }%
        % Else
                {%
                }%
        }%
        {%
        \ifthenelse{\value{COOL@strpointer}=#1 \AND \equal{#2}{#3} }%
                {%
                \setboolean{COOL@charmatch}{true}%
                }%
        % Else
                {%
                }%
        \stepcounter{COOL@strpointer}%
        \COOL@strcomparegobble[#1]<#2>#4%
        }%
}
\newcommand{\ifstrchareq}[5]{%
\setboolean{COOL@charmatch}{false}%
\setcounter{COOL@strpointer}{1}%
\COOL@strcomparegobble[#2]<#3>#1\COOL@strEnd\relax%
\ifthenelse{ \boolean{COOL@charmatch} }%
        {%
        #4%
        }%
        {%
        #5%
        }%
}
\newcommand{\ifstrleneq}[4]{%
\strlenstore{#1}{COOL@strlen}%
\ifthenelse{ \value{COOL@strlen} = #2 }%
        {%
        #3%
        }%
        {%
        #4%
        }%
}
\newboolean{COOL@decimalfound}
\newboolean{COOL@decimal}
\def\COOL@decimalgobbler#1#2\COOL@strEnd{%
\ifthenelse{\equal{#1}{\COOL@strStop}}%
        {%
        \setboolean{COOL@decimal}{false}%
        }%
{\ifthenelse{\equal{#2}{\COOL@strStop}}%
        {%
        \ifthenelse{`#1 < `0 \OR `#1 > `9}%
                {%
                \ifthenelse{ `#1 = `.  \AND \NOT \value{COOL@strpointer} = 1 \AND \NOT \boolean{COOL@decimalfound} }%
                        {%
                        }%
                % Else
                        {%
                        \setboolean{COOL@decimal}{false}%
                        }%
                }%
        % Else
                {%
                }%
        }%
        {%
        \ifthenelse{ `#1 < `0 \OR `#1 > `9 }%
                {%
                \ifthenelse{ `#1 = `.  \AND \NOT \boolean{COOL@decimalfound} }%
                        {%
                        \setboolean{COOL@decimalfound}{true}%
                        }%
                {\ifthenelse{ \(`#1 = `+ \OR `#1 = `-\) \AND \value{COOL@strpointer} = 1 }%
                        {%
                        }%
                % Else
                        {%
                        \setboolean{COOL@decimal}{false}%
                        }}%
                }%
        % Else
                {}%
        \stepcounter{COOL@strpointer}%
        \COOL@decimalgobbler#2\COOL@strEnd%
        }}%
}
\newcommand{\isdecimal}[2]{%
\setcounter{COOL@strpointer}{1}%
\setboolean{COOL@decimalfound}{false}%
\setboolean{COOL@decimal}{true}%
\expandafter\COOL@decimalgobbler#1\COOL@strStop\COOL@strEnd%
\ifthenelse{ \boolean{COOL@decimal} }%
        {%
        \setboolean{#2}{true}%
        }%
        {%
        \setboolean{#2}{false}%
        }%
}%
\newboolean{COOL@numeric}%
\def\COOL@eparser#1e#2\COOL@strEnd{%
\xdef\COOL@num@magnitude{#1}%
\xdef\COOL@num@exponent{#2}%
}
\def\COOL@ecorrector#1e\COOL@strStop{%
\xdef\COOL@num@exponent{#1}%
}
\def\COOL@Eparser#1E#2\COOL@strEnd{%
\xdef\COOL@num@magnitude{#1}%
\xdef\COOL@num@exponent{#2}%
}
\def\COOL@Ecorrector#1E\COOL@strStop{%
\xdef\COOL@num@exponent{#1}%
}
\newcommand{\isnumeric}[2]{%
\COOL@eparser#1e\COOL@strStop\COOL@strEnd%
\ifthenelse{ \equal{\COOL@num@exponent}{\COOL@strStop} }%
        {%
        \COOL@Eparser#1E\COOL@strStop\COOL@strEnd%
        \ifthenelse{ \equal{\COOL@num@exponent}{\COOL@strStop} }%
                {%
                \gdef\COOL@num@exponent{0}%
                }%
        % Else
                {%
                \expandafter\COOL@Ecorrector\COOL@num@exponent%
                }%
        }
        {%
        \expandafter\COOL@ecorrector\COOL@num@exponent%
        }%
\isdecimal{\COOL@num@magnitude}{COOL@numeric}%
\ifthenelse{ \boolean{COOL@numeric} }%
        {%
        \isdecimal{\COOL@num@exponent}{COOL@numeric}%
        \ifthenelse{ \boolean{COOL@numeric} }%
                {%
                \setboolean{#2}{true}%
                }%
        % Else
                {%
                \setboolean{#2}{false}%
                }%
        }%
        {%
        \setboolean{#2}{false}%
        }%
}
\newboolean{COOL@isint}
\def\COOL@intgobbler#1#2\COOL@strEnd{%
\ifcat#11%
\ifthenelse{\equal{#2}{\COOL@strStop}}%
        {%
        \ifthenelse{`#1 < `0 \OR `#1 > `9}%
                {%
                \setboolean{COOL@isint}{false}%
                }%
        % Else
                {%
                }%
        }%
        {%
        \ifthenelse{ `#1 < `0 \OR `#1 > `9 }%
                {%
                \ifthenelse{ `#1 = `+ \OR `#1 = `- \AND \value{COOL@strpointer} = 1 }%
                        {}%
                % Else
                        {%
                        \setboolean{COOL@isint}{false}%
                        }%
                }%
        % Else
                {%
                }%
        \stepcounter{COOL@strpointer}%
        \COOL@intgobbler#2\COOL@strEnd%
        }%
\else%
        \setboolean{COOL@isint}{false}%
\fi%
}
\newcommand{\isint}[2]{%
\setcounter{COOL@strpointer}{1}%
\setboolean{COOL@isint}{true}%
\expandafter\COOL@intgobbler#1\COOL@strStop\COOL@strEnd%
\ifthenelse{ \boolean{COOL@isint} }%
        {%
        \setboolean{#2}{true}%
        }%
        {%
        \setboolean{#2}{false}%
        }%
}
\endinput
%%
%% End of file `coolstr.sty'.
