• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

autom4te.cache/H07-Jan-2017-44,43338,845

builds/H07-Jan-2017-462409

docs/H07-Jan-2017-9188

m4/H07-Jan-2017-

runtime/H07-Jan-2017-13440

src/H03-May-2022-10,7508,350

tests/H07-Jan-2017-15,84814,021

AUTHORSH A D07-Jan-20171.8 KiB3229

COPYINGH A D07-Jan-201734.3 KiB675553

ChangeLogH A D07-Jan-201711.4 KiB229210

INSTALLH A D07-Jan-20176.8 KiB168129

Makefile.amH A D07-Jan-2017279 105

Makefile.inH A D07-Jan-201725 KiB820723

READMEH A D07-Jan-201730.4 KiB1,105845

README.win32H A D07-Jan-20171.3 KiB4139

TODOH A D07-Jan-2017419 1511

aclocal.m4H A D07-Jan-2017363.6 KiB10,1819,204

compileH A D07-Jan-20177.2 KiB348258

config.guessH A D07-Jan-201742.3 KiB1,4321,239

config.hH A D07-Jan-20171.8 KiB6720

config.h.inH A D07-Jan-2017591 2315

config.subH A D07-Jan-201735.1 KiB1,8081,670

configureH A D07-Jan-2017562.4 KiB18,41015,635

configure.acH A D07-Jan-20171.2 KiB5139

depcompH A D07-Jan-201723 KiB792502

install-shH A D07-Jan-201714.3 KiB502327

libtoolH A D07-Jan-2017337.1 KiB11,8088,205

ltmain.shH A D26-Oct-2016316.5 KiB11,1487,979

missingH A D07-Jan-20176.7 KiB216143

reconfig.shH A D07-Jan-2017219 135

test-driverH A D07-Jan-20174.6 KiB15492

README

1Dia2Code v. 1.0.0
2
3SUMMARY
4
5This program generates code for many languages from an UML Dia Diagram.
6
7
8DESCRIPTION
9
10This program is a small utility that makes code from a Dia diagram. Supported
11target languages are: C++(99,11), C#, Java, PHP5.
12Starting version 1.0.0, the program was completely rewritten in C++.
13Target languages still to be ported from the dia2code-0.8.x C implementation are:
14ActionScript3, Ada, C, Python, Ruby, shapefiles, and SQL create statement files.
15
16Its intended purpose is to ease the programmer's work by generating
17the structure of the classes in an Object Oriented language
18(like C++, Java and C#) from a graphical representation of them
19(a Dia Diagram).
20
21
22STATUS
23
24Dia2Code generates C++(99,11), C#, Java, PHP.
25Templates and packages are supported.
26In the future, it will be able to generate ActionScript, Ada, C, IDL, Python, Ruby,
27shape files, and SQL's CREATE TABLE statements.
28For the time being, if you require any of these languages, please continue to use
29the dia2code-0.8.x C based implementation.
30
31The generation of #include and import directives is automatically done
32considering the types used in each class but they may be added by dependencies.
33Classes are automatically searched in the types of:
34attributes, method's return types, method's parameters, parents, dependencies
35and associations.
36
37Dia2Code handles Associations, Dependencies, Realizations, Implements and
38Generalizations.
39
40Feel free to have a try and send me your comments.
41
42
43LICENSE
44
45This program is distributed under the GNU GPLv3.
46Read the COPYING file for details.
47
48
49REQUIREMENTS
50
51Works under Linux (i386 and x64) and Win32/Win64.
52Feedback about other platforms is welcome.
53
54- Dia (I work with 0.97.2 but older versions *may* be OK).
55- libxml2 headers and development libraries (I use 2.9 but it *may* be
56  OK if you use any version greater than 2.0).
57- A C++ compiler which supports C++11 standard (>=gcc 4.6).
58- automake and autoconf (actually, optional)
59
60
61INSTALLATION
62
63Usually:
64
65        $ ./configure --with-corba
66
67        $ make
68
69        $ make check
70
71        # make install
72
73Read the INSTALL file for details.
74
75If that doesn't work for you, try (from the src's dia2code directory):
76
77        $ g++ -std=c++11 -I/usr/include/libxml2 *.cpp -O2 -o dia2codetest -lxml2 -I..
78
79        $ strip dia2code
80
81To cross-compiling from Linux (build=x86_64-pc-linux-gnu):
82        - To Win32, with package cross-i686-pc-mingw32/gcc:
83        # ./configure --disable-static --enable-shared --build=x86_64-pc-linux-gnu --host=i686-pc-mingw32
84
85        - To Win64, with package cross-x86_64-w64-mingw32/gcc:
86        # ./configure --disable-static --enable-shared --build=x86_64-pc-linux-gnu --host=x86_64-w64-mingw32
87
88        - To Linux32:
89        # ./configure --disable-static --enable-shared -m32
90
91        - To Linux64:
92        # ./configure --disable-static --enable-shared -m64
93
94
95OPERATION
96
97    $ dia2code <parameters>
98
99Where <parameters> can be any combination of:
100
101-h --help            Print this help and exit.
102-d <dir>             Output generated files to <dir>, default is "."
103--buildtree          Convert package names to a directory tree.
104                     Imply -1. Off by default.
105-l <license>         License file to prepend to generated files.
106-nc                  Do not overwrite files that already exist.
107-cl <classlist>      Generate code only for the classes specified in
108                     the comma-separated <classlist>.
109                     E.g: Base,Derived.
110-v                   Invert the class list selection.  When used
111                     without -cl prevents any file from being created.
112--version            Show version x.y.z.
113--tab <number>       Set number of spaces for one indentation.
114                     Default: 4. Maximum: 8.
115-ext <extension>     Use <extension> as the file extension.
116                     Here are the defaults:
117                     ada:"ads", c:"h", cpp:"hpp", idl:"idl",
118                     java:"java", php:"php", python:"py",
119                     csharp:"cs".
120                     Not applicable to shp, sql.
121-bext <extension>    Use <extension> as the body (implementation) file
122                     extension. Only applies to ada and c.
123                     Here are the defaults:
124                     ada:"adb", c:"c".
125-nl                  Create new line on new brace. Off by default.
126-1                   One header contains only one header. If two classes
127                     have the same name, they will be overwritten without
128                     --buildtree.
129                     Off by default but java.
130-t <target>          Selects the output language. <target> can be one of:
131                     ada,as3,c,cpp,cpp11,csharp,idl,java,php,php5,python,
132                     ruby,shp,sql.
133<diagramfile>        The Dia file that holds the diagram to be read.
134
135The only mandatory parameters are the diagram file name and the target.
136
137Note: Parameters can be specified in any order.
138
139
140EXAMPLES
141
142    $ dia2code -t java test.dia
143
144    Will generate the *.java files for the classes in the test.dia diagram
145    and put them in the current directory.
146
147    $ dia2code -t cpp -nc -d ~/C++ hw.dia
148
149    Will generate the *.cpp and *.h files for the classes in the test.dia
150    diagram and put them in the directory ~/C++. It won't overwrite any
151    existant file.
152
153    $ dia2code -t java -cl Base,Derived test.dia
154
155    Will create the Java files only for classes "Base" and "Derived".
156
157    $ dia2code -t cpp -cl B*,*Foo test.dia
158
159    Will create the *.hpp files for classes that begin with "B" or
160    end with "Foo".
161    NOTE: You can only specify one asterisk and either at the beginning or end
162    of the pattern.
163    NOTE2: You may have to quote the asterisks when typing on the shell
164    (e.g. "\*" instead of "*")
165
166    $ dia2code -t cpp -cl Foo -v foobar.dia
167
168    Will create C++ code for all classes but "Foo".
169
170    $ dia2code -t cpp -v test.dia
171
172    Will not create any files. Don't know if it may be useful, but it surely
173    is syntactically correct.
174
175
176NOTES ON UML
177
178What you should put into your diagram
179
180These are mandatory:
181
182- A non-empty class or package name.
183- For each attribute, the name and type.
184- For each method, the name.
185- For each method's parameter, the name and type.
186
187These are optional:
188
189- The stereotype of the class.
190- The default value of attributes.
191- The default value of parameters.
192- The return type of a method. If no type is declared, dia2code
193  will output no type at all for it.
194
195
196OUTPUT
197
198This section shows some examples of UML diagram converted to code without use
199of stereotype.
200Lines starting with double stars are comments to explain the process of the
201generation of the code.
202
203Common:
204If -1 and --buildtree are not specified, the name of each file will be the
205class name (if not in a package) and the name of the top package either.
206If -1 or --buildtree is specified, the filename will be the class name.
207
208
209C++ generator:
210** The license if specified in command line (-l option).
211/*
212File bit-by-bit.
213 */
214
215** Header guard
216#ifndef README__HPP
217#define README__HPP
218
219** Dependencies
220#include "dependencies.hpp"
221
222** Templates
223template <type template>
224
225** Namespace if classes are in package.
226namespace package {
227    ** Class with inheritance if necessary.
228    class Class : public ParentClass {
229        ** Visibility of the attribute / operation. Public, private, protected
230        ** are supported. Implementation is not, default will be public.
231        ** Attributes will be printed first, then operations.
232        // Attributes
233        ** Default values are ignored for attributes.
234        public :
235            ** Comments are in doxygen format.
236            /// Comment for the first
237            /// attribute.
238            type1 nom1;
239        private :
240            /// Example of static attribute.
241            static type2 nom2;
242        protected :
243            type3 nom3;
244        // Operations
245        public :
246            /**
247             * \class AbstractOperation
248             * \brief Multiple line
249             *        comment
250             */
251            ** An abstract operation must not be defined thus " = 0".
252            virtual AbstractOperation () = 0;
253            ** A virtual operation must be defined in the source code.
254            virtual VirtualOperation ();
255            NonAbstractOperation ();
256            /**
257             * \brief comment
258             * \param in (in)
259             * \param inOut (in/out) comment2
260             * \param undef (???)
261             * \param out (out)
262             */
263            virtual type test (type1 in, type2 inOut, type3 undef = 0, type4 out) = 0;
264            static test2 ();
265            test3 () const;
266    };
267}
268
269** End of header guard
270#endif
271
272
273C++11 generator:
274** The license if specified in command line (-l option).
275/*
276File bit-by-bit.
277 */
278
279** Header guard
280#ifndef README__HPP
281#define README__HPP
282
283** Dependencies
284#include "dependencies.hpp"
285
286** Templates
287template <type template>
288
289** Namespace if class are in package.
290namespace package {
291    ** Class with inheritance if necessary.
292    public class Class : public ParentClass {
293        ** Visibility of the attribute / operation. Public, private, protected
294        ** are supported. Implementation is not, default will be public.
295        ** Attributes will be print first, then operations.
296        // Attributes
297        ** Default values are ignored for attributes.
298        public :
299            ** Comments are in doxygen format.
300            /// Comment for the first
301            /// attribute.
302            type1 nom1;
303        private :
304            /// Exemple of static attribut.
305            static type2 nom2;
306        protected :
307            type3 nom3;
308        // Operations
309        public :
310            /**
311             * \class AbstractOperation
312             * \brief Multiple line
313             *        comment
314             */
315            ** An abstract operation must not be defined thus " = 0".
316            virtual AbstractOperation () = 0;
317            ** A virtual operation must be defined in the source code.
318            virtual VirtualOperation ();
319            NonAbstractOperation ();
320            /**
321             * \brief comment
322             * \param in (in)
323             * \param inOut (in/out) comment2
324             * \param undef (???)
325             * \param out (out)
326             */
327            virtual type test (type1 in, type2 inOut, type3 undef = 0, type4 out) = 0;
328            static test2 ();
329            constexpr test3 ();
330    };
331}
332
333** End of header guard
334#endif
335
336
337C# generator:
338https://msdn.microsoft.com/en-us/library/ms228500%28v=vs.90%29.aspx
339
340XML Documentation Comments
341https://msdn.microsoft.com/en-us/library/b2s063f7.aspx
342
343** The license if specified in command line (-l option).
344/*
345File bit-by-bit.
346 */
347
348** No header guard
349
350** Dependencies
351using dependencies;
352
353** Templates
354template <type template>
355
356** Namespace if classes are in package.
357namespace package {
358    ** Class with inheritance and templates if necessary.
359    public class Class <template> : ParentClass where template : type  {
360        ** Attributes will be printed first, then operations.
361        // Attributes
362        ** Comments are in XML format.
363        /// <summary>com1</summary>
364        public type1 nom1 = val1;
365        private static type2 nom2;
366        protected type3 nom3 = val3;
367        // Operations
368        public abstract AbstractOperation ();
369        public virtual VirtualOperation ();
370        public NonAbstractOperation ();
371        /// <summary>comment</summary>
372        /// <param name="in">(in)</param>
373        /// <param name="inOut">(in/out) comment2</param>
374        /// <param name="undef">(???)</param>
375        /// <param name="out">(out)</param>
376        /// <returns>type</returns>
377        public abstract type test (type1 in, type2 inOut, type3 undef = 0, type4 out);
378        public static test2 ();
379        ** There is no const function in C#.
380        public test3 ();
381    };
382}
383
384
385Java generator:
386Convention naming:
387http://www.oracle.com/technetwork/java/codeconventions-135099.html
388
389Packages: all-lowercase ASCII letters and should be one of the top-level domain
390names, currently com, edu, gov, mil, net, org, or one of the English two-letter
391codes identifying countries as specified in ISO Standard 3166, 1981.
392com.sun.eng
393com.apple.quicktime.v2
394edu.cmu.cs.bovik.cheese
395
396Classes or Interfaces:
397Class names should be nouns, in mixed case with the first letter of each
398internal word capitalized.
399class Raster;
400class ImageSprite
401
402Methods:
403Methods should be verbs, in mixed case with the first letter lowercase, with
404the first letter of each internal word capitalized.
405run ();
406runFast ();
407
408Variables:
409Except for variables, all instance, class, and class constants are in mixed
410case with a lowercase first letter. Internal words start with capital letters.
411Variable names should not start with underscore _ or dollar sign $ characters,
412even though both are allowed.
413int             i;
414char            c;
415float           myWidth;
416
417Constants:
418The names of variables declared class constants and of ANSI constants should be
419all uppercase with words separated by underscores ("_").
420static final int MAX_WIDTH = 999;
421
422
423** The license if specified in command line (-l option).
424/*
425File bit-by-bit.
426 */
427
428** No header guard
429
430** Dependencies
431import Dependencies;
432
433** If class are in package.
434package Pack;
435
436** Class with inheritance and templates if necessary.
437public class Class <template extends type> extends ParentClass {
438    ** Attributes will be printed first, then operations.
439    // Attributes
440    ** Comments are in doxygen format.
441    /**
442     * comment.
443     */
444    public type1 nom1 = val1;
445    private static type2 nom2;
446    protected type3 nom3 = val3;
447    // Operations
448    public abstract AbstractOperation ();
449    public VirtualOperation ();
450    public final NonAbstractOperation ();
451    /**
452     * comment
453     * @param in (in)
454     * @param inOut (in/out) comment2
455     * @param undef (???)
456     * @param out (out)
457     * @return type
458     */
459    ** There is no default param in Java.
460    public abstract type test (type1 in, type2 inOut, type3 undef = 0, type4 out);
461    public static test2 ();
462    ** There is no const function in Java.
463    public test3 ();
464}
465
466
467STEREOTYPES
468
469Multiple stereotypes can be applied on each class, attribute, operation,
470inheritance and dependence by separating them with a "," without space.
471For example (without quotes): "interface,getset".
472
473
474- Inheritance or Realization of an interface:
475
476By default, all inheritances are public. Some languages, like C++, allow a
477different visibility like protected or private.
478Possible value: public, private, protected, implementation.
479
480C++ and C++11 generator:
481** The stereotype of Generalization (or Realizes) of three classes are public,
482** protected and private.
483** Implementation visibility is not applicable to C++ generator.
484class InheritanceClasseChildren : public InheritanceClasseImplement, protected InheritanceClasseProtected, private InheritancePack1::InheritanceClassePrivate {
485};
486
487C# generator:
488** Generalization are public only.
489class InheritanceClasseChildren : InheritanceClasseImplement : InheritanceClasseProtected : InheritanceClassePrivate {
490};
491
492Java generator:
493** In Java, Generalization are public only.
494class InheritanceClasseChildren extends InheritanceClasseImplement extends InheritanceClasseProtected extends InheritancePack1.InheritanceClassePrivate {
495};
496
497
498
499- Classes:
500
501CORBAValue:
502----------
503  To enable Corba to a class, the stereotype must be CORBAValue.
504
505GetSet
506------
507  Generate all get/set functions of all attributes. Their visibility will be
508  public. If you want to be able to customize the visibility of the functions
509  or generate get/set only for specifics attributes, use instead GetSet
510  stereotype on operation.
511
512  A "T getA ();" method, with return type conformant to the type of the
513  attribute. If the type of the attribute is boolean (boolean, Boolean or bool)
514  then the name will be: "T isA ()".
515
516  A "void setA (T value);" method, with a parameter, "value", with type
517  conformant to the type of the attribute.
518
519C++ generator:
520** The stereotype of the class is GetSet.
521// Stereotype : GetSet
522public class GetSet {
523    // Attributes
524    private :
525        char * nom;
526        bool boole;
527    // Operations
528    public :
529        char * getNom () const;
530        void setNom (char * value);
531        bool isBoole () const;
532        void setBoole (bool value);
533}
534
535
536C++11 generator:
537** The stereotype of the class is GetSet.
538// Stereotype : GetSet
539public class GetSet {
540    // Attributes
541    private :
542        char * nom;
543        bool boole;
544    // Operations
545    public :
546        constexpr char * getNom ();
547        void setNom (char * value);
548        constexpr bool isBoole ();
549        void setBoole (bool value);
550}
551
552
553C# generator:
554// Stereotype : GetSet
555public class GetSet {
556    // Attributes
557    public type nom;
558    /// <summary>com2</summary>
559    private bool boole;
560    // Operations
561    public type Nom {
562        get {
563        }
564        set {
565        }
566    }
567    public bool Boole {
568        get {
569        }
570        set {
571        }
572    }
573}
574
575
576Java generator:
577** The stereotype of the class is GetSet.
578// Stereotype : GetSet
579public class GetSet {
580    // Attributes
581    private char * nom;
582    private bool boole;
583    // Operations
584    public char * getNom () {
585    }
586    public void setNom (char * value) {
587    }
588    public bool isBoole () {
589    }
590    public void setBoole (bool value) {
591    }
592}
593
594
595const, constant, Const, Constant or CORBAConstant:
596-----  --------  -----  --------    -------------
597
598TODO
599
600
601enum, enumeration, Enum, Enumeration or CORBAEnum:
602----  -----------  ----  -----------    ---------
603
604Generate an enum class. Only attributes will be used. Template or function are
605ignored.
606
607
608C++ generator:
609/// Comment of the enum
610enum enumeration {
611    /// Comment ENUM_1
612    ENUM_1 = 0,
613    /// Comment ENUM_2
614    ENUM_2,
615    /// Comment ENUM_3
616    ENUM_3
617};
618
619
620C++11 generator:
621/// Comment of the enum
622enum class enumeration {
623    /// Comment ENUM_1
624    ENUM_1 = 0,
625    /// Comment ENUM_2
626    ENUM_2,
627    /// Comment ENUM_3
628    ENUM_3
629};
630
631
632C# generator:
633/// <summary>Comment of the enum</summary>
634public enum enumeration {
635    /// <summary>enum1</summary>
636    ENUM_1 = 0,
637    /// <summary>enum2</summary>
638    ENUM_2,
639    ENUM_3
640};
641
642
643Java generator:
644/**
645 * Comment of the enum
646 */
647public enum enumeration {
648    /// Comment ENUM_1
649    ENUM_1 = 0,
650    /// Comment ENUM_2
651    ENUM_2,
652    ENUM_3
653};
654
655
656struct, structure, Struct, Structure, or CORBAStruct:
657------  ---------  ------  ---------     -----------
658
659A structure is almost the same as a class.
660
661
662C++ and C++11 generator:
663** In C++, all attributes and operations are public.
664/// Comment about the structure.
665struct structure {
666    // Attributes
667    /// com1
668    type1 nom1;
669    /// com2-1
670    /// com2-2
671    type2 nom2;
672    type3 nom3;
673    // Operations
674    void operation (type1 attr1);
675};
676
677
678C# generator:
679public struct structure {
680    /// <summary>com1</summary>
681    public type1 nom1;
682    /// <summary>com2-1
683    /// com2-2</summary>
684    public type2 nom2;
685    public type3 nom3;
686    public void operation (type1 attr1) {
687    }
688};
689
690
691Java generator:
692** In Java, structure is not defined. The equivalent is a class.
693/**
694 * Comment about the structure.
695 */
696public class structure {
697    // Attributes
698    /**
699     * com1
700     */
701    public type1 nom1;
702    /**
703     * com2-1
704     * com2-2
705     */
706    private type2 nom2;
707    protected type3 nom3;
708    // Operations
709    public void operation (type1 attr1) {
710    }
711};
712
713
714typedef, Typedef or CORBATypedef:
715-------  -------    ------------
716
717A typedef defines a type as a derivated of another one.
718The name of the new type is the name of the classe.
719The name of the derivated type is the name of the first attribute.
720All other information is ignored.
721Not applicable in Java.
722
723
724C++ and C++11 generator:
725#include "Pack.hpp"
726
727typedef PrimitiveType NewType1;
728typedef Pack::ClassType NewType2;
729
730C# generator:
731using Pack;
732
733public class AliasOfMyClass : MyClass {}
734public class ArrayOfBool : bool[3][10] {}
735
736
737Java generator:
738import Pack.ClassType;
739
740class NewType1 extends PrimitiveType {}
741class NewType2 extends Pack.ClassType {}
742
743
744extern:
745------
746Define a external class. Usefull for external dependencies when you don't want
747to generate the class' source.
748IMPORTANT for C++ generator: because extern can define a system header <list>
749or a header for another <Class.hpp>, no extension will be automatically added.
750If a class implements such external class, the extension (if so) will be
751removed.
752
753
754C++ and C++11 generator:
755#include <Pack/Class.hpp>
756
757
758C# generator:
759using Pack;
760
761
762Java generator:
763import Pack.Class;
764
765
766interface, Interface:
767---------  ---------
768Define a interface. The class will be automatically considers as a interface if
769a Realization or a Implementation link are pointing to it.
770
771
772C++ and C++11 generator:
773class Interface2 {
774};
775
776
777C# generator:
778public interface Interface2 {
779}
780
781
782Java generator:
783public interface Interface2 {
784}
785
786
787dllexport, DllExport:
788---------  ---------
789Force some signature to be store in a Microsoft Library Manager (lib).
790
791
792C++ and C++11 generator:
793class DllExport operations {
794}
795// Don't forget to add a #define:
796// #define DllExport __declspec (dllexport)
797
798
799C# generator:
800Java generator:
801PHP gerenator:
802not supported
803
804
805- Operation:
806
807delete, Delete:
808------  ------
809In C++11, a deleted function must be defined in the header.
810Not applicable in C# and Java.
811
812C++ generator:
813** In C++, there is no keyword for function hiding (as `delete` in C++11).
814** So the common way to delete a function (like copy constructor) is to make
815** the function private and not define it in source.
816class operations {
817    private :
818        test5 ();
819}
820
821
822C++11 generator:
823class operations {
824    public :
825        test5 () = delete;
826}
827
828
829C# generator:
830** Not applicable in C#.
831class operations {
832    public test5 () {
833    }
834}
835
836
837Java generator:
838** Not applicable in Java.
839class operations {
840    public test5 () {
841    }
842}
843
844
845GetSet:
846------
847This feature will generate the same output as GetSet for class except it will
848respect the visibility of the operation. You also need to define the attribute.
849
850
851dllexport, DllExport:
852---------  ---------
853Force some signature to be stored in a Microsoft Library Manager (lib).
854
855
856C++ and C++11 generator:
857class operations {
858  DllExport test ();
859}
860// Don't forget to add a #define:
861// #define DllExport __declspec (dllexport)
862
863
864C# generator:
865Java generator:
866PHP gerenator:
867not supported
868
869
870- Attributes:
871
872Some stereotypes are supported that all begin with "CORBA". These are:
873CORBAConstant, CORBAEnum, CORBAException, CORBANative, CORBATypedef,
874CORBAStruct, CORBAUnion, CORBAValue.
875When generating IDL, the corresponding IDL syntax is generated for the UML
876class. When generating other languages, a rough mapping from the IDL to the
877other language is generated.
878
879The following conventions are followed by the code generation for CORBA
880stereotypes:
881
882Constant   First attribute's type contains the const type; first attribute's
883           value contains the const's value. Everything else unused.
884Enum       Attribute names contain the enum literals, everything else unused.
885Exception  TODO.
886Native     TODO.
887Typedef    First attribute's type contains the original type;
888           first attribute's value optionally contains the dimensions
889           in case of an array. Everything else unused.
890Struct     Attribute names and types contain the struct members.
891           Everything else unused.
892Union      First attribute's type contains the switch type. Only
893           enum types are supported as the switch type.
894           Following attributes contain the union cases as follows:
895           Attribute value contains the switch value for the case
896           (only exactly one value possible per case); attribute
897           name and type contains the union member name and type
898           for that case.
899           Everything else unused.
900Value      Use much like a normal class. Staticness not supported.
901
902
903- Dependency:
904
905NoLoop, noloop
906------  ------
907In C/C++, circular dependencies are really messy with include and only the user
908can handle it. Adding a "NoLoop" stereotype will disable the "#include" for the
909connection.
910
911
912MISCELLANEOUS
913
914Visibility
915
916Dia2Code does not handle the "implementation" visibility for methods.
917So when you have a class that implements a method that was declared
918abstract in a base class, you have to give it the same visibility of the
919parent class' method. The visibility of the method is not printed if it is
920"implementation"; this may be a source of bugs.
921
922
923Method's return type
924
925If you leave the "type" entry in the method declaration empty, then no
926type will be declared for it. This is useful with constructors, when the
927return type is implicit (both in C++ and Java). If the return type is
928void, you should explicitly declare it in the UML diagram.
929
930
931Packages
932
933The UML standard states that there are two ways of representing packages:
934a large box with all the elements inside (Large Package in Dia) or a small box
935(Small Package in Dia) to which the package's elements connect with a symbol
936that Dia does not include: a line with a crossed out circle in the end of the
937container. You can put a normal line with a "Coordiate origin" arrow at one
938end, of course, and will be aesthetically correct, but of no use to Dia2Code.
939
940Dia2code, currently, checks only for intersections of packages (Large or
941Small) with other objects like classes and other packages, so it will
942be mostly useful with diagrams that use Large Packages instead of Small
943ones.
944
945
946INFORMATION FOR DEVELOPERS
947
948How it works:
949
9501. Parse the diagram file with xmlParseFile().
9512. Parse the tree generated in 1 for UML classes to build an
952   umlclasslist (type defined here).
9533. Parse the tree again for UML Generalizations, Realizations,
954   Implements, Dependencies, Associations and packages to add information
955   to the class list.
9564. Generate the structure of the classes (write it into files)
957   from the class list.
958
959Steps 1-3 are done in parse_diagram ().
960Step 4 is done in GenerateCode* ().
961Both functions are called from main ().
962
963
964Code Generators:
965
966**IMPORTANT**: When a modification is done in a generator, BE SURE to do the
967same with all generators if necessary.
968
969A code generator (class derived from GenerateCode) is a class that takes
970reference to a DiaGram class.
971
972The DiaGram class contains:
973  - std::list <umlClassNode> uml; // a list of all class nodes.
974
975The GenerateCode class contains:
976  - DiaGram &   dia;           // a reference to a DiaGram class.
977  - std::string license;       // file that contains the license.
978  - std::string outdir;        // folder where to write the headers.
979                               // empty for current folder.
980  - std::string file_ext;      // extension of header.
981  - std::string body_file_ext; // extension of body file (if usefull).
982
983  - uint8_t     indent : 4; // number of space of each indent.
984    uint32_t    getIndent () const;
985    void        setIndent (uint8_t spaces);
986
987  - bool        overwrite : 1; // allow overwriting existing file.
988    bool        getOverwrite () const;
989    void        setOverwrite (bool over);
990
991  - bool        buildtree : 1; // create one folder for each package.
992    bool        getBuildTree () const;
993    void        setBuildTree (bool build);
994
995  - bool        bOpenBraceOnNewline : 1; // open brace on new line.
996    bool        getOpenBraceOnNewline () const;
997    void        setOpenBraceOnNewline (bool newline);
998
999  - bool        oneClassOneHeader : 1; // Only one class par header.
1000    bool        getOneClass () const;
1001    void        setOneClass (bool val);
1002
1003
1004New generator:
1005
1006The new generator is a class that inherits from GenerateCode. All virtual
1007functions must be overridden. Developers can get an idea on how to write a
1008new generator by having a good look inside GenerateCodeCpp.cpp.
1009
1010  - writeLicense ();
1011Write the license at the top of each header. The characters that start and end
1012multiple line comments must be added before and after the file.
1013The license is specified by the attribute license.
1014
1015  - writeStartHeader (std::string & name);
1016Write the mechanism that avoids multiple inclusion (applies to C/C++).
1017  - writeEndHeader ();
1018Finish the mechanism that avoids multiple inclusion.
1019
1020  - writeInclude (std::basic_string <char> name);
1021  - writeInclude (const char * name);
1022Write the instruction that includes a file (header).
1023
1024  - writeFunctionComment (const umlOperation & ope);
1025Write the comment for a function and its parameters. Use well-known format.
1026C++ uses doxygen format.
1027
1028  - writeFunction (const umlOperation & ope, int * curr_visibility);
1029Write the header of a function. The current visibility is used to avoid writing
1030it every time.
1031
1032  - writeComment (const std::string & text);
1033  - writeComment (const char * text);
1034Write a single comment, not in the well-known format.
1035
1036  - writeClassComment (const umlClassNode & node);
1037Write the comment for a class by using the well-known format.
1038
1039  - writeClass (const umlClassNode & node);
1040Write the beginning of a class (name, inheritance and visibility).
1041  - writeClassEnd ();
1042End the class.
1043
1044  - writeAttribute (const umlAttribute & attr, int * curr_visibility);
1045Write an attribute inside of a class.
1046
1047  - writeNameSpaceStart (const umlClassNode * name);
1048Start a package.
1049  - writeNameSpaceEnd (const umlClassNode * node);
1050End a package.
1051
1052  - writeConst (const umlClassNode & node);
1053Write a class which is a const type (stereotype "const", "constant" or
1054"CORBAConstant").
1055
1056  - writeEnum (const umlClassNode & node);
1057Write a class which is an enum type (stereotype "enum", "enumeration" or
1058"CORBAEnum").
1059
1060  - writeStruct (const umlClassNode & node);
1061Write a class which is an structure type (stereotype "struct", "structure" or
1062"CORBAStruct").
1063
1064  - writeTypedef (const umlClassNode & node);
1065Write a class which is a typedef type (stereotype "typedef" or "CORBATypedef").
1066
1067  - writeAssociation (const umlassoc & asso);
1068Write an association.
1069
1070  - writeTemplates (
1071               const std::list <std::pair <std::string, std::string> > & tmps);
1072Write a template.
1073
1074Add a new generator to the main program:
1075The following files need to be updated:
1076 - src/main.cpp:
1077     - add a new include at the top of the file with the header of the new
1078       generator,
1079     - inside the variable const char *help, add the abreviation of the
1080       language,
1081     - inside the variable const char *bighelp, change -ext, -bext and -t
1082       options,
1083     - and finally add it inside the main loop, in "case 1".
1084 - src/Makefile.am:
1085     - add the source in dia2code_SOURCES,
1086     - add the header in EXTRA_DIST.
1087 - builds/vs-community-2013/dia2code.vcxproj
1088     - add the new source and header files.
1089 - README:
1090     - add examples for classic usecases and for the different stereotypes.
1091 - tests/tests.sh:
1092     - add your new generator to generators.
1093And of course, don't forget to run "git add GenerateCodeXXX.?pp".
1094
1095
1096KNOWN BUGS
1097
1098- Packages of classes are searched using the position and size instead of
1099  <dia:childnode parent="O0"/>
1100
1101
1102AUTHOR, MAINTAINER and THANKS
1103
1104Javier O'Hara <joh314@users.sourceforge.net>
1105

README.win32

1INSTALLATION
2The windows version of dia2code is distributed as an
3executable installer. Just run the installer to set
4up the program.
5USAGE
6The installer will add context menu entries for .dia files.
7These entries are accessible through right-mouse-clicks in
8the Windows Explorer. The following options are available in
9version 0.8.5:
10* Create Ada code
11* Create C code
12* Create C++ code
13* Create C# code
14* Create IDL code
15* Create Java code
16* Create PHP code
17* Create PHP 5 code
18* Create Python code
19* Create Ruby code
20* Create Shapefile generation script
21* Create SQL definition
22UNINSTALLATION
23The dia2code installer adds an uninstall option to the Windows
24start menu.
25COMPILATION
26The sourcecode of dia2code is available from http://dia2code.sourceforge.net
27You will need the binary distribution of libxml2 (See
28http://www.zlatkovic.com/libxml.en.html).
29There are different options to compile dia2code on Windows.
30A Dev-C++ project file (dia2code.dev) is part of the dia2code
31sources. Dev-C++ is a free C++ IDE:
32http://www.bloodshed.net/devcpp.html
33Cygwin might be another option: See http://www.cygwin.com
34Compiling the source *.c files (example using Cygwin):
35gcc -mno-cygwin -fnative-struct -I PATH_TO_LIBXML2_INCLUDES -c main.c
36Linking dia2code:
37gcc -mno-cygwin -fnative-struct -o dia2code.exe *.o -L PATH_TO_LIBXML2_DLL -lxml2
38--
39Steffen Macke <sdteffen@gmail.com>
40
41