2011-04-28 06:04:39 +08: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-14 04:21:08 +08:00
# include "lldb/Interpreter/OptionGroupOutputFile.h"
2011-04-28 06:04:39 +08:00
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
2011-09-10 08:48:33 +08:00
# include "lldb/Utility/Utils.h"
2011-04-28 06:04:39 +08:00
using namespace lldb ;
using namespace lldb_private ;
OptionGroupOutputFile : : OptionGroupOutputFile ( ) :
m_file ( ) ,
m_append ( false , false )
{
}
OptionGroupOutputFile : : ~ OptionGroupOutputFile ( )
{
}
2014-03-18 12:43:47 +08:00
static const uint32_t SHORT_OPTION_APND = 0x61706e64 ; // 'apnd'
2011-04-28 06:04:39 +08:00
static OptionDefinition
g_option_table [ ] =
{
2014-07-10 00:31:49 +08:00
{ LLDB_OPT_SET_1 , false , " outfile " , ' o ' , OptionParser : : eRequiredArgument , nullptr , nullptr , 0 , eArgTypeFilename , " Specify a path for capturing command output. " } ,
2014-03-18 12:43:47 +08:00
{ LLDB_OPT_SET_1 , false , " append-outfile " , SHORT_OPTION_APND ,
2014-07-10 00:31:49 +08:00
OptionParser : : eNoArgument , nullptr , nullptr , 0 , eArgTypeNone ,
2015-06-18 13:27:05 +08:00
" Append to the file specified with '--outfile <path>'. " } ,
2011-04-28 06:04:39 +08:00
} ;
uint32_t
OptionGroupOutputFile : : GetNumDefinitions ( )
{
2012-05-16 07:21:36 +08:00
return llvm : : array_lengthof ( g_option_table ) ;
2011-04-28 06:04:39 +08:00
}
const OptionDefinition *
OptionGroupOutputFile : : GetDefinitions ( )
{
return g_option_table ;
}
Error
2016-08-12 07:51:28 +08:00
OptionGroupOutputFile : : SetOptionValue ( uint32_t option_idx ,
const char * option_arg ,
ExecutionContext * execution_context )
2011-04-28 06:04:39 +08:00
{
Error error ;
2012-12-04 08:32:51 +08:00
const int short_option = g_option_table [ option_idx ] . short_option ;
2011-04-28 06:04:39 +08:00
switch ( short_option )
{
case ' o ' :
2015-02-20 19:14:59 +08:00
error = m_file . SetValueFromString ( option_arg ) ;
2011-04-28 06:04:39 +08:00
break ;
2014-03-18 12:43:47 +08:00
case SHORT_OPTION_APND :
2011-04-28 06:04:39 +08:00
m_append . SetCurrentValue ( true ) ;
break ;
default :
2011-10-26 08:56:27 +08:00
error . SetErrorStringWithFormat ( " unrecognized option '%c' " , short_option ) ;
2011-04-28 06:04:39 +08:00
break ;
}
return error ;
}
void
2016-08-12 07:51:28 +08:00
OptionGroupOutputFile : : OptionParsingStarting (
ExecutionContext * execution_context )
2011-04-28 06:04:39 +08:00
{
m_file . Clear ( ) ;
m_append . Clear ( ) ;
}