summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/upmethodology/upmethodology-code.sty
blob: 4ff7d9b0ac84320971be00a6f7990d21c6a16cda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
% Source Code Description for Unified Process Methodology
%
% Copyright (c) 2006-2022 Stephane GALLAND <galland@arakhne.org>
% 
% This program is free library; you can redistribute it and/or modify
% it under the terms of the GNU Lesser General Public License as
% published by the Free Software Foundation; either version 3 of the
% License, or any later version.
%
% This library is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
% Lesser General Public License for more details.
%
% You should have received a copy of the GNU Lesser General Public
% License along with this library; see the file COPYING.  If not,
% write to the Free Software Foundation, Inc., 59 Temple Place - Suite
% 330, Boston, MA 02111-1307, USA.
%
% Creation date: 2006-04-27
% Modifications:
%   2009-10-30   Clean code.
%

\global\edef\upm@package@code@ver{2022/02/10}

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{upmethodology-code}[\upm@package@code@ver]

\RequirePackage{upmethodology-p-common}

\def\upm@code@eat@spaces#1{#1}
\def\upm@code@makemul#1{\upm@code@eat@spaces{#1}\bgroup\textbf{s}\egroup\xspace}

%-----
%Language
%0: UML
%1: java
%2: C++
\newcount\upm@code@current@lang

\DeclareOption{uml}{\upm@code@current@lang=0}
\DeclareOption{java}{\upm@code@current@lang=1}
\DeclareOption{cpp}{\upm@code@current@lang=2}

\ExecuteOptions{uml}
\ProcessOptions

%-----
%Language changes
\newcommand{\upmcodelang}[1]{%
	\ifthenelse{\equal{#1}{java}}{%
		\upm@code@current@lang=1%
	}{%
	\ifthenelse{\equal{#1}{cpp}}{%
		\upm@code@current@lang=2%
	}{%
		\upm@code@current@lang=0%
	}%
	}%
	\upm@code@declarations%
}

\def\upm@code@declarations {
%-----
%PROTOTYPES
\gdef\jclass##1{\mbox{\textsc{##1}}\xspace}
\gdef\jinterface##1{\mbox{\textit{##1}}\xspace}
\gdef\jpackage##1{\mbox{\textsc{##1}}\xspace}
\gdef\jfunc##1{\texttt{##1}\xspace}

%-----
%TYPES
\if\the\upm@code@current@lang 1
	%Java
	\gdef\jclazz{\textbf{Class}\xspace}
	\gdef\jvoid{\textbf{void}\xspace}
	\gdef\jint{\textbf{int}\xspace}
	\gdef\jlong{\textbf{long}\xspace}
	\gdef\jfloat{\textbf{float}\xspace}
	\gdef\jboolean{\textbf{boolean}\xspace}
	\gdef\jdouble{\textbf{double}\xspace}
	\gdef\jchar{\textbf{char}\xspace}
	\gdef\jstring{\jclass{String}\xspace}
	\gdef\jarray##1{{{##1}\bgroup\textbf{\string[\string]}\egroup}\xspace}
	\gdef\jcollection##1{{\jclass{Collection}\textless{##1}\bgroup\textgreater\egroup}\xspace}
	\gdef\jset##1{{\jclass{Set}\textless{##1}\bgroup\textgreater\egroup}\xspace}
\else\if\the\upm@code@current@lang 2
	%C++
	\gdef\jclazz{\textbf{class}\xspace}
	\gdef\jvoid{\textbf{void}\xspace}
	\gdef\jint{\textbf{int}\xspace}
	\gdef\jlong{\textbf{long}\xspace}
	\gdef\jfloat{\textbf{float}\xspace}
	\gdef\jboolean{\textbf{bool}\xspace}
	\gdef\jdouble{\textbf{double}\xspace}
	\gdef\jchar{\textbf{char}\xspace}
	\gdef\jstring{\jclass{std\string:\string:string}\xspace}
	\gdef\jarray##1{{{##1}\bgroup\textbf{\string[\string]}\egroup}\xspace}
	\gdef\jcollection##1{{\jclass{std\string:\string:vector}\textless{##1}\bgroup\textgreater\egroup}\xspace}
	\gdef\jset##1{{\jclass{std\string:\string:set}\textless{##1}\bgroup\textgreater\egroup}\xspace}
\else
	%UML
	\gdef\jclazz{\textbf{class}\xspace}
	\gdef\jvoid{\textbf{void}\xspace}
	\gdef\jint{\textbf{integer}\xspace}
	\gdef\jlong{\textbf{long integer}\xspace}
	\gdef\jfloat{\textbf{float}\xspace}
	\gdef\jboolean{\textbf{boolean}\xspace}
	\gdef\jdouble{\textbf{double}\xspace}
	\gdef\jchar{\textbf{character}\xspace}
	\gdef\jstring{\textbf{string}\xspace}
	\gdef\jcollection##1{{\textbf{collection of} \upm@code@makemul{##1}\bgroup\egroup}\xspace}
	\gdef\jarray##1{{\textbf{array of} \upm@code@makemul{##1}\bgroup\egroup}\xspace}
	\gdef\jset##1{{\textbf{set of} \upm@code@makemul{##1}\bgroup\egroup}\xspace}
\fi\fi

%-----
%CONSTANTS
\if\the\upm@code@current@lang 1
	%Java
	\gdef\jtrue{\textsc{true}\xspace}
	\gdef\jfalse{\textsc{false}\xspace}
\else\if\upm@code@current@lang 2
	%C++
	\gdef\jtrue{\textsc{true}\xspace}
	\gdef\jfalse{\textsc{false}\xspace}
\else
	\gdef\jtrue{\textsc{true}\xspace}
	\gdef\jfalse{\textsc{false}\xspace}
\fi\fi

%-----
%OPERATIONS
\gdef\jop##1{\bgroup\jcode{##1}\egroup}
\gdef\jcall##1##2{\mbox{\jfunc{##1}\bgroup\texttt{\string({##2}\string)}\egroup}\xspace}
\gdef\jcode##1{\texttt{##1}\xspace}

}

\upm@code@declarations

\endinput