From 2388a588bdf32610e18a66c0c6ef248087fd1cdc Mon Sep 17 00:00:00 2001 From: Mikhail Glushenkov Date: Fri, 16 Jan 2009 07:02:28 +0000 Subject: Registry.h should not depend on CommandLine.h. Split Support/Registry.h into two files so that we have less to recompile every time CommandLine.h is changed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62312 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/RegistryParser.h | 55 +++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 include/llvm/Support/RegistryParser.h (limited to 'include/llvm/Support/RegistryParser.h') diff --git a/include/llvm/Support/RegistryParser.h b/include/llvm/Support/RegistryParser.h new file mode 100644 index 0000000000..2cc578370f --- /dev/null +++ b/include/llvm/Support/RegistryParser.h @@ -0,0 +1,55 @@ +//=== RegistryParser.h - Linker-supported plugin registries -----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Defines a command-line parser for a registry. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_REGISTRY_PARSER_H +#define LLVM_SUPPORT_REGISTRY_PARSER_H + +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Registry.h" + +namespace llvm { + + /// A command-line parser for a registry. Use like such: + /// + /// static cl::opt::entry, false, + /// RegistryParser > + /// GCOpt("gc", cl::desc("Garbage collector to use."), + /// cl::value_desc()); + /// + /// To make use of the value: + /// + /// Collector *TheCollector = GCOpt->instantiate(); + /// + template > + class RegistryParser : + public cl::parser, + public Registry::listener { + typedef U traits; + typedef typename U::entry entry; + typedef typename Registry::listener listener; + + protected: + void registered(const entry &E) { + addLiteralOption(traits::nameof(E), &E, traits::descof(E)); + } + + public: + void initialize(cl::Option &O) { + listener::init(); + cl::parser::initialize(O); + } + }; + +} + +#endif // LLVM_SUPPORT_REGISTRY_PARSER_H -- cgit v1.2.3