% -------------------------------------------------------
% Copyright 2012 Ghersi Andrea (ghanhawk@gmail.com).
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License version
% 1.3c, available at 'http://www.latex-project.org/lppl'.
% -------------------------------------------------------

% ===============================================================================
% -------------------------------------------------------------------------     %
% Why a class file? (from document: LaTeX 2e for class and package writers)     %
% -------------------------------------------------------------------------     %
%                                                                               %
% The first thing to do when you want to put some new LaTEX commands in a file  %
% is to decide whether it should be a document class or a package. The rule of  %
% thumb is:                                                                     %
%                                                                               %
%   If the commands could be used with any document class, then make them a     %
%   package; if not, then make them a class.                                    %
% ===============================================================================

\NeedsTeXFormat{LaTeX2e}

\RequirePackage{svn-prov}
\def\@versionstr{1.5.3}

\ProvidesClassSVN
   {$Id: mycv.cls 60 2012-04-14 23:33:21Z ghangenit $}
   [\@versionstr][My Curriculum Vitae class]

% ========
% Packages
% ========

\RequirePackage{kvoptions} % see the comment above
\RequirePackage{etextools} % for lists and other useful tools
\RequirePackage{ifthen}    % for <\ifthenelse> command
\RequirePackage{pifont}    % 'ding' style for item of itemize env
\RequirePackage{xstring}   % string utilities

% =============
% Class Options
% =============

\DeclareBoolOption{withDec}

\DeclareDefaultOption{%
   \PassOptionsToClass{\CurrentOption}{article}}

\DeclareStringOption[english]{language}
\DeclareStringOption[Contents]{cntdir}
\DeclareStringOption[mycv_style.def]{style}
\DeclareStringOption[]{mdlname}
\ProcessKeyvalOptions*

% -----------------------------------------------------------
% The value of an option declared with <\DeclareStringOption>
% is stored in the macro \<class (or package) name>@<option>
% -----------------------------------------------------------

\PassOptionsToPackage{\mycv@language}{babel}
\RequirePackage{babel}

\LoadClass{article}

\def\cvcontentsdir{\mycv@cntdir}

% ===============
% File inclusions
% ===============

\input{mycv_base.def}
\input{mycv_misc.def}

% -------------------------------------
% use custom, default or any style file
% -------------------------------------
\ifthenelse{\equal{\mycv@style}{none}}%
   {\relax}% file style is not wanted
   {\input{\mycv@style}}

% ----------------------
% use decorations or not
% ----------------------
\ifthenelse{\boolean{mycv@withDec}}%
   {\input{mycv_dec.def}}%
   {\relax}

\DeclareRobustCommand{\ifmodel}[1]{%
   \begingroup
   \def\@mdlname{#1}
   \ifx\mycv@mdlname\@mdlname
      \endgroup
      \expandafter\@firstoftwo
   \else
      \endgroup
      \expandafter\@secondoftwo
   \fi
}

% -----------------------------------------------
% <\ifoption{optionname}{then block}{else block}>
% -----------------------------------------------

\DeclareRobustCommand{\ifoption}[1]{%
   \begingroup
   \ifthenelse{\boolean{mycv@#1}}
      {\endgroup\expandafter\@firstoftwo}
      {\endgroup\expandafter\@secondoftwo}%
}