2011-04-27 22:04:39 +00:00
//===-- OptionGroupOutputFile.cpp -------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
2011-05-13 20:21:08 +00:00
# include "lldb/Interpreter/OptionGroupOutputFile.h"
2011-04-27 22:04:39 +00:00
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
2011-09-10 00:48:33 +00:00
# include "lldb/Utility/Utils.h"
2011-04-27 22:04:39 +00:00
using namespace lldb ;
using namespace lldb_private ;
OptionGroupOutputFile : : OptionGroupOutputFile ( ) :
m_file ( ) ,
m_append ( false , false )
{
}
OptionGroupOutputFile : : ~ OptionGroupOutputFile ( )
{
}
static OptionDefinition
g_option_table [ ] =
{
2013-09-05 16:42:23 +00:00
{ LLDB_OPT_SET_1 , false , " outfile " , ' o ' , OptionParser : : eRequiredArgument , NULL , 0 , eArgTypeFilename , " Specify a path for capturing command output. " } ,
{ LLDB_OPT_SET_1 , false , " append-outfile " , ' apnd ' , OptionParser : : eNoArgument , NULL , 0 , eArgTypeNone , " Append to the the file specified with '--outfile <path>'. " } ,
2011-04-27 22:04:39 +00:00
} ;
uint32_t
OptionGroupOutputFile : : GetNumDefinitions ( )
{
2012-05-15 23:21:36 +00:00
return llvm : : array_lengthof ( g_option_table ) ;
2011-04-27 22:04:39 +00:00
}
const OptionDefinition *
OptionGroupOutputFile : : GetDefinitions ( )
{
return g_option_table ;
}
Error
OptionGroupOutputFile : : SetOptionValue ( CommandInterpreter & interpreter ,
2012-12-04 00:32:51 +00:00
uint32_t option_idx ,
const char * option_arg )
2011-04-27 22:04:39 +00:00
{
Error error ;
2012-12-04 00:32:51 +00:00
const int short_option = g_option_table [ option_idx ] . short_option ;
2011-04-27 22:04:39 +00:00
switch ( short_option )
{
case ' o ' :
error = m_file . SetValueFromCString ( option_arg ) ;
break ;
2012-12-04 00:32:51 +00:00
case ' apnd ' :
2011-04-27 22:04:39 +00:00
m_append . SetCurrentValue ( true ) ;
break ;
default :
2011-10-26 00:56:27 +00:00
error . SetErrorStringWithFormat ( " unrecognized option '%c' " , short_option ) ;
2011-04-27 22:04:39 +00:00
break ;
}
return error ;
}
void
OptionGroupOutputFile : : OptionParsingStarting ( CommandInterpreter & interpreter )
{
m_file . Clear ( ) ;
m_append . Clear ( ) ;
}