aboutsummaryrefslogtreecommitdiff
path: root/support/lib/Support/ProgramOption.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-07-23 02:35:57 +0000
committerChris Lattner <sabre@nondot.org>2001-07-23 02:35:57 +0000
commit8f367bd3c0f56b7b318c46cee04f77735f617777 (patch)
treeef00b00e2465f9168bbbd83fd2ebef8fa857146f /support/lib/Support/ProgramOption.cpp
parenta28504313d4c3fe87173a71b511dd4c8e25c3312 (diff)
Large scale changes to implement new command line argument facility
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'support/lib/Support/ProgramOption.cpp')
-rw-r--r--support/lib/Support/ProgramOption.cpp114
1 files changed, 0 insertions, 114 deletions
diff --git a/support/lib/Support/ProgramOption.cpp b/support/lib/Support/ProgramOption.cpp
deleted file mode 100644
index 6b391bc714..0000000000
--- a/support/lib/Support/ProgramOption.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-// $Id$
-//***************************************************************************
-//
-// File:
-// ProgramOption.C
-//
-// Purpose:
-// General representations for a program option.
-//
-// History:
-// 08/08/95 - adve - created in the dHPF compiler
-// 11/26/96 - adve - EvalOpt now returns #args consumed, or -1 for error
-// 07/15/01 - vadve - Copied to LLVM system and modified
-//
-//**************************************************************************/
-
-#include "llvm/Support/ProgramOption.h"
-#include <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-//**************************************************************************/
-
-StringOption::StringOption(const string &_argString,
- const string &_helpMesg,
- const string &_initValue,
- bool _append)
- : ProgramOption(_argString, _helpMesg),
- value(_initValue),
- append(_append)
-{}
-
-int StringOption::EvalOpt(const string &optarg) {
- if (optarg == (char*) NULL)
- return -1; // flag the error
-
- if (this->append)
- value += optarg;
- else
- value = optarg;
-
- optionSpecified = true;
- return 1; // one additional argument consumed
-}
-
-
-//**************************************************************************/
-
-FlagOption::FlagOption(const string &_argString,
- const string &_helpMesg,
- bool _initValue)
- : ProgramOption(_argString, _helpMesg, 0),
- value(_initValue)
-{}
-
-int FlagOption::EvalOpt(const string &optarg) {
- if (optarg == "0") {
- value = false;
- return 1; // one additional argument consumed
- }
- else {
- value = true;
- return 0; // zero ... consumed
- }
-}
-
-//**************************************************************************/
-
-RealValuedOption::RealValuedOption(const string &_argString,
- const string &_helpMesg,
- double _initValue)
- : ProgramOption(_argString, _helpMesg),
- value(_initValue)
-{}
-
-int RealValuedOption::EvalOpt(const string &optarg) {
- if (optarg == "") return -1;
-
- char* lastCharScanned = NULL;
- value = strtod(optarg.c_str(), &lastCharScanned);
- if (! (*lastCharScanned == '\0')) // look for incorrect or partially
- return -1; // correct numerical argument
-
- optionSpecified = true;
- return 1;
-}
-
-string RealValuedOption::GetTextValue() const {
- char buffer[40];
- sprintf(buffer, "%f", value);
- return buffer;
-}
-
-//**************************************************************************/
-
-IntegerValuedOption::IntegerValuedOption(const string &_argString,
- const string &_helpMesg,
- int _initValue)
- : RealValuedOption(_argString, _helpMesg, (double) _initValue)
-{}
-
-int IntegerValuedOption::Value() const {
- double realValue = RealValuedOption::Value();
- assert(realValue == (int) realValue);
- return (int) realValue;
-}
-
-string IntegerValuedOption::GetTextValue() const {
- char buffer[40];
- sprintf(buffer, "%d", Value());
- return buffer;
-}
-
-