From: Robert K. <ro...@br...> - 2003-02-25 13:11:30
|
Here is the "ini file" documentation again. Also know that if no -ini option is given, it'll look for ... umm ... = "dia2code.ini", and then "~/.dia2code/dia2code.ini". For win32, it's $HOME/dia2code/dia2code.ini ... I think. Ask me if you = have questions. Rob ----- Original Message -----=20 From: Robert Konigsberg=20 To: dia...@li...=20 Sent: Friday, February 21, 2003 10:01 PM Subject: [Dia2code-general] Changes checked in Okay, I've put my changes into CVS. NOW, HOW TO USE NEW -ini OPTION I've added a command-line option, called "-ini <filename>" which will = allow you to specify command-line options in a file. I envision that if = we start adding flexibility to the tool, then people will want to = specify the options outside of a command-line, thus making it a little = more manageable. Right now the code only handles these three options 1. file.outdir (eqivalent to -d option) 2. indent.size - how many spaces do you want to indent (currently only = the Java generator uses this.) 3. indent.brace.newline - If open-braces should be on the next line. = YES/NO option, (currently only the Java generator uses this.) Two example files are: $ cat test.ini file.outdir=3D./java indent.brace.newline=3Dyes indent.size=3D4 $ cat test2.ini file.outdir=3D./java2 indent.brace.newline=3Dno indent.size=3D8 BEFORE YOU ADD TO MY OPTIONS, AND BEFORE YOU SAY "Why did you decide to = use a.b.c mnemonics?" I chose based upon two factors: 1. They're only examples, we can remove them. 2. Cause I wrote it, I chose it. :) Okay, only one good factor. Before you start adding them, though, someone should manage them. OR, = add them, but they should be considered an "experimental option" until = they're more heavily used. An examples of good options use is: generate.java.attributes.asgetset=3Dyes (All attributes are = defined private, but a get/set is provided at the scope you requested.) HOW TO ADD YOUR OWN OPTIONS: In main.c, you will find this piece of code: #define PARSE_TYPE_FUNCTION 0 #define PARSE_TYPE_INT 1 #define PARSE_TYPE_STRCPY 2 #define PARSE_TYPE_STRDUP 3 #define PARSE_TYPE_YESNO 4 #define PARSE_TYPE_TRUEFALSE 5 ini_parse_command ini_parse_commands[] =3D { {"file.outdir", PARSE_TYPE_STRDUP, &outdir}, {"indent.brace.newline", PARSE_TYPE_YESNO, = &indent_open_brace_on_newline}, {"indent.size", PARSE_TYPE_INT, &indent_count}, {"generate.backup", PARSE_TYPE_YESNO, &generate_backup}, **** // ADD MORE ENTRIES HERE **** {NULL, -1, NULL} }; The **** line **** above is not actually in the code, it's a note for = you. If you want another type of command parsed, you can put it there. Each line has three items: 1. string mnemonic (as you should be able to infer) 2. How the parameter is parsed (see the list of possible parse types = above it.) 3. a pointer. For PARSE_TYPE_INT, PARSE_TYPE_YESNO and PARSE_TYPE_TRUEFALSE, = parameter 3 should be (int *) PARSE_TYPE_INT converts directly to int PARSE_TYPE_YESNO converts first character from y/n to 1/0 (case = insensitive) PARSE_TYPE_TRUEFALSE converts first character from t/f to 1/0 (case = insensitive) For PARSE_TYPE_STRCPY, parameter 3 should be (char *) PARSE_TYPE_STRCPY does direct strcpy (good if you preallocate your = char * buffer) For PARSE_TYPE_STRDUP, parameter 3 should be ((char *)*) (that is why = the example for file.outdir is &outdir, while outdir is char *) PARSE_TYPE_STRDUP does strdup (good if you do not preallocate your = char * buffer) For PARSE_TYPE_FUNCTION, parameter 3 should be a pointer to function = void func(char *name, char *param) PARSE_TYPE_FUNCTION passes it along to a function for processing. This = is good for options such as: generate.classes.include=3DClass1;Class2;Class3 If you want some examples of the other types, let me know. |