blob: 2a4e8dce0704a3e9067dc606b1597b59701e7c14 [file] [log] [blame]
Greg Clayton57b3c6b2011-04-27 22:04:39 +00001//===-- OptionGroupOutputFile.cpp -------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "OptionGroupOutputFile.h"
11
12// C Includes
13// C++ Includes
14// Other libraries and framework includes
15// Project includes
16
17using namespace lldb;
18using namespace lldb_private;
19
20OptionGroupOutputFile::OptionGroupOutputFile() :
21 m_file (),
22 m_append (false, false)
23{
24}
25
26OptionGroupOutputFile::~OptionGroupOutputFile ()
27{
28}
29
30static OptionDefinition
31g_option_table[] =
32{
33{ LLDB_OPT_SET_1 , false, "outfile", 'o', required_argument, NULL, 0, eArgTypePath , "Specify a path for capturing command output."},
34{ LLDB_OPT_SET_1 , false, "append-outfile" , 'A', no_argument, NULL, 0, eArgTypeNone , "Append to the the file specified with '--outfile <path>'."},
35};
36
37const uint32_t k_num_file_options = sizeof(g_option_table)/sizeof(OptionDefinition);
38
39uint32_t
40OptionGroupOutputFile::GetNumDefinitions ()
41{
42 return k_num_file_options;
43}
44
45const OptionDefinition *
46OptionGroupOutputFile::GetDefinitions ()
47{
48 return g_option_table;
49}
50
51Error
52OptionGroupOutputFile::SetOptionValue (CommandInterpreter &interpreter,
53 uint32_t option_idx,
54 const char *option_arg)
55{
56 Error error;
57 char short_option = (char) g_option_table[option_idx].short_option;
58
59 switch (short_option)
60 {
61 case 'o':
62 error = m_file.SetValueFromCString (option_arg);
63 break;
64
65 case 'A':
66 m_append.SetCurrentValue(true);
67 break;
68
69 default:
70 error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option);
71 break;
72 }
73
74 return error;
75}
76
77void
78OptionGroupOutputFile::OptionParsingStarting (CommandInterpreter &interpreter)
79{
80 m_file.Clear();
81 m_append.Clear();
82}