From f034231a6a1fd5d6395206c1651de8cd9402cca3 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Fri, 23 Aug 2013 17:46:38 +0000 Subject: Import lldb as of SVN r188801 (A number of files not required for the FreeBSD build have been removed.) Sponsored by: DARPA, AFRL --- source/Interpreter/OptionGroupOutputFile.cpp | 81 ++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 source/Interpreter/OptionGroupOutputFile.cpp (limited to 'source/Interpreter/OptionGroupOutputFile.cpp') diff --git a/source/Interpreter/OptionGroupOutputFile.cpp b/source/Interpreter/OptionGroupOutputFile.cpp new file mode 100644 index 000000000000..aa01bf54964f --- /dev/null +++ b/source/Interpreter/OptionGroupOutputFile.cpp @@ -0,0 +1,81 @@ +//===-- OptionGroupOutputFile.cpp -------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Interpreter/OptionGroupOutputFile.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Utility/Utils.h" + +using namespace lldb; +using namespace lldb_private; + +OptionGroupOutputFile::OptionGroupOutputFile() : + m_file (), + m_append (false, false) +{ +} + +OptionGroupOutputFile::~OptionGroupOutputFile () +{ +} + +static OptionDefinition +g_option_table[] = +{ + { LLDB_OPT_SET_1 , false, "outfile", 'o', required_argument, NULL, 0, eArgTypeFilename , "Specify a path for capturing command output."}, + { LLDB_OPT_SET_1 , false, "append-outfile" , 'apnd', no_argument, NULL, 0, eArgTypeNone , "Append to the the file specified with '--outfile '."}, +}; + +uint32_t +OptionGroupOutputFile::GetNumDefinitions () +{ + return llvm::array_lengthof(g_option_table); +} + +const OptionDefinition * +OptionGroupOutputFile::GetDefinitions () +{ + return g_option_table; +} + +Error +OptionGroupOutputFile::SetOptionValue (CommandInterpreter &interpreter, + uint32_t option_idx, + const char *option_arg) +{ + Error error; + const int short_option = g_option_table[option_idx].short_option; + + switch (short_option) + { + case 'o': + error = m_file.SetValueFromCString (option_arg); + break; + + case 'apnd': + m_append.SetCurrentValue(true); + break; + + default: + error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); + break; + } + + return error; +} + +void +OptionGroupOutputFile::OptionParsingStarting (CommandInterpreter &interpreter) +{ + m_file.Clear(); + m_append.Clear(); +} -- cgit v1.3