Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Poirier <theeth@yahoo.com>2010-02-01 04:43:31 +0300
committerMartin Poirier <theeth@yahoo.com>2010-02-01 04:43:31 +0300
commit678f68550ba96cf539bd50d197680537741b3c83 (patch)
treefebf9ac567f0b98739a3d7556216a9809604b053 /source/blender/blenlib/BLI_args.h
parent7379e75e12c5d5de2181802f5d2cd71f4c9c73f1 (diff)
New argument parsing library supporting multiple passes, case sensitive and insensitive arguments, default handlers and other features that were hacked in the previous ugly switch system. Very simpler system for adding new arguments, easier to see conflicts and no more replication between BG and non BG mode arguments.
I've tested pretty much everything except GE options (-g options), but some small bugs could have sneaked in.
Diffstat (limited to 'source/blender/blenlib/BLI_args.h')
-rw-r--r--source/blender/blenlib/BLI_args.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_args.h b/source/blender/blenlib/BLI_args.h
new file mode 100644
index 00000000000..c953774dd40
--- /dev/null
+++ b/source/blender/blenlib/BLI_args.h
@@ -0,0 +1,53 @@
+/**
+ * A general argument parsing module
+ *
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef BLI_ARGS_H
+#define BLI_ARGS_H
+
+struct bArgs;
+typedef struct bArgs bArgs;
+
+/* returns the number of extra arguments consumed by the function. 0 is normal value, -1 stops parsing arguments, other negative indicates skip */
+typedef int (*BA_ArgCallback)(int argc, char **argv, void *data);
+
+struct bArgs *BLI_argsInit(int argc, char **argv);
+void BLI_argsFree(struct bArgs *ba);
+
+/* pass starts at 1, -1 means valid all the time */
+void BLI_argsAdd(struct bArgs *ba, char *arg, int pass, BA_ArgCallback cb, void *data);
+void BLI_argsAddCase(struct bArgs *ba, char *arg, int pass, BA_ArgCallback cb, void *data); /* not case specific */
+
+void BLI_argsParse(struct bArgs *ba, int pass, BA_ArgCallback default_cb, void *data);
+
+void BLI_argsPrint(struct bArgs *ba);
+char **BLI_argsArgv(struct bArgs *ba);
+
+#endif